// Numbas version: exam_results_page_options {"name": "Hina's copy of Draw a straight line graph by dragging points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Hina's copy of Draw a straight line graph by dragging points", "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+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',{boundingBox:[-11,11,11,-11],grid:true,labels:true});\nvar board = div.board;\n\nvar x1 = -8;\nvar y1 = 0;\nvar x2 = 8;\nvar y2 = 0;\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 a = board.create('point',[-8,0],{size:5});\nvar b = board.create('point',[8,0],{size:5});\n\na.on('drag',function(){\n var x1 = Numbas.math.niceNumber(a.X());\n var y1 = Numbas.math.niceNumber(a.Y());\n var x2 = Numbas.math.niceNumber(b.X());\n var y2 = Numbas.math.niceNumber(b.Y());\n var m = (y2-y1)/(x2-x1);\n var c = y1-m*x1;\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(m);\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(c);\n});\nb.on('drag',function(){\n var x1 = Numbas.math.niceNumber(a.X());\n var y1 = Numbas.math.niceNumber(a.Y());\n var x2 = Numbas.math.niceNumber(b.X());\n var y2 = Numbas.math.niceNumber(b.Y());\n var m = (y2-y1)/(x2-x1);\n var c = y1-m*x1;\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(m);\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(c);\n});\n\nvar line = board.create('line',[a,b], {strokeColor:'blue',strokeWidth:2});\nline.on('drag',function(){\n var x1 = Numbas.math.niceNumber(a.X());\n var y1 = Numbas.math.niceNumber(a.Y());\n var x2 = Numbas.math.niceNumber(b.X());\n var y2 = Numbas.math.niceNumber(b.Y());\n var m = (y2-y1)/(x2-x1);\n var c = y1-m*x1;\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(m);\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(c);\n});\nreturn div;\n\n\n", "type": "html", "parameters": [], "language": "javascript"}}, "advice": "

{line(m,c)}

", "variables": {"m": {"name": "m", "definition": "random(-3..3#0.5)", "group": "Ungrouped variables", "description": "

The slope of the line.

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

The y-intercept.

", "templateType": "anything"}}, "variablesTest": {"maxRuns": 100, "condition": "m<>0 or c<>0"}, "parts": [{"scripts": {}, "type": "gapfill", "gaps": [{"maxValue": "m+0.2", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "marks": "2", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showFeedbackIcon": true, "scripts": {}, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "allowFractions": false, "minValue": "m-0.2"}, {"maxValue": "c+0.2", "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "marks": "2", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showFeedbackIcon": true, "scripts": {}, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "allowFractions": false, "minValue": "c-0.2"}], "showCorrectAnswer": true, "marks": 0, "variableReplacementStrategy": "originalfirst", "prompt": "

{dragpoint()}

\n

", "variableReplacements": [], "showFeedbackIcon": true}], "variable_groups": [], "extensions": ["jsxgraph"], "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["m", "c"], "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.

", "rulesets": {}, "tags": [], "metadata": {"description": "

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

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "contributors": [{"name": "Hina Ahmed", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1160/"}]}]}], "contributors": [{"name": "Hina Ahmed", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1160/"}]}