// Numbas version: exam_results_page_options {"name": "JSXGraph test", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "parts": [{"type": "gapfill", "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

{dragpoint()}

\n

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

", "gaps": [{"notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "type": "numberentry", "minValue": "a-0.1", "variableReplacements": [], "scripts": {}, "showCorrectAnswer": true, "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "maxValue": "a+0.1", "mustBeReduced": false, "allowFractions": false, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "marks": 1}, {"notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "type": "numberentry", "minValue": "b-0.1", "variableReplacements": [], "scripts": {}, "showCorrectAnswer": true, "mustBeReducedPC": 0, "correctAnswerStyle": "plain", "maxValue": "b+0.1", "mustBeReduced": false, "allowFractions": false, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "marks": 1}], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "prompt": "

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

\n

{singraph()}

\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)$.

", "scripts": {}, "showCorrectAnswer": true, "variableReplacements": [], "matrix": [1, 0, 0], "maxMarks": 0, "displayColumns": 0, "distractors": ["", "", ""], "choices": ["

Odd

", "

Even

", "

Neither

"], "type": "1_n_2", "minMarks": 0, "showFeedbackIcon": true, "shuffleChoices": false, "variableReplacementStrategy": "originalfirst", "marks": 0}, {"type": "gapfill", "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

{polarplot()}

", "gaps": [{"vsetrange": [0, 1], "showpreview": true, "expectedvariablenames": [], "answer": "5sqrt(cos(2t))", "scripts": {}, "variableReplacements": [], "showCorrectAnswer": true, "vsetrangepoints": 5, "type": "jme", "checkingtype": "absdiff", "checkvariablenames": false, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "marks": 1, "checkingaccuracy": 0.001}], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "showCorrectAnswer": true, "marks": 0}], "ungrouped_variables": ["b", "a"], "variablesTest": {"maxRuns": 100, "condition": ""}, "advice": "", "functions": {"polarplot": {"parameters": [], "type": "html", "language": "javascript", "definition": "\n var div = Numbas.extensions.jsxgraph.makeBoard('600px','400px',{\nboundingBox:[-6,4,6,-4],\ngrid: false,\nshowNavigation: false\n });\n var board = div.board;\n \n var tree;\n var nscope = new Numbas.jme.Scope([scope,{variables:{t:new Numbas.jme.types.TNum(0)}}]);\n var curve = board.create('curve',[function(t){\nif(tree) {\n try {\nnscope.variables.t.value = t;\n var val = Numbas.jme.evaluate(tree,nscope).value;\n return val;\n }\n catch(e) {\nreturn 0;\n }\n}\nelse\n return 0;\n },[0,0]],0,2*Math.PI);\n \n question.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\nvar expr = question.parts[2].gaps[0].display.studentAnswer();\ntry {\n tree = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n tree = null;\n}\ncurve.updateCurve();\nboard.update();\n});\n });\n \n return div;\n "}, "singraph": {"parameters": [], "type": "html", "language": "javascript", "definition": "\nvar div = Numbas.extensions.jsxgraph.makeBoard('600px','200px',{boundingBox:[-2*Math.PI,1.2,2*Math.PI,-1.2],grid:false});\nvar board = div.board;\n\nvar graph = board.create('functiongraph',function(x){return Math.sin(x)});\n\nvar p1 = board.create('glider',[1,graph.Y(1),graph],{name:'$f(x)$'});\nvar p2 = board.create('point',[function(){return - p1.X()},function(){return graph.Y(-p1.X())}],{name:'$f(-x)$'})\n\nreturn div;\n"}, "dragpoint": {"parameters": [], "type": "html", "language": "javascript", "definition": "\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[-10,10,10,-10],grid:false});\nvar board = div.board;\n\nvar x = Numbas.jme.unwrapValue(scope.variables.a);\nvar y = Numbas.jme.unwrapValue(scope.variables.b);\n\nvar a = board.create('point',[x,y],'$A$');\na.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\nboard.create('line',[[0,2],[1,4]]);\n\nquestion.signals.on('HTMLAttached',function(e) {\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\nreturn div;\n\n"}}, "metadata": {"description": "

Experimental question using JSXGraph to provide dynamic, interactive graphs.

", "licence": "Creative Commons Attribution 4.0 International"}, "extensions": ["jsxgraph"], "preamble": {"js": "", "css": ""}, "rulesets": {}, "variables": {"b": {"name": "b", "definition": "2", "templateType": "anything", "description": "", "group": "Ungrouped variables"}, "a": {"name": "a", "definition": "1", "templateType": "anything", "description": "", "group": "Ungrouped variables"}}, "name": "JSXGraph test", "variable_groups": [], "statement": "", "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/"}]}