// Numbas version: exam_results_page_options {"name": "Draw a quadratic graph by dragging points a=-1 b=0", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Draw a quadratic graph by dragging points a=-1 b=0", "tags": [], "metadata": {"description": "

Horizontal and vertical shifts and scales of a random cubic spline

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

By dragging the points A, B, C, D and E, construct the graph of the function $y=\\simplify[all]{{a}*x^2+{b}*x+{c}}$.

\n

Note that in order to be marked correct, the points need to be within 0.2 of their correct $y$-values. If necessary, you can zoom in on the graph by using ctrl-+, that is holding down the ctrl key and pressing +. To return to the normal zoom, you can use ctrl-0.

\n

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

", "advice": "

The correct graph is shown below.

\n

{graph(a,b,c)}

", "rulesets": {}, "extensions": ["jsxgraph"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"c": {"name": "c", "group": "Ungrouped variables", "definition": "random(-9..9)", "description": "

The function is f(x)=ax^2+bx+c.

", "templateType": "anything", "can_override": false}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "-1", "description": "

The function is f(x)=ax^2+bx+c.

", "templateType": "anything", "can_override": false}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "0", "description": "

The function is f(x)=ax^2+bx+c.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "4*a+2*b+c<=10 and 4*a+2*b+c>=-10 and 4*a-2*b+c<=10 and 4*a-2*b+c>=-10 and (-b/(2*a) < -2 or -b/(2*a) >2 or (-(b^2-4*a*c)/(4*a) <= 10 and -(b^2-4*a*c)/(4*a) >= -10))", "maxRuns": 100}, "ungrouped_variables": ["a", "b", "c"], "variable_groups": [], "functions": {"graph": {"parameters": [["a", "number"], ["b", "number"], ["c", "number"]], "type": "html", "language": "javascript", "definition": "// set up the board\nvar div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-2.5,11,2.5,-11],grid:true,withLabel:true,ticks:false});\n\nvar board = div.board;\n\nvar d = board.create('point',[2.1,0],{size:-1,name:'x'});\nd.setProperty({fixed:true});\nvar f = board.create('point',[0,10],{size:-1,name:'y'});\nf.setProperty({fixed:true});\nvar e = board.create('point',[-2,4*a-2*b+c],{size:5,name:'A'});\ne.setProperty({fixed:true});\nvar g = board.create('point',[-1,a-b+c],{size:5,name:'B'});\ng.setProperty({fixed:true});\nvar e = board.create('point',[0,c],{size:5,name:'C'});\ne.setProperty({fixed:true});\nvar e = board.create('point',[1,a+b+c],{size:5,name:'D'});\ne.setProperty({fixed:true});\nvar e = board.create('point',[2,4*a+2*b+c],{size:5,name:'E'});\ne.setProperty({fixed:true});\n\nboard.create('functiongraph',[function(x){ return a*x*x+b*x+c;},-2,2],{strokeColor:'blue',strokeWidth:2});\n\nreturn div;"}}, "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:[-2.5,11,2.5,-11],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',[2.1,0.2],{name:'X',size:-1});\n label1.setProperty({fixed:true});\n var label2 = board.create('point',[0,10.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',[[-2,0],[-2,1]],{visible: false});\n var np0 = board.create('glider',[-2,8.5,line0],\n {\n name:'A',\n size:5\n }\n );\n\n var line1 = board.create('line',[[-1,0],[-1,1]],{visible: false});\n var np1 = board.create('glider',[-1,8.5,line1],\n {\n name:'B',\n size:5\n }\n );\n \n var line2 = board.create('line',[[0,0],[0,1]],{visible: false});\n var np2 = board.create('glider',[0,8.5,line2],\n {\n name:'C',\n size:5,\n }\n );\n \n var line3 = board.create('line',[[1,0],[1,1]],{visible: false});\n var np3 = board.create('glider',[1,8.5,line3],\n {\n name:'D',\n size:5\n }\n );\n var line4 = board.create('line',[[2,0],[2,1]],{visible: false});\n var np4 = board.create('glider',[2,8.5,line4],\n {\n name:'E',\n size:5\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 = 5;\n var points = [np0, np1, np2, np3, np4];\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 var diff = y-(a*x*x+b*x+c);\n xstudentAnswer(diff);\n });\n \n }\n \n // create each point\n for(var i=0;i", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-0.2", "maxValue": "0.2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-0.2", "maxValue": "0.2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-0.2", "maxValue": "0.2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-0.2", "maxValue": "0.2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-0.2", "maxValue": "0.2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Anthony Brown", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/799/"}]}]}], "contributors": [{"name": "Anthony Brown", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/799/"}]}