Accueil › Forums › Programmation WIMS › Programmation dans le langage wims › jsxgraph et exercices à étapes : rafraîchissement de la figure
Étiqueté : jsxgraph étapes
- Ce sujet contient 3 réponses, 2 participants et a été mis à jour pour la dernière fois par
Richard Taillet, le il y a 9 années et 8 mois.
-
AuteurMessages
-
-
2 septembre 2015 à 09:36 #3068
Richard Taillet
Participant::Bonjour,
Je progresse dans ma tentative de faire un exercice à étapes avec jsxgraph, et je bute sur un dernier (!) problème. Je joins le code très simplifié, qui consiste en deux étapes, il faut tracer un trait, puis si on l’a fait correctement, répondre à une question simple. Mon problème principal est le suivant : lorsque la première question est posée pour la seconde fois (si la réponse était fausse le coup d’avant), jsxgraph retrace le trait proposé auparavant par l’utilisateur. On a l’impression de ne plus pouvoir tracer de trait. En fait c’est plus subtil, si on fait deux clics en aveugle pour définir un trait, il est bien pris en compte (mais c’est inutilisable en pratique car on ne voit pas ce qu’on trace).
Du coup, y a-t-il un moyen de réinitialiser la figure lorsque la question est reposée ?
Merci ! 🙂
\css{<style type="text/css"> .jxgbox {margin-left:auto;margin-right:auto;} .jsxgraph_button {text-align:center;} </style>} \computeanswer{no} \format{html} \precision{1000} \range{-5..5} \integer{angleincident=30} \integer{rayon=300} \integer{xpix=2*\rayon*1.2} \integer{ypix=2*\rayon*1.2} \real{xmin=-1.2} \real{xmax=1.2} \real{ysize=1} \real{ymin=-0.2} \real{ymax=1.2} %%% dessin du rapporteur \text{rapporteur=linewidth 1 frect 0,0,\xpix,\ypix/2,lightgray } \for{i=90 to 180 step 10}{ \real{ang=floor((\i*3.14/180)*1000)/1000} \text{rapporteur=\rapporteur line \xpix/2+\rayon*cos(\ang), \ypix/2-\rayon*sin(\ang), \xpix/2+\rayon*1.1*cos(\ang),\ypix/2-\rayon*1.1*sin(\ang), black } } \for{i=90 to 180 step 30}{ \text{rapporteur=\rapporteur text black, \xpix/2+\rayon*1.1*cos(\i*3.14/180),\ypix/2-\rayon*1.1*sin(\i*3.14/180),large, \i } } \text{rapporteur=\rapporteur line \xpix/2-0.1*\rayon, \ypix/2, \xpix/2+0.1*\rayon, \ypix/2, black line \xpix/2, \ypix/2-0.1*\rayon, \xpix/2, \ypix/2+0.1*\rayon, black } \text{dessin= draw( \xpix,\ypix \rapporteur ) } %%% fin du dessin \text{choix=oui,non} \text{reponse=2} \text{ETAPE = r1} \nextstep{\ETAPE} \integer{ok1=0} \statement{ \if{\ok1 == 0}{ <p>1. <b>Tracer un trait passant par le centre et la graduation 120. (\angle)</b></p> \embed{r1,\xpix x \ypix \dessin sline} } \if{\ok1 == 1}{ <p>1. Le trait a été tracé correctement.</p> <p>2. <b>cliquez sur NON.</b></p> \embed{r2,1}\embed{r2,2} } } \answer{}{\jstest}{type=jsxgraphcurve} {option=color1=blue color2=blue precision=8} \answer{}{\reponse;\choix}{type=click} {option=noanalyzeprint} \real{longueur = sqrt((\jstest[4]-\jstest[2])*(\jstest[4]-\jstest[2])+(\jstest[3]-\jstest[1])*(\jstest[3]-\jstest[1]))} \real{cosinus = (\jstest[3]-\jstest[1])/\longueur} \if {\cosinus==0}{ \real{angle=90} } { \real{angle=atan((\jstest[4]-\jstest[2])/(\jstest[3]-\jstest[1]))/3.14159*180} } \if {\angle<0}{\real{angle=180+(\angle)}} \real{ecart1=abs(\angle+\anglereincident-90)} \condition{Votre tracé s'écarte de la valeur attendue de \ecart1 deg}{\ecart1<1} \if{\ok1==1}{\text{ETAPE =}} \if{\ok1 == 0} { \if{\ecart1<1} { \text{ETAPE = r2} \integer{ok1=1} } {\text{ETAPE = r1}} }
-
16 septembre 2015 à 10:11 #3085
Julien
Modérateur::Bonjour,
Merci de poster un code qui fonctionne afin qu’on puisse se concentrer sur le problème…
\title{richard} \css{<style type="text/css"> .jxgbox {margin-left:auto;margin-right:auto;} .jsxgraph_button {text-align:center;} </style>} \computeanswer{no} \format{html} \precision{1000} \range{-5..5} \integer{angleincident=30} \integer{rayon=300} \integer{xpix=2*\rayon*1.2} \integer{ypix=2*\rayon*1.2} \real{xmin=-1.2} \real{xmax=1.2} \real{ysize=1} \real{ymin=-0.2} \real{ymax=1.2} %%% dessin du rapporteur \text{rapporteur=linewidth 1 frect 0,0,\xpix,\ypix/2,lightgray } \for{i=90 to 180 step 10}{ \real{ang=floor((\i*3.14/180)*1000)/1000} \text{rapporteur=\rapporteur line \xpix/2+\rayon*cos(\ang), \ypix/2-\rayon*sin(\ang), \xpix/2+\rayon*1.1*cos(\ang),\ypix/2-\rayon*1.1*sin(\ang), black} } \for{i=90 to 180 step 30}{ \text{rapporteur=\rapporteur text black, \xpix/2+\rayon*1.1*cos(\i*3.14/180),\ypix/2-\rayon*1.1*sin(\i*3.14/180),large, \i} } \text{rapporteur=\rapporteur line \xpix/2-0.1*\rayon, \ypix/2, \xpix/2+0.1*\rayon, \ypix/2, black line \xpix/2, \ypix/2-0.1*\rayon, \xpix/2, \ypix/2+0.1*\rayon, black } \text{dessin= draw( \xpix,\ypix \rapporteur ) } %%% fin du dessin \text{choix=oui,non} \text{reponse=2} \matrix{nstep = r1} \nextstep{\nstep} \integer{ok=0} \real{ecart1=} \real{angle=} \real{longueur=} \real{coss=} \statement{ \if{\ok=0}{ <p>1. <b>Tracer un trait passant par le centre et la graduation 120. (\angle)</b></p> \embed{r1,\xpix x \ypix \dessin sline} } \if{\ok=1}{ <p>1. Le trait a été tracé correctement.</p> <p>2. <b>cliquez sur NON.</b></p> \embed{r2,1}\embed{r2,2} } reply1=\reply1 <br /> angle=\angle <br /> ecart1=\ecart1 <br /> ok=\ok <br /> angleincidence=\angleincidence <br /> longueur =\longueur <br />rep=\rep<br />coss=\coss } \answer{}{\jstest}{type=jsxgraphcurve} {option=color1=blue color2=blue precision=8} \answer{}{\reponse;\choix}{type=click} {option=noanalyzeprint} \matrix{rep=\reply1} \real{longueur=sqrt((\rep[4]-\rep[2])*(\rep[4]-\rep[2])+(\rep[3]-\rep[1])*(\rep[3]-\rep[1]))} \real{coss=(\rep[3]-\rep[1])/\longueur} \if{\coss=0}{\real{angle=90}}{\real{angle=atan((\rep[4]-\rep[2])/(\rep[3]-\rep[1]))/3.14159*180}} \if{\angle<0}{\real{angle=180+(\angle)}} \real{ecart1=abs(\angle+\angleincident-90)} \condition{Votre tracé s'écarte de la valeur attendue de \ecart1 deg}{\ecart1<1} \if{\ok=1}{\text{nstep =}} \if{\ok=0}{ \if{\ecart1<1} { \text{nstep = r2} \integer{ok=1} } {\text{nstep = r1}} }
A priori ton exo fonctionne sur une version plus ancienne de Wims « WIMS-4.07c compilé le 2014-06-25. »
Bernadette, des modif ont eu lieu dans le module oef qui pourrait impacter ou pas ??
-
Cette réponse a été modifiée le il y a 9 années et 8 mois par
Julien.
-
Cette réponse a été modifiée le il y a 9 années et 8 mois par
-
16 septembre 2015 à 10:58 #3087
Richard Taillet
Participant::Bonjour,
Merci pour votre réponse, mais je ne comprends pas votre requête « Merci de poster un code qui fonctionne »… Si je copie le code que j’ai fourni plus haut, le colle en mode « brut » sur le serveur de l’université de Savoie, et teste l’exercice, ça marche chez moi, dans le sens où ça lance l’exo, me permet de répondre à la question, puis confronte l’utilisateur au problème contre lequel je lutte et pour lequel j’ai sollicité une aide.
Du coup, que pourrais-je partager d’autre qui soit plus clair ?
Bonne journée,
Richard.
-
16 septembre 2015 à 11:04 #3088
Richard Taillet
Participant
-
-
AuteurMessages
- Vous devez être connecté pour répondre à ce sujet.