Peut-on vérifier une réponse OEF avec maxima ?

Accueil Forums Programmation WIMS Programmation d’exercices OEF Peut-on vérifier une réponse OEF avec maxima ?

Vous lisez 12 fils de discussion
  • Auteur
    Messages
    • #2184
      boud
      Participant
      Up
      0
      Down
      ::

      Est-il possible dans un exercice createxo (en format oef) de vérifier
      la réponse avec maxima?

      Mon idée est de présenter un calcul symbolique
      suffisamment compliqué (en nombre de paramètres aléatoires et dans sa
      structure algébrique) afin que l’étudiant-e doive comprendre la
      méthode mathématique/physique plutôt qu’apprendre une réponse par
      coeur. Mais dans ce cas, le nombre de formes de réponse correcte est
      grand. Si la complexité, dans le sens du nombre de façons à présenter
      la réponse, est N, j’ai peur que le nombre de familles de façon
      d’exprimer la même réponse (au sens mathématique) soit d’ordre de N!.
      Ce qui est évidemment impossible à mettre dans un fichier OEF si
      N >= 5 (et déjà lourd à faire si N=4).

      S’il n’est pas possible de vérifier la réponse avec maxima, par ex.,

      \answer{1. La reponse}{\theanswer}{type=maxima}

      on serait obligé (dans le cadre de format createxo/OEF), il me semble,
      de rester avec les quesions plutôt simples, et/ou de donner des très longues
      listes de réponses possibles.

      Voilà deux exemples (simplifiés – les vraies questions arrivent à ces
      expressions après quelques manipulations algébriques/différentielles).
      Dans question 1, je préférerais que les nombres avec un point décimal
      (système anglophone) soient acceptés. Dans question 2, je suppose que
      certain-e-s étudiant-e-s vont oublier que 1/tan(x) peux s’écrire
      cot(x). Dans les deux cas, passer la réponse de l’étudiant-e à maxima
      avec un test comme

      maxima(\responseetudiant - \mareponse) = 0

      pourrait, il me semble, permettre de décider avec plus de fiabilité
      si la réponse est bonne ou non.

      CODE OEF :

      \title{example}
      \computeanswer{no}
      \format{html}
      \precision{1000}
      
      ## Choisir une question
      \integer{i=random(1,2)}
      # question 1
      \if{\i=1}{
      \text{question= 7/(10*t)}
      }
      # question 2
      \if{\i=2}{
      \text{question= 2*cos(t/7)/(7*sin(t/7))}
      }
      ## Preparer la reponse exprimee dans plusieurs formes les plus evidentes
      \text{theanswer= maxima( \question, expand;)}
      \text{theanswerfactor=maxima(\theanswer,factor;)}
      \text{theanswertrigreduce=maxima(trigreduce(\theanswer);)}
      \text{theanswerfactortrigreduce=maxima(trigreduce(\theanswerfactor);)}
      \statement{Repondre a la question blabla.}
      \answer{1. La reponse ?}{\theanswer,\theanswerfactor,\theanswertrigreduce,\theanswerfactortrigreduce}{type=algexp}
      

      QUELQUES REPONSES REJETEES
      question 1

      0.7/t
      is not written as required. Please rewrite it in the correct form.

      question 2

      2/7 /tan(t/7)
      bad answer, the correct answer is 2*cos(t/7)/(7*sin(t/7)).

      QUELQUES REPONSES ACCEPTEES (autres que la réponse annoncée à l’utilisateur) :

      question 1
      7/10/t

      question 2

      2*cot(t/7)/7  
       2/7*cot(t/7)

      SYSTÈME : debian/squeeze wims-4.00-4 + patch pour bug #8408

      • Ce sujet a été modifié il y a 9 années et 11 mois par boud. Raison : tous les bbcodes ne sont pas acceptes
      • Ce sujet a été modifié le il y a 9 années et 11 mois par boud.
      • Ce sujet a été modifié le il y a 9 années et 11 mois par boud.
      • Ce sujet a été modifié il y a 9 années et 11 mois par boud. Raison : ortaugraf inaccetpable
      • Ce sujet a été modifié il y a 9 années et 11 mois par boud. Raison : format
    • #2190
      jm.evers
      Participant
      Up
      0
      Down
      ::

      Hi,
      For the rational number use ‘float’:
      if float(7/(10*t)) = float(0.7/t) then Y else N;
      Y
      float(7/(10*t));
      0.7/t

      For the other example, things are more complex; I sometimes use
      trigrat(2/7 /tan(t/7));
      2*cos(t/7)/(7*sin(t/7))
      But it’s maybe not installed in all maxima versions? just try it
      kind regards,
      joke

    • #2192
      boud
      Participant
      Up
      0
      Down
      ::

      Thank you for the suggestions. One of them helps for one of these two
      specific examples, and I found a maxima hack for the second, though
      the main problem – can we run maxima on the answers? – remains. My
      patch compared to my post above is:

      @@ -18,5 +18,8 @@
       \text{theanswerfactor=maxima(\theanswer,factor;)}
       \text{theanswertrigreduce=maxima(trigreduce(\theanswer);)}
       \text{theanswerfactortrigreduce=maxima(trigreduce(\theanswerfactor);)}
      +\text{theanswerfactorfloat=maxima(float(\theanswerfactor);)}
      +\text{theanswerletsimp = maxima((matchdeclare(a,true), letrat: true, let(cos(a)/sin(a),1/tan(a)), letsimp(\theanswer));)}
       \statement{Repondre a la question blabla.}
      -\answer{1. La reponse ?}{\theanswer,\theanswerfactor,\theanswertrigreduce,\theanswerfactortrigreduce}{type=algexp}
      +\answer{1. La reponse ?}{\theanswer,\theanswerfactor,\theanswertrigreduce,\theanswerfactortrigreduce,\theanswerfactorfloat,\theanswerletsimp}{type=algexp}

      So 0.7/t is now accepted as a correct answer for question 1, using the
      5th correct answer in the list of correct answers. The tan simplification
      (ignoring cot) is obtained by telling maxima how to simplify to tan and
      saying nothing about cot, so the 6th correct answer now works for question 2.

      But these are just specific hacks for rather simple expressions. The
      problem for more complicated problems remains: algebraic and
      trigonometric simplification are not the main skill being tested. The main
      question is whether the student can express physical problems mathematically
      and simplify them to a reasonable degree, without pedantry. With these quite
      simple examples there’s already a list of 6 different valid answers. Preparing
      a list of e.g. 120 valid answers would be impractical.

      Can we apply maxima to the answer provided by the student (instead of
      having to generate a list of valid answers)?

      (PS: trigrat is available in maxima-5.21.1, though it doesn’t help.
      Here is my maxima version:

      dpkg -l |egrep " maxima( |-share)"
      ii  maxima                                   5.21.1-2squeeze                          A computer algebra system -- base system
      ii  maxima-share                             5.21.1-2squeeze                          A computer algebra system -- extra code

      )

      • Cette réponse a été modifiée le il y a 9 années et 11 mois par boud. Raison: trigrat and maxima version
    • #2194
      boud
      Participant
      Up
      0
      Down
      ::

      To illustrate this point further, I modified question 1 to:

      \text{question= maxima(diff((sin(t/8))^2,t)/(sin(t/8))^2;)}

      The following two answers (which in reality are correct) are
      interpreted as wrongly written, or wrong, respectively:

      0.25 *cos(t/8)/sin(t/8)
      is not written as required. Please rewrite it in the correct form.

      0.25*cot(0.125*t) bad answer, the correct answer is cos(t/8)/(4*sin(t/8)).

      Introducing more correct answers by applying
      maxima(float(…);) to each of the existing correct answers and
      adding these new ones to the list can, again, allow these two specific
      examples to be accepted as correct. But then 0.25*cot(t/8) requires
      float to be applied before trigreduce. I don’t see how a more complex
      question can have a reasonably short list of correct answers rather
      than growing longer factorially.

    • #2195
      jm.evers
      Participant
      Up
      0
      Down
      ::

      I don’t use OEF , but in any case you should apply the same ‘maxima’ operations on both correct answer and student reply.
      So for OEF you should build you own local ‘anstype’. (written in wims-phtml)
      For example a single call to maxima :

      
      #############
      test=!exec maxima if trigrat(reply$i) = trigrat(answer$i) then yes else no;\
      if float(reply$i) = float(answer$i) then yes else no;\
      if some_operation_A(reply$i) = some_operation_A(answer$i) then yes else no;\
      ....;
      if some_operation_Z(reply$i) = some_operation_Z(answer$i) then yes else no;
      
      !if yes isin $test
      score=1
      !else
      score=0
      !endif
      ############
      

      But I guess Bernadette is the one you should consult about these specific OEF things.
      joke

    • #2196
      jm.evers
      Participant
      Up
      0
      Down
      ::

      To study some examples of OEF modules using a localized ‘anstype’ , see

      
      E1/number/oefnumber.fr/anstype
      E1/number/oefcalcul1.fr/anstype
      E1/number/oefcalcul2.fr/anstype
      E1/geometry/oefsquare.fr/anstype
      E1/geometry/oefsquare.fr/src/cpp/anstype
      E4/number/oefcalcul.fr/anstype
      E6/geometry/OEFprogConstr.fr/anstype
      E6/geometry/oefsymmetry.fr/anstype
      E6/geometry/oefsymmetry.nl/anstype
      E6/number/oefsymmetry.fr/anstype
      H1/geometry/OEFtriang5.fr/anstype
      H1/algebra/frac5.fr/anstype
      H2/geometry/oeffrieze.fr/anstype
      H2/geometry/oeffrieze.nl/anstype
      H2/number/oeflceb.fr/anstype
      H3/number/OEFevalwimsfrac.fr/anstype
      H3/algebra/oefqcm4.fr/anstype
      H3/algebra/oefqcm3.fr/anstype
      H3/arithmetic/oefarith.fr/anstype
      H4/stat/oefstatistiques.fr/anstype
      H4/algebra/oefresolalg.fr/anstype
      H4/analysis/OEFevalwimsgrph.fr/anstype
      H5/stat/OEFevalwimsstat.fr/anstype
      H5/geometry/OEFtransform.fr/anstype
      H6/geometry/OEFsimigeoTS.fr/anstype
      

      succes !
      joke

    • #2197
      boud
      Participant
      Up
      0
      Down
      ::

      Thanks for the hints – I have no objections to integrating some
      « native WIMS » with OEF – provided that I understand how to set up the
      files and paths, etc. I found that {type=algexp} in my oef script
      refers to files located at

      scripts/anstype/algexp
      scripts/anstype/algexp.input

      I copied these two files to a directory anstype/ in the
      directory for this class, and renamed them. I don’t seem to
      be able to get the OEF system to read them using {type=algexpmynewname}.

      However, I removed {type=…} totally, and now seem to have a hack
      that works: let WIMS/OEF decide itself what the type is (i.e. use a default
      type). Thus, now I have for the following OEF source file:

      \title{example 3 pour rapport de bug}
      \computeanswer{no}
      \format{html}
      \precision{1000}
      
      \text{question= maxima(diff((sin(t/8))^2,t)/(sin(t/8))^2;)}
      
      \text{theanswer= maxima( \question, expand;)}
      
      \statement{Repondre a la question svp.}
      
      \answer{1. La reponse ?}{\theanswer}

      examples of correct answers:

      cos(t/8)/(4*sin(t/8))  	  good answer.
       1/4 * cot(t/8)  	  good answer.
       1/4 /tan(t/8)  	  good answer.
       0.25/tan(t/8)  	  good answer.
       cot(0.125*t)/4  	  good answer.

      examples of wrong answers:

      1 /tan(t/8)  	  bad answer, the correct answer is cos(t/8)/(4*sin(t/8)).
      cos(t/8)  	  bad answer, the correct answer is cos(t/8)/(4*sin(t/8)).
       sin(t)  	  bad answer, the correct answer is cos(t/8)/(4*sin(t/8)).

      So far it seems that the default answer type for oef answers is just what I
      was looking for – no need for any extra calls to maxima. 🙂 (Maybe the wims
      scripts already do this by default?)

      Replacing the answer line by

      \answer{1. La reponse ?}{\theanswer}{type=default}

      gives identical results.

      • Cette réponse a été modifiée le il y a 9 années et 11 mois par boud. Raison: syntax
    • #2199
      jm.evers
      Participant
      Up
      0
      Down
      ::

      Ok:the anstype ‘default’ is some sort of ‘switch board’, it may call:
      1) if an ‘=’ is present in the correct answer : use anstype/equation
      2) if a numerical evaluation is not NaN : use anstype/numeric
      3) if there are math variables present : use anstype/function
      4) else assume text : use anstype/atext

      So you will end up using anstype/function…
      This answer type will substitute the variables with some random values and do a numerical comparison…read ~/public_html/scripts/anstype/function
      not a single call to maxima 🙂
      kind regards,
      Joke

      • Cette réponse a été modifiée le il y a 9 années et 11 mois par jm.evers.
      • Cette réponse a été modifiée le il y a 9 années et 11 mois par jm.evers.
    • #2202
      Julien
      Modérateur
      Up
      0
      Down
      ::

      Peux-tu préciser ton environnement pour que l’on comprenne pourquoi ton {type=algexpmynewname} n’a pas été pris en compte par Wims ? Serveur local ou compte modtool

      Un problème de droit de lecture de tes fichiers par le serveur Wims est envisageable…

      Voili voilou

      • Cette réponse a été modifiée le il y a 9 années et 11 mois par Julien.
      • Cette réponse a été modifiée le il y a 9 années et 11 mois par Julien.
    • #2205
      boud
      Participant
      Up
      0
      Down
      ::

      Julien – c’est sur un serveur local (debian/squeeze wims-4.00-4 + patch pour
      bug #8408), dans un répertoire pour « prof visiteur » [je trouve ça toujours
      le plus simple à gérer], c.a.d.
      log/classes/1234/
      qui contient

      ls -F
      anstype/  content.html	doc/	Exindex   exostat   livret/	 score/    sheets/  supervisor	vote/
      cdt/	  def/		exams/  Extitles  forum/     noscore/  scoreavg  src/     version

      Wims et apache ont le droit de lecture de anstype/, anstype/algexpmynewname et
      anstype/algexpmynewname.input (et d’execution de anstype/).

      Un problème de droits d’accès me semble envisageable, mais je ne vois
      pas où exactement. Faut-il le droit d’écrire des fichiers temporaires qq part ?
      Ou peut-être c’est une erreur de chemin ?

      Joke – thanks for helping me read the source – in that case I think
      I’ll use type=function explicitly. The evaluation method for functions
      does not constitute a serious mathematical proof that two expressions
      are equal, but for practical purposes in « ordinary » physics (no Dirac
      delta functions, Cantor functions, etc.) it may well be enough.

      In that case – this is just wondering aloud – what are the chances of
      either incorrectly marking a wrong answer to be correct or a right answer
      to be wrong?

      Continuing with my question 1 bis, I can get a « wrong » answer (one or more
      terms of Taylor expansion at t=0) to be marked nearly correct or fully
      correct if the precision is not too strict and if the range is close
      to zero:

      \precision{100000}
      \range{0.001..0.1}


      \answer{1. La reponse ?}{\theanswer}{type=function}

      2/t  	  bad precision, the correct answer is cos(t/8)/(4*sin(t/8)).
      You have got a score of 7.2 on 10. 
      2/t - t/96  	  good answer.

      I didn’t manage to create an example where the right answer is marked
      wrong, without any warning of an error in the script. In principle,
      requiring a precision of 1e-16 for double precision calculations
      should give different answers when calculating something in one step
      versus many steps with uncorrelated least significant bit errors.

      I had never thought of this sort of numerical checking to be anything
      more than a hack before, but the chance of it failing either way are
      probably low for « reasonable » practical cases, as long as the author(s)
      of the exercise do not forget the nature of the algorithm. Good :).

    • #2206
      jm.evers
      Participant
      Up
      0
      Down
      ::

      If there is a risk of incorrect marking in some OEF exercise (in case of NaN wims will return some error ‘bad’), you could change the « \range{min,max} » : the random values for substition in anstype function are chosen in this range…
      Furhermore the compare precision \precision{} could be adjusted to suit some specific demands. If the difference between the substituted values e.g abs(student_answer – correct_answer) is smaller than 1/sqrt(precision) the answer is considered to be correct
      joke

      • Cette réponse a été modifiée le il y a 9 années et 11 mois par jm.evers.
      • Cette réponse a été modifiée le il y a 9 années et 11 mois par jm.evers. Raison: typo typo typo
    • #2209
      Julien
      Modérateur
      Up
      0
      Down
      ::

      Si tu as fait une install avec apt-get install wims le chemin pour ajouter un type de question se trouve ici :
      cd /var/lib/wims/public_html/scripts/anstype/
      Dans ce cas ton type est intégré à la distribution.

      Si tu veux faire quelques choses qui fonctionne que pour ton module l’exemple suivant te donne le chemin à suivre.
      cd /var/lib/wims/public_html/modules/devel/judev/test\~stat\~oeftempsdereaction.fr/anstype

      Après je me suis jamais trop baladé dans les classes donc je ne sais pas si on peut ajouter direct dans une classe ???

      J’arrête de polluer ton poste vu que ton problème semble résolu.

      @+

    • #2223
      boud
      Participant
      Up
      0
      Down
      ::

      Julien – les fichiers placés directement dans le repertoire
      scripts/anstype/ sont bien lus. La non-lecture des fichiers dans
      log/classes/1234/ est peut-être pour des raisons de sécurité, ou
      peut-être c’est une particularité des droits d’accès ou de chemin
      dans mon installation de wims.

      Joke – I agree – the range and precision parameters should be able to
      reduce the chance of a wrong function being marked correct to a very
      small value – my guess is a probability of around 1e-15 or so. Since
      the error is in favour of the student, this should be a safe error margin. 🙂

      However, a warning: something in an anstype file of the form `!exec
      maxima some_operation_A(reply$i) = …` is likely to fail if the
      maxima operation literally contains underscores. I don’t know if this
      is a bug or a security feature. Further discussion would probably best
      go at
      https://wimsedu.info/?topic=caratere-underscore-dans-maxima
      and if the consensus is that it’s a bug, then probably it should be
      filed at https://sourcesup.renater.fr/scm/?group_id=379 (Maybe an
      exception to the « refuse underscores » rule could be made for maxima
      built-in functions, that are trusted to be safe? or a wims parameter
      that lists allowable maxima functions whose symbols include
      underscores could be definable in wims.conf?)

      Thanks to both of you for the fast responses.

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