// Numbas version: finer_feedback_settings {"name": "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": [{"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", "language": "javascript", "parameters": [["m", "number"], ["c", "number"]]}, "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", "language": "javascript", "parameters": []}}, "ungrouped_variables": ["m", "c"], "name": "Draw a straight line graph by dragging points", "tags": [], "preamble": {"css": "", "js": ""}, "advice": "
{line(m,c)}
", "rulesets": {}, "parts": [{"prompt": "{dragpoint()}
\n", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "m+0.2", "minValue": "m-0.2", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": "2", "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "c+0.2", "minValue": "c-0.2", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": "2", "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "extensions": ["jsxgraph"], "statement": "
Draw the graph of the function $\\simplify[all,fractionNumbers]{y={m}x+{c}}$ by dragging the points A and B.
\nNote that to be marked correct, you have to get the slope and the $y$-intercept to within 0.2 of the asked for values.
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": "m<>0 or c<>0"}, "variables": {"c": {"definition": "random(-5..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "c", "description": "The y-intercept.
"}, "m": {"definition": "random(-3..3#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "m", "description": "The slope of the line.
"}}, "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", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Paul Howes", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/632/"}]}]}], "contributors": [{"name": "Paul Howes", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/632/"}]}