Bug canvasdraw et/ou drawinput

Accueil Forums Programmation WIMS Programmation d’exercices OEF Bug canvasdraw et/ou drawinput

Vous lisez 11 fils de discussion
  • Auteur
    Messages
    • #5877
      Christophe Barnier
      Participant
      Up
      0
      Down
      ::

      Bonjour,
      Cet exercice fonctionnait très bien mais il ne fonctionne plus… Je n’arrive pas à savoir ce qu’il se passe.

      \title{Arbre de probabilité à compléter}
      \language{fr}
      \range{-5..5}
      \author{Barnier Christophe}
      \email{barnierchr@gmail.com}
      \computeanswer{no}
      \format{html}
      \precision{10000}
      
      \text{liste=C,D,E,F,G,H,L,M,N,P,R,S,T}
      \text{listem=shuffle(\liste)}
      \text{A=\listem[1]}
      \text{B=\listem[2]}
      
      \real{pA=randint(1..99)/100}
      \real{pnA=1-\pA}
      \real{pBsA=randint(1..99)/100} p de B sachant A
      \real{pnBsA=1-\pBsA}
      \real{pBsnA=randint(1..99)/100}
      \real{pnBsnA=1-\pBsnA}
      \real{pAB=\pA*\pBsA}
      \real{pAnB=\pA*\pnBsA}
      \real{pnAB=\pnA*\pBsnA}
      \real{pnAnB=\pnA*\pnBsnA}
      \real{pB=\pAB+\pnAB}
      \real{pnB=1-\pB}
      \integer{round{ipAsB=\pAB/\pB*100}}
      \real{pAsB=\ipAsB/100}
      \real{pnAsB=1-pAsB}
      \integer{round{ipAsnB=\pAnB/\pnB*100}}
      \real{pAsnB=\ipAsnB/100}
      \real{pnAsnB=1-pAsnB}
      
      \text{tnA=wims(mathmlmath \overline{\A})}
      \text{tnB=wims(mathmlmath \overline{\B})}
      \text{tA=wims(mathmlmath \A)}
      \text{tB=wims(mathmlmath \B)}
      \text{tAeB=wims(mathmlmath \A \cap \B)}
      \text{tAenB=wims(mathmlmath \A \cap \overline{\B})}
      \text{tnAeB=wims(mathmlmath \overline{\A} \cap \B)}
       \text{tnAenB=wims(mathmlmath \overline{\A} \cap \overline{\B})}
      
      \text{dessinarbre=
       xrange 0,10
       yrange -10,10
       text black,0,-0.5,large,*
      
       arrow 0.3,0,2,4.5,10,black
       strokecolor red
       mathml 2.2,5,0,0,\tA
       text black,0.5,2.6,normal,\pA
      
       arrow 2.5,4.5,4.5,7,10,black
       strokecolor red
       mathml,4.7,7.4,0,0,\tB
       text black,3.2,6.5,normal,\pBsA
       arrow 2.5,4.5,4.5,2,10,black
       strokecolor red
       mathml 4.7,2.4,0,0,\tnB
      
       arrow 0.3,0,2,-4.5,10,black
       strokecolor red
       mathml,2.2,-4,0,0,\tnA
      
       arrow 2.5,-4.5,4.5,-7,10,black
       strokecolor red
       mathml,4.7,-6.8,0,0,\tnB
      
       arrow 2.5,-4.5,4.5,-2,10,black
       strokecolor red
       mathml,4.7,-1.5,0,0,\tB
       text black,3.2,-2.5,normal,\pBsnA
       }
      
      \text{dessinarbre2=
       xrange 0,10
       yrange -10,10
       text black,0,-0.5,large,*
      
       arrow 0.3,0,2,4.5,10,black
       strokecolor red
       mathml 2.2,5,0,0,\tA
       text black,0.5,2.6,normal,\pA
      
       arrow 2.5,4.5,4.5,7,10,black
       strokecolor red
       mathml,4.7,7.4,0,0,\tB
       strokecolor red
       mathml,5.7,7.4,0,0,\tAeB
       text black ,5.7,8,normal,issues
      text black ,7.7,8,normal,probabilités
       text black,3.2,6.5,normal,\pBsA
       arrow 2.5,4.5,4.5,2,10,black
       strokecolor red
       mathml 4.7,2.4,0,0,\tnB
       strokecolor red
       mathml 5.7,2.4,0,0,\tAenB
       text black,3.2,1.9,normal,\pnBsA
      
       arrow 0.3,0,2,-4.5,10,black
       strokecolor red
       mathml,2.2,-4,0,0,\tnA
       text black,0.5,-3.3,normal,\pnA
      
       arrow 2.5,-4.5,4.5,-7,10,black
       strokecolor red
       mathml,4.7,-6.8,0,0,\tnB
       strokecolor red
       mathml,5.7,-6.8,0,0,\tnAenB
       text black,3.2,-7.1,normal,\pnBsnA
       arrow 2.5,-4.5,4.5,-2,10,black
       strokecolor red
       mathml,4.7,-1.5,0,0,\tB
       strokecolor red
       mathml,5.7,-1.5,0,0,\tnAeB
       text black,3.2,-2.5,normal,\pBsnA
       }
      
      \text{dessinarbresol=
       xrange 0,10
       yrange -10,10
       text black,0,-0.5,large,*
      
       arrow 0.3,0,2,4.5,10,black
       strokecolor red
       mathml 2.2,5,0,0,\tA
       text black,0.5,2.6,normal,\pA
      
       arrow 2.5,4.5,4.5,7,10,black
       strokecolor red
       mathml,4.7,7.4,0,0,\tB
       strokecolor red
       mathml,5.7,7.4,0,0,\tAeB
       text black ,5.7,8,normal,issues
      text black ,7.7,8,normal,probabilités
       text black,3.2,6.5,normal,\pBsA
       arrow 2.5,4.5,4.5,2,10,black
       strokecolor red
       mathml 4.7,2.4,0,0,\tnB
       strokecolor red
       mathml 5.7,2.4,0,0,\tAenB
       text black,3.2,1.9,normal,\pnBsA
      
       arrow 0.3,0,2,-4.5,10,black
       strokecolor red
       mathml,2.2,-4,0,0,\tnA
       text black,0.5,-3.3,normal,\pnA
      
       arrow 2.5,-4.5,4.5,-7,10,black
       strokecolor red
       mathml,4.7,-6.8,0,0,\tnB
       strokecolor red
       mathml,5.7,-6.8,0,0,\tnAenB
       text black,3.2,-7.1,normal,\pnBsnA
       arrow 2.5,-4.5,4.5,-2,10,black
       strokecolor red
       mathml,4.7,-1.5,0,0,\tB
       strokecolor red
       mathml,5.7,-1.5,0,0,\tnAeB
       text black,3.2,-2.5,normal,\pBsnA
      
       strokecolor green
       mathml,7.7, 7.4,0,0,\pAB
       mathml,7.7, -1.5,0,0,\pnAB
       }
      
      \steps{r1, r2, r3
      r4, r5
      }
      
      \statement{
      
      <p>On considère une expérience aléatoire, \(\A) et \(\B) sont deux événements.</p>
      <p> <b>Etape 1:</b> compléter l'arbre.</p>
      \if{\step=1}{
      <div>
      
      \special{drawinput [\dessinarbre], 450 x 300, 1
       r1,0.5 x -1
       r2,2.75 x 3.5
       r3,2.75 x -5.4
       }
      
      </div>
      <div>
      </div>
      }
      \if{\step=2 and \sc_reply1 = 1 and \sc_reply2 = 1 and \sc_reply3 = 1}{
      <div class="oui">
       Trois bonnes réponses, très bien ! <hr />
      </div>
      }
      
      \if{\step=2 and \sc_reply1 = 0 or \sc_reply2 = 0 or \sc_reply3 = 0}{
      <div class="non">
      Attention, vous vous êtes trompé, voici la règle qui s'applique pour compléter un arbre:
      <div class="propriete">
      <p> <i><b>Règle 1:</b> Pour chaque noeud de l'arbre,
       la somme des probabilités doit être égale à 1.</i><p>
      <center>\(p\left(\A\right)+\p\left(\overline{\A}\right)=1)
       donc \(\p\left(\overline{\A}\right)=1-p\left(\A\right)=1-\pA=\pnA)</center>
      </div>
      <hr />
      Faites la suite de l'exercice avec les bonnes valeurs.
      </div>
      }
      
      \if{\step=2}{
      <p> <b>Etape 2:</b> Calcul de la probabilité des intersections</p>
      <div>
      \special{drawinput [\dessinarbre2], 450 x 300, 3
       r4,7.7 x 7.4
       r5,7.7 x -1.5
       }
      </div>
      <div>
      </div>
      }
      }
      \feedback{\sc_reply4 = 0 or \sc_reply5 = 0}{
      <div class="non">
      Attention, vous vous êtes trompé, voici la règle
       qui s'applique pour calculer la probabilité d'une intersection d'événements:
      <div class="propriete">
      <p> <i><b>Règle 2:</b> La probabilité de l’événement correspondant à un chemin de l’arbre est
      obtenue en multipliant les probabilités portées par ses branches..</i><p>
      <center>\(p(\A \cap \B)=p(\A)\times p_\A(\B)=\pA\times \pBsA =\pAB )</center>
      </div>
      </div>
      <b> solution </b>
      \canvasdraw{450,300}{\dessinarbresol}
      }
      \feedback{\sc_reply4 = 1 and \sc_reply5 = 1}{
      <div class="oui">
      Très bien, vos calculs sont juste.
      </div>
      <b> solution </b>
      \canvasdraw{450,300}{\dessinarbresol}
      }
      \hint{
      <div class="propriete">
      <p> <i><b>Règle 1:</b> Pour chaque noeud de l'arbre,
       la somme des probabilités doit être égale à 1.</i><p>
      <center>\(p\left(A\right)+\p\left(\overline{A}\right)=1)</center>
      <p> <i><b>Règle 2:</b> La probabilité de l’événement correspondant à un chemin de l’arbre est
      obtenue en multipliant les probabilités portées par ses branches..</i><p>
      <center>\(p(A \cap B)=p(A)\times p_A(B))</center>
      </div>
      }
      \answer{pnA}{\pnA}{type=default}{option=nonstop}
      \answer{pnBsA}{\pnBsA}{type=default}{option=nonstop}
      \answer{pnBsnA}{\pnBsnA}{type=default}{option=nonstop}
      \answer{pAB}{\pAB}{type=default}
      \answer{pnAB}{\pnAB}{type=default}
    • #5878
      jm.evers
      Participant
      Up
      0
      Down
      ::

      Hi,
      I don’t know what the problem is, but pay attention:the command mathml is changed…It is now simply mathml x,y,mathmlcode
      And there is a probably simpler way of presenting TeX formatted typesetting using
      the new command latex x,y,TeXcode
      (please check if you are using a current version of canvasdraw)
      Bernadette Perrin has created a great/large help page within createxo.
      The rest of the exercise escapes my knowledge of the french language.
      Please post a simpler example of your issue with canvasdraw -preferably in direct exec !
      joke

      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers. Raison: typos
    • #5881
      Christophe Barnier
      Participant
      Up
      0
      Down
      ::

      Thanks for your reply, i will modify my code.
      I’ve tried to post my code as code but it was not accepted.
      what do you mean by « preferably in direct exec ! »

    • #5882
      Christophe Barnier
      Participant
      Up
      0
      Down
      ::

      Bonjour,
      J’ai réduit le code pour cerner les bugs. j’ai deux bug:

      • le \overline{A} ne passe pas dans la fonction latex x,y,Texcod
        il n’y a pas de barre sur le A à l’affichage.
      • Le dessin ne passe plus dans le drawinput

      Merci de votre aide. Christophe

      \title{Arbre de probabilité à compléter}
      \language{fr}
      \range{-5..5}
      \author{Barnier Christophe}
      \email{barnierchr@gmail.com}
      \computeanswer{no}
      \format{html}
      \precision{10000}
      
      \real{pA=randint(1..99)/100}
      \real{pnA=1-\pA}
      \real{pBsA=randint(1..99)/100} p de B sachant A
      \real{pnBsA=1-\pBsA}
      \real{pBsnA=randint(1..99)/100}
      \real{pnBsnA=1-\pBsnA}
      \real{pAB=\pA*\pBsA}
      \real{pAnB=\pA*\pnBsA}
      \real{pnAB=\pnA*\pBsnA}
      \real{pnAnB=\pnA*\pnBsnA}
      \real{pB=\pAB+\pnAB}
      \real{pnB=1-\pB}
      \integer{ipAsB=round{\pAB/\pB*100}}
      \real{pAsB=\ipAsB/100}
      \real{pnAsB=1-pAsB}
      \integer{ipAsnB=round{\pAnB/\pnB*100}}
      \real{pAsnB=\ipAsnB/100}
      \real{pnAsnB=1-pAsnB}
      
      \text{dessinarbre=
       xrange 0,10
       yrange -10,10
       text black,0,-0.5,large,*
       arrow 0.3,0,2,4.5,10,black
       strokecolor red
       latex 2.2,5,A
       text black,0.5,2.6,normal,\pA
       arrow 2.5,4.5,4.5,7,10,black
       strokecolor red
       latex,4.7,7.4,B
       text black,3.2,6.5,normal,\pBsA
       arrow 2.5,4.5,4.5,2,10,black
       strokecolor red
       latex 4.7,2.4,\overline{B}
       arrow 0.3,0,2,-4.5,10,black
       strokecolor red
       latex,2.2,-4,\overline{A}
       arrow 2.5,-4.5,4.5,-7,10,black
       strokecolor red
       latex,4.7,-6.8,\overline{B}
       arrow 2.5,-4.5,4.5,-2,10,black
       strokecolor red
       latex,4.7,-1.5,B
       text black,3.2,-2.5,normal,\pBsnA
       }
      
      \statement{
      
      <p>On considère une expérience aléatoire, \(\A) et \(\B) sont deux événements.</p>
      <p> <b>Etape 1:</b> compléter l'arbre.</p>
      
      \canvasdraw{450,300}{\dessinarbre}
      
      \special{drawinput [\dessinarbre], 450 x 300, 1
       reply1,0.5 x -1
       reply2,2.75 x 3.5
       reply3,2.75 x -5.4
       }
      
      }
      
      \answer{pnA}{\pnA}{type=default}
      \answer{pnBsA}{\pnBsA}{type=default}
      \answer{pnBsnA}{\pnBsnA}{type=default}
    • #5883
      jm.evers
      Participant
      Up
      0
      Down
      ::

      The overline seems to work just fine…
      search for ‘direct’ or ‘direct exec’ in wims
      copy & paste this in the textarea
      execute by ‘canvasdraw’

      size 400,400
      xrange -10,10
      yrange -10,10
      fontfamily 148px Arial
      strokecolor green
      drag xy
      centered
      latex 0,0,\overline{B}
      

      joke

      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
    • #5885
      Christophe Barnier
      Participant
      Up
      -1
      Down
      ::

      I have tried your simple canvas, there is no overline on the B on the layout, i’m sorry….
      and the drawinput is bugging..
      Christophe

    • #5886
      jm.evers
      Participant
      Up
      1
      Down
      ::

      \real{pnAsnB=1-pAsnB}
      should be \real{pnAsnB=1-\pAsnB}
      I guess…

    • #5887
      jm.evers
      Participant
      Up
      1
      Down
      ::

      on https://wims.auto.u-psud.fr/
      overline on pariSud server...

      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
    • #5889
      jm.evers
      Participant
      Up
      0
      Down
      ::

      I’m not familiar with the ‘special; oef methods…but there are no input fields
      in your oef script…however in the ‘correct’ answer they are displayed
      dont know ask B. Perrin

      So you have to ask Bernadette Perrin…
      Inputfields are working fine in canvasdraw

      size 400,400
      xrange -10,10
      yrange -10,10
      linewidth 6
      point 1,2,red
      input 1,2,5,1, ?
      point -5,5,red
      input -5,5,5,1, ?
      point 6,-5,red
      input 6,-5,5,1, ?
      point -5,-8,red
      input -5,-8,5,1, ?
      
      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
      • #5892
        Christophe Barnier
        Participant
        Up
        0
        Down
        ::

        Hello,
        Thanks for your reply. Where do you find this tool to execute sample of code?

    • #5893
      Christophe Barnier
      Participant
      Up
      0
      Down
      ::

      J’ai corrigé les erreurs d’affectation mais c’étaient des erreurs marginales…
      Il reste toujours les deux bugs, pas d’affichage de l’\overline{}, et problème avec le drawinput, à l’aide Bernadette…

      \title{Arbre de probabilité à compléter}
      \language{fr}
      \range{-5..5}
      \author{Barnier Christophe}
      \email{barnierchr@gmail.com}
      \computeanswer{no}
      \format{html}
      \precision{10000}
      
      \real{pA=randint(1..99)/100}
      \real{pnA=1-\pA}
      \real{pBsA=randint(1..99)/100} p de B sachant A
      \real{pnBsA=1-\pBsA}
      \real{pBsnA=randint(1..99)/100}
      \real{pnBsnA=1-\pBsnA}
      \real{pAB=\pA*\pBsA}
      \real{pAnB=\pA*\pnBsA}
      \real{pnAB=\pnA*\pBsnA}
      \real{pnAnB=\pnA*\pnBsnA}
      \real{pB=\pAB+\pnAB}
      \real{pnB=1-\pB}
      \integer{ipAsB=round{\pAB/\pB*100}}
      \real{pAsB=\ipAsB/100}
      \real{pnAsB=1-\pAsB}
      \integer{ipAsnB=round{\pAnB/\pnB*100}}
      \real{pAsnB=\ipAsnB/100}
      \real{pnAsnB=1-\pAsnB}
      
      \text{dessinarbre=
       xrange 0,10
       yrange -10,10
       text black,0,-0.5,large,*
       arrow 0.3,0,2,4.5,10,black
       strokecolor red
       latex 2.2,5,A
       text black,0.5,2.6,normal,\pA
       arrow 2.5,4.5,4.5,7,10,black
       strokecolor red
       latex,4.7,7.4,B
       text black,3.2,6.5,normal,\pBsA
       arrow 2.5,4.5,4.5,2,10,black
       strokecolor red
       drag xy
      centered
       latex 4.7,2.4,\overline{B}
       arrow 0.3,0,2,-4.5,10,black
       strokecolor red
       latex,2.2,-4,\overline{A}
       arrow 2.5,-4.5,4.5,-7,10,black
       strokecolor red
       latex,4.7,-6.8,\overline{B}
       arrow 2.5,-4.5,4.5,-2,10,black
       strokecolor red
       latex,4.7,-1.5,B
       text black,3.2,-2.5,normal,\pBsnA
       }
      
      \statement{
      
      <p>On considère une expérience aléatoire, \(\A) et \(\B) sont deux événements.</p>
      <p> <b>Etape 1:</b> compléter l'arbre.</p>
      
      \canvasdraw{450,300}{\dessinarbre}
      
      \special{drawinput [\dessinarbre], 450 x 300, 1
       reply1,0.5 x -1
       reply2,2.75 x 3.5
       reply3,2.75 x -5.4
       }
      
      }
      
      \answer{pnA}{\pnA}{type=default}
      \answer{pnBsA}{\pnBsA}{type=default}
      \answer{pnBsnA}{\pnBsnA}{type=default}
    • #5894
      jm.evers
      Participant
      Up
      0
      Down
      ::

      In canvasdraw the command input (from docs)

      @ input x,y,size,editable,value
      @ to set inputfield "readonly", use editable = 0
      @ if no preset 'value' is needed...use a 'space' as last item argument

      The last argument ‘value’ can not be an empty string…
      So if you have source code access to your wims server, you can quick fix this by editing scripts/oef/special/drawinput.phtml
      and add:

      blah blah
      !if $(reply$n_) = $empty
      !set reply$n_=?       
      !endif         
       !set codeinput=!append line input $[$x_],$[$y_],$(inputsize_tmp[2]),1,$(reply$n_) $ $ to $code
      !endif
      
      The \overline is probably eaten by some oef-script
      You could try a direct call to canvasdraw...
      

      \text{test=wims(exec canvasdraw
      size 200,200
      xrange 0,4
      yrange 0,4
      linewidth 5
      input 1,1,1,1,?
      latex 2,2,\Huge{\overline{B}})}
      \statement{
      \test
      }

      
      
      I will see if this can be changed within canvasdraw (e.g. accepting an empty string...)
      
      kind regards
      Joke
      
      
      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
      • Cette réponse a été modifiée le il y a 2 années et 11 mois par jm.evers.
      • #5898
        jm.evers
        Participant
        Up
        0
        Down
        ::

        forget the last example oef code…it was not correctly displayed in BBCode

        
        \text{test=wims(exec canvasdraw 
        size 200,200
        xrange 0,4
        yrange 0,4
        linewidth 5
        input 1,1,1,1,?
        latex 2,2,\Huge{\overline{B}})}
        \statement{  
        \test
        }
    • #5899
      jm.evers
      Participant
      Up
      0
      Down
      ::

      The ’empty string’ flaw in canvasdraw is corrected and uploaded to SVN
      Thank you for noticing!

      joke

Vous lisez 11 fils de discussion
  • Vous devez être connecté pour répondre à ce sujet.