简体   繁体   中英

JSXGraph Moodle plugin move after student answer

I have a Moodle question with a JSXGraph image, say

<jsxgraph width="600" height="500">
    var brd = JXG.JSXGraph.initBoard(BOARDID, {boundingbox:[-5,5,5,-5], axis:true});
    var p = brd.create('point', [0,1]);
</jsxgraph>

How can I set

p.moveTo([0,2]);

if the student answers wrong?

I would need to access the board. Somehow I need to get the board ID.

What question type do you use? Ich would recommend to use Formulas. Then you can use our JSXGraph Moodle formulas extension. It is included in the JSXGraph Moodle filter (no files have to be installed additionally). You can find a documentation here: https://github.com/jsxgraph/moodleformulas_jsxgraph/blob/master/README.md .

In your case you can type:

<jsxgraph width="600" height="500" ext_formulas>

   // JavaScript code to create the construction.
   var jsxCode = function (question) {

      var brd = JXG.JSXGraph.initBoard(BOARDID, {boundingbox:[-5,5,5,-5], axis:true});
      var p = brd.create('point', [0,1]);
       
      if (question.isSolved)
         p.moveTo([0,2]);
    };

    // Execute the JavaScript code.
    new JSXQuestion(BOARDID, jsxCode, /* if you want to see inputs: */ true);

</jsxgraph>

This code would move the point to [0,2] when the question is displayed after submission.

I hope, I could help you.

Thank you. I have been using the STACK question type. I will try your approach.

Best wishes, Juha-Matti

(I do not have enough reputation to add a comment, so I have to write my message in this way.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM