// Numbas version: finer_feedback_settings {"name": "Draw a straight line graph by dragging points Horizontal", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["m", "c"], "parts": [{"variableReplacements": [], "showCorrectAnswer": true, "prompt": "
{dragpoint()}
\n", "marks": 0, "scripts": {}, "gaps": [{"minValue": "m-0.2", "variableReplacements": [], "marks": "1", "maxValue": "m+0.2", "type": "numberentry", "showFeedbackIcon": true, "allowFractions": false, "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "scripts": {}, "correctAnswerFraction": false, "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"]}, {"minValue": "c-0.2", "variableReplacements": [], "marks": 1, "maxValue": "c+0.2", "type": "numberentry", "showFeedbackIcon": true, "allowFractions": false, "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "scripts": {}, "correctAnswerFraction": false, "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"]}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true}], "extensions": ["jsxgraph"], "functions": {"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});\n\nreturn div;\n\n\n", "parameters": [], "language": "javascript", "type": "html"}, "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;", "parameters": [["m", "number"], ["c", "number"]], "language": "javascript", "type": "html"}}, "variables": {"c": {"definition": "random(-5.5..5.5#0.5)", "description": "
The y-intercept.
", "group": "Ungrouped variables", "templateType": "anything", "name": "c"}, "m": {"definition": "0", "description": "The slope of the line.
", "group": "Ungrouped variables", "templateType": "anything", "name": "m"}}, "variable_groups": [], "preamble": {"js": "", "css": ""}, "tags": [], "metadata": {"description": "This question asks a student to draw a straight line graph by dragging points.
", "licence": "Creative Commons Attribution 4.0 International"}, "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.
", "variablesTest": {"maxRuns": 100, "condition": "m<>0 or c<>0"}, "advice": "\nThis is a horizontal line with the $y$ value $y= \\var[fractionNumbers]{c}$.
\n{line(m,c)}
", "rulesets": {}, "name": "Draw a straight line graph by dragging points Horizontal", "type": "question", "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}], "resources": []}]}], "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}]}