// Numbas version: exam_results_page_options {"name": "JSXGraph test (preamble version)", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {}, "ungrouped_variables": ["a", "b"], "name": "JSXGraph test (preamble version)", "tags": ["demo"], "preamble": {"css": "", "js": "// There is a function for each board. These functions are called after the question HTML is generated.\n\nfunction dragpoint_board() {\n var div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[-10,10,10,-10],grid:false});\n $(question.display.html).find('#dragpoint').append(div);\n \n var board = div.board;\n var scope = question.scope;\n \n var x = Numbas.jme.unwrapValue(scope.variables.a);\n var y = Numbas.jme.unwrapValue(scope.variables.b);\n \n var a = board.create('point',[x,y],'$A$');\n a.on('drag',function(){\n var x = Numbas.math.niceNumber(a.X());\n var y = Numbas.math.niceNumber(a.Y());\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(a.X());\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(y);\n });\n ko.computed(function(){ \n var x = parseFloat(question.parts[0].gaps[0].display.studentAnswer());\n var y = parseFloat(question.parts[0].gaps[1].display.studentAnswer());\n if(!(isNaN(x) || isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n a.moveTo([x,y],100);\n }\n });\n}\n\nfunction singraph_board() {\n var div = Numbas.extensions.jsxgraph.makeBoard('600px','200px',{boundingBox:[-2*Math.PI,1.2,2*Math.PI,-1.2],grid:false});\n \n $(question.display.html).find('#singraph').append(div);\n \n var board = div.board;\n \n var graph = board.create('functiongraph',function(x){return Math.sin(x)});\n \n var p1 = board.create('glider',[1,graph.Y(1),graph],{name:'$f(x)$'});\n var p2 = board.create('point',[function(){return - p1.X()},function(){return graph.Y(-p1.X())}],{name:'$f(-x)$'});\n}\n\nfunction polarplot_board() {\n \n var div = Numbas.extensions.jsxgraph.makeBoard('600px','400px',{\n boundingBox:[-6,4,6,-4],\n grid: false,\n showNavigation: false\n });\n $(question.display.html).find('#polarplot').append(div);\n \n var board = div.board;\n \n var tree;\n var nscope = new Numbas.jme.Scope([question.scope,{variables:{t:new Numbas.jme.types.TNum(0)}}]);\n var curve = board.create('curve',[function(t){\n if(tree) {\n try {\n nscope.variables.t.value = t;\n var val = Numbas.jme.evaluate(tree,nscope).value;\n return val;\n }\n catch(e) {\n return 0;\n }\n }\n else\n return 0;\n },[0,0]],0,2*Math.PI);\n \n ko.computed(function(){\n var expr = question.parts[2].gaps[0].display.studentAnswer();\n try {\n tree = Numbas.jme.compile(expr,question.scope);\n }\n catch(e) {\n tree = null;\n console.log(e);\n }\n curve.updateCurve();\n board.update();\n });\n}\n\n\nquestion.signals.on('HTMLAttached',function() {\n dragpoint_board();\n singraph_board();\n polarplot_board();\n});\n"}, "advice": "", "rulesets": {}, "parts": [{"prompt": "

This part demonstrates a binding between the properties of an element in the graph and values entered in the answer boxes.

\n

Place the dot at $(\\var{a},\\var{b})$. You can either drag the dot or enter coordinates in the box.

\n
\n

$X$: [[0]], $Y$: [[1]]

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "a+0.1", "minValue": "a-0.1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "b+0.1", "minValue": "b-0.1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"displayColumns": 0, "prompt": "

This part shows the use of a dynamic graph to illustrate a question.

\n
\n

Is this function odd or even, or neither? You can drag the point labelled $f(x)$ and compare it with the point labelled $f(-x)$.

", "matrix": [1, 0, 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

Odd

", "

Even

", "

Neither

"], "variableReplacementStrategy": "originalfirst", "maxMarks": 0, "distractors": ["", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}, {"prompt": "

This part contains a dynamic plot of the function entered by the student.

\n

Define a function $f(t)$ on $[0,2\\pi)$ which plots in polar coordinates a Lemniscate of Bernoulli touching the points $(-5,0)$, $(0,0)$ and $(5,0)$.

\n

$f(t) = $ [[0]]

\n
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"vsetrangepoints": 5, "expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "answer": "5sqrt(cos(2t))", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "extensions": ["jsxgraph"], "statement": "", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "1", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "2", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"description": "

Experimental question using JSXGraph to provide dynamic, interactive graphs.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}