// Numbas version: exam_results_page_options {"name": "Fourier Sketching (-3 to 3) - Mod Function", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "name": "Fourier Sketching (-3 to 3) - Mod Function", "tags": [], "statement": "

\n

By dragging the points A, B, and C, construct the graph of the function

\n

$ f(x) = \\mid \\simplify{ x - {a}}\\; \\mid $

\n

Note that in order to be marked correct, the points need to be within 0.2 of their correct values.

\n

Also note that you have to drag each of the points in order to be able to submit your answer.

", "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n var a = scope.variables.a.value;\n var b = scope.variables.b.value;\n var c = scope.variables.c.value;\n\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-3.3,5.5,3.3,-5.5],grid:true,withLabel:true});\n $(question.display.html).find('#dragpoint').append(div);\n\n var board = div.board;\n \n// ceeate axis labels\n \n var label1 = board.create('point',[3.1,0.2],{name:'X',size:-1});\n label1.setProperty({fixed:true});\n var label2 = board.create('point',[0,14.3],{name:'y',size:-1});\n label2.setProperty({fixed:true});\n \n \n \n //create draggable points\n\n\n var line0 = board.create('line',[[-3,0],[-3,1]],{visible: false});\n var np0 = board.create('glider',[-3,0,line0],\n {\n name:'A',\n size:3\n }\n );\n\n var line1 = board.create('line',[[-1,0],[0,0]],{visible: false});\n var np1 = board.create('glider',[-0.5,0,line1],\n {\n name:'B',\n size:3\n }\n );\n \n var line2 = board.create('line',[[3,0],[3,4]],{visible: false});\n var np2 = board.create('glider',[3,0,line2],\n {\n name:'C',\n size:3,\n }\n );\n \n \n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 3;\n var points = [np0, np1, np2];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n var point = points[i];\n \n var x=point[0];\n var y=point[1];\n \n // the contents of the input box for this point\n var xstudentAnswer = question.parts[0].gaps[i].display.studentAnswer;\n\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var x = Numbas.math.niceNumber(point.X());\n var y = Numbas.math.niceNumber(point.Y());\n \n if(i===0)\n {\n var diff = y-b*(3+a);\n xstudentAnswer(diff);\n }\n if (i===1)\n {\n var diff = x-b*(a);\n xstudentAnswer(diff);\n }\n if (i===2)\n {\n var diff = y-b*(3-a);\n xstudentAnswer(diff);\n }\n });\n \n }\n \n // create each point\n for(var i=0;iThe correct graph is shown below.

\n

{graph(a,b,c)}

", "parts": [{"showCorrectAnswer": true, "prompt": "
", "showFeedbackIcon": true, "gaps": [{"showCorrectAnswer": true, "showFeedbackIcon": false, "mustBeReducedPC": 0, "variableReplacements": [], "scripts": {}, "mustBeReduced": false, "minValue": "-0.2", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "maxValue": "0.2", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "marks": "1", "correctAnswerStyle": "plain"}, {"showCorrectAnswer": true, "showFeedbackIcon": false, "mustBeReducedPC": 0, "variableReplacements": [], "scripts": {}, "mustBeReduced": false, "minValue": "-0.2", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "maxValue": "0.2", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "marks": "1", "correctAnswerStyle": "plain"}, {"showCorrectAnswer": true, "showFeedbackIcon": false, "mustBeReducedPC": 0, "variableReplacements": [], "scripts": {}, "mustBeReduced": false, "minValue": "- 0.2", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "maxValue": "0.2", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "marks": "1", "correctAnswerStyle": "plain"}], "variableReplacements": [], "scripts": {}, "marks": 0, "variableReplacementStrategy": "originalfirst", "type": "gapfill"}], "variablesTest": {"maxRuns": "200", "condition": ""}, "metadata": {"description": "", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "rulesets": {}, "extensions": ["jsxgraph"], "variables": {"b": {"group": "Ungrouped variables", "description": "", "name": "b", "templateType": "anything", "definition": "random(1)"}, "a": {"group": "Ungrouped variables", "description": "", "name": "a", "templateType": "anything", "definition": "random(-2..2)"}, "c": {"group": "Ungrouped variables", "description": "", "name": "c", "templateType": "anything", "definition": "random(1)"}}, "type": "question", "contributors": [{"name": "Gareth Woods", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/978/"}]}]}], "contributors": [{"name": "Gareth Woods", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/978/"}]}