PremierLangage / Yggdrasil

A PL subproject where we are tackling the design of new types of exercises
4 stars 2 forks source link

JSXGraph exercise #14

Open ddoyen opened 5 years ago

ddoyen commented 5 years ago

An exercise where the student has to move geometrical objects in a JSXGraph drawing panel.

Syntax

The JSXGraph script is defined in a key jxgscript. The properties of the geometrical objects that are relevant for the evaluation of the exercise are stored in variables form_XXX.

jxgscript ==
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-10, 10, 10, -10], axis:true});
var p = brd.create('point',[0,0]);
var form_x=p.X();
var form_y=p.Y();
==

The usual text and form keys. The JSXGraph drawing panel is inserted in the form with an element <div class="jxgbox"></div>.

text ==
Déplacer le point aux coordonnées (1,3).
==

form ==
<div id="jxgbox" class="jxgbox" style="width:300px; height:300px;"></div>
==

The usual evaluator key where the value of form_XXX is retrieved in the usual answer dictionary.

evaluator ==
x=answer['x']
y=answer['y']
from math import sqrt
if sqrt((x-1)**2+(y-3)**2)<0.1:
     grade=(100,"Bonne réponse")
else:
     grade=(0,"Mauvaise réponse")
==
ddoyen commented 5 years ago

I have improved the template and begun to document it.

https://github.com/PremierLangage/conceptexo/tree/master/JSXGraph