JSXGraph Moodle / drawing to board after student has answered

78 views
Skip to first unread message

Juha-Matti Huusko

unread,
Sep 28, 2023, 6:25:37 AM9/28/23
to jsxg...@googlegroups.com
Dear all,

1) In Moodle, I have a STACK question, Question text:

Give the point \(A\) in the form [a,b].
[[jsxgraph]]
    var brd = JXG.JSXGraph.initBoard(BOARDID, {boundingbox:[-5,5,5,-5], axis:true});
    var A = brd.create('point', [2,3],{name:'A'});
[[/jsxgraph]]
[[input:ans1]] [[validation:ans1]]

2) If the student answers wrong, let's say [5,6], I want to draw the student's point to the picture. Answer is wrong. Your point is different, as you can see in the picture.

But, how can I access the board? What will be the ID of the board and how can I draw more points there?

Best wishes,
Juha-Matti Huusko

Raed Shorrosh

unread,
Sep 28, 2023, 6:46:27 PM9/28/23
to jsxg...@googlegroups.com
one way to do what you are asking is as follows:

<script type="text/javascript">
    var checkanswer;
</script>
[[jsxgraph]]
  var board = JXG.JSXGraph.initBoard(divid, {boundingbox: [-10, 5, 10, -5], axis: true, showCopyright: false});
  var A=board.create('point', [0,0],{name:'A'});
  var ans=[0,0];
  checkanswer=function(ans){
    A.moveTo(ans);
    board.update();

  }

[[/jsxgraph]]
[[input:ans1]] [[validation:ans1]]

now in the false node of the prt copy the following (as HTML) :

<p>your answer is wrong, see the graph</p>
<div style="display:none;">
    [[jsxgraph width="0px" height="0px"]]
       checkanswer({#ans1#});
    [[/jsxgraph]]
</div>


--
You received this message because you are subscribed to the Google Groups "JSXGraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsxgraph+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsxgraph/CANHZyDmGdNXFKRCJRuv4zQVJRJ0aSARUPx1YRh9BvpVFLor3mA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages