// Numbas version: exam_results_page_options {"name": "Draw a quadratic graph by dragging points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "

Draw the graph of the function \$\\simplify[all,fractionNumbers]{y={m}x+{c}}\$ by dragging the points A and B.

\n

Note that to be marked correct, you have to get the slope and the \$y\$-intercept to within 0.2 of the asked for values.

", "variablesTest": {"condition": "m<>0 or c<>0", "maxRuns": 100}, "variable_groups": [], "rulesets": {}, "ungrouped_variables": ["m", "c"], "functions": {"line": {"definition": "// set up the board\nvar div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-11,11,11,-11],grid:true,withLabel:true});\n\nvar board = div.board;\n\nvar d = board.create('point',[10,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',[0,c],{size:5,name:'A'});\ne.setProperty({fixed:true});\nvar g = board.create('point',[2,c+2*m],{size:5,name:'B'});\ng.setProperty({fixed:true});\n\nboard.create('functiongraph',[function(x){ return m*x*x+c;},-11,11],{strokeColor:'blue',strokeWidth:2});\n\nreturn div;", "type": "html", "parameters": [["m", "number"], ["c", "number"]], "language": "javascript"}, "dragpoint": {"definition": "// set up the board\nvar div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',);\nvar board = div.board;\n\nvar x1 = -8;\nvar y1 = 0;\nvar x2 = 8;\nvar y2 = 0;\n var num_points = 3;\n var points = [np0, np1, np2];\n\nvar e = board.create('point',[10,0],{size:-1,name:'x'});\ne.setProperty({fixed:true});\nvar f = board.create('point',[0,10],{size:-1,name:'y'});\nf.setProperty({fixed:true});\n\nvar np0 = board.create('point',[0,0],{size:5});\nvar np1 = board.create('point',[3,3],{size:5});\nvar np2 = board.create('point',[-3,3],{size:5});\n\n \n\n\nnp0.on('drag',function(){\n var x1 = Numbas.math.niceNumber(p[0].X());\n var y1 = Numbas.math.niceNumber(p[0].Y());\n var x2 = Numbas.math.niceNumber(p[1].X());\n var y2 = Numbas.math.niceNumber(p[1].Y());\n var m = (y2-y1)/(x2-x1);\n var c = y1-m*x1;\n\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(m);\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(c);\n});\nnp1.on('drag',function(){\n var x1 = Numbas.math.niceNumber(p[0].X());\n var y1 = Numbas.math.niceNumber(p[0].Y());\n var x2 = Numbas.math.niceNumber(p[1].X());\n var y2 = Numbas.math.niceNumber(p[1].Y());\n var m = (y2-y1)/(x2-x1);\n var c = y1-m*x1;\n\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(m);\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(c);\n});\nnp2.on('drag',function(){\n var x1 = Numbas.math.niceNumber(p[0].X());\n var y1 = Numbas.math.niceNumber(p[0].Y());\n var x2 = Numbas.math.niceNumber(p[1].X());\n var y2 = Numbas.math.niceNumber(p[1].Y());\n var m = (y2-y1)/(x2-x1);\n var c = y1-m*x1;\n\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(m);\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(c);\n});\n\n\n\nreturn div;\n\n\n", "type": "html", "parameters": [], "language": "javascript"}}, "metadata": {"description": "

This question asks a student to draw a straight line graph by dragging points.

", "licence": "Creative Commons Attribution 4.0 International"}, "extensions": ["jsxgraph"], "parts": [{"showCorrectAnswer": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "prompt": "

\n

", "type": "gapfill", "scripts": {}, "gaps": [{"variableReplacements": [], "correctAnswerFraction": false, "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "marks": "1", "showFeedbackIcon": true, "scripts": {}, "showCorrectAnswer": true, "correctAnswerStyle": "plain", "maxValue": "m+0.2", "allowFractions": false, "mustBeReducedPC": 0, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "minValue": "m-0.2"}, {"variableReplacements": [], "correctAnswerFraction": false, "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "scripts": {}, "showCorrectAnswer": true, "correctAnswerStyle": "plain", "maxValue": "c+0.2", "allowFractions": false, "mustBeReducedPC": 0, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "minValue": "c-0.2"}]}], "advice": "

{line(m,c)}

", "name": "Draw a quadratic graph by dragging points", "variables": {"m": {"definition": "random(-3..3#0.5)", "group": "Ungrouped variables", "description": "

The slope of the line.

", "templateType": "anything", "name": "m"}, "c": {"definition": "random(-5..5)", "group": "Ungrouped variables", "description": "

The y-intercept.

", "templateType": "anything", "name": "c"}}, "tags": [], "preamble": {"js": "", "css": ""}, "type": "question", "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/"}]}