// Numbas version: exam_results_page_options {"showQuestionGroupNames": false, "name": "Graphing Linear Functions", "percentPass": 0, "custom_part_types": [], "timing": {"timeout": {"action": "none", "message": ""}, "allowPause": true, "timedwarning": {"action": "none", "message": ""}}, "showstudentname": true, "feedback": {"feedbackmessages": [], "showanswerstate": true, "showactualmark": true, "allowrevealanswer": true, "showtotalmark": true, "advicethreshold": 0, "intro": ""}, "resources": [], "question_groups": [{"questions": [{"name": "Graphing: Linear from calculated values", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/", "name": "Michael Proudman"}], "tags": ["jsxgraph", "JSXgraph", "Jsxgraph", "plot", "quadratic"], "advice": "

## Video Help

\n

\n

", "ungrouped_variables": ["a", "c"], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"description": "

Compute a table of values for a linear function. A JSXgraph plot shows the plot going through the entered values.

", "licence": "None specified"}, "parts": [{"choices": ["

", "

"], "maxMarks": 1, "shuffleChoices": false, "adaptiveMarkingPenalty": 0, "variableReplacementStrategy": "originalfirst", "minMarks": 0, "marks": 0, "distractors": ["", ""], "showFeedbackIcon": true, "displayColumns": 0, "scripts": {}, "prompt": "

The graph of this formula has:

Fill in the table of values for $y=\\simplify{{a}x+{c}}$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$x$$-3$$-2$$-1$$0$$1$$2$$3 y[[0]][[1]][[2]][[3]][[4]][[5]][[6]] \n ", "customMarkingAlgorithm": "", "customName": ""}, {"gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "0", "correctAnswerFraction": false, "marks": 0.5, "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "showFractionHint": true, "showFeedbackIcon": true, "customName": "", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "allowFractions": false, "minValue": "0", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "customMarkingAlgorithm": ""}, {"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "{c}", "correctAnswerFraction": false, "marks": 0.5, "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "showFractionHint": true, "showFeedbackIcon": true, "customName": "", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "allowFractions": false, "minValue": "{c}", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "customMarkingAlgorithm": ""}], "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "unitTests": [], "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": " Give the coordinates of the y intercept: \\bigg([[0]], [[1]]\\bigg) ", "customMarkingAlgorithm": "", "customName": ""}], "rulesets": {"std": ["all", "fractionNumbers"]}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n var a = scope.variables.a.value;\n var c = scope.variables.c.value;\n var maxy = Math.max(Math.abs(a*9+c),Math.abs(c));\n \n var div = Numbas.extensions.jsxgraph.makeBoard('250px','400px',{boundingBox:[-5,maxy+3,5,-maxy-3],grid:true});\n question.display.html.find('#dragpoint').append(div);\n \n var board = div.board;\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 = 7;\n var points = [];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n var point = points[i] = board.create(\n 'glider',\n [i-(num_points-1)/2,0,line],\n {\n name:'',\n size:2,\n snapSizeY: 0.1, // the point will snap to y-coordinates which are multiples of 0.1\n snapToGrid: true\n }\n );\n \n // the contents of the input box for this point\n var studentAnswer = question.parts[1].gaps[i].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n y = evaluate(studentAnswer());\n if(!(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var y = Numbas.math.niceNumber(point.Y());\n studentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;iYou are given the formula:\n ## y=\\simplify{{a}x+{c}} ", "variable_groups": [], "variables": {"a": {"templateType": "anything", "definition": "random(-3,-2,-1,-0.5,0.5,1,2,3)", "group": "Ungrouped variables", "description": "", "name": "a"}, "c": {"templateType": "anything", "definition": "random(-4..4 except 0)", "group": "Ungrouped variables", "description": "", "name": "c"}}}, {"name": "Graphing: Linear from calculated values", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/", "name": "Michael Proudman"}], "tags": ["jsxgraph", "JSXgraph", "Jsxgraph", "plot", "quadratic"], "advice": " ## Video Help \n \n ", "ungrouped_variables": ["a", "c"], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"description": " Compute a table of values for a linear function. A JSXgraph plot shows the plot going through the entered values. ", "licence": "None specified"}, "parts": [{"choices": [" A positive gradient. ", " A negative gradient. "], "maxMarks": 1, "shuffleChoices": false, "adaptiveMarkingPenalty": 0, "variableReplacementStrategy": "originalfirst", "minMarks": 0, "marks": 0, "distractors": ["", ""], "showFeedbackIcon": true, "displayColumns": 0, "scripts": {}, "prompt": " The graph of this formula has: ", "extendBaseMarkingAlgorithm": true, "customName": "", "matrix": ["if(a>0,1,0)", "if(a>0,0,1)"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "displayType": "radiogroup", "showCorrectAnswer": true, "type": "1_n_2", "customMarkingAlgorithm": "", "showCellAnswerState": true}, {"gaps": [{"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{a}*(-3)+{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{a}*(-2)+{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{a}*(-1)+{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{a}*1+{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{a}*2+{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "marks": 0.5, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showPreview": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "valuegenerators": [], "answer": "{a}*3+{c}", "showFeedbackIcon": true, "customName": "", "checkingAccuracy": 0.001, "variableReplacements": [], "unitTests": [], "useCustomName": false, "showCorrectAnswer": true, "checkingType": "absdiff", "type": "jme", "customMarkingAlgorithm": ""}], "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "unitTests": [], "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": " Fill in the table of values for y=\\simplify{{a}x+{c}}: \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n x$$-3$$-2$$-1$$0$$1$$2$$3$
$y$[[0]][[1]][[2]][[3]][[4]][[5]][[6]]
\n
", "customMarkingAlgorithm": "", "customName": ""}, {"gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "0", "correctAnswerFraction": false, "marks": 0.5, "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "showFractionHint": true, "showFeedbackIcon": true, "customName": "", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "allowFractions": false, "minValue": "0", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "customMarkingAlgorithm": ""}, {"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "{c}", "correctAnswerFraction": false, "marks": 0.5, "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "showFractionHint": true, "showFeedbackIcon": true, "customName": "", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "allowFractions": false, "minValue": "{c}", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "customMarkingAlgorithm": ""}], "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "unitTests": [], "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Give the coordinates of the y intercept: $\\bigg($[[0]]$,$ [[1]]$\\bigg)$

", "customMarkingAlgorithm": "", "customName": ""}], "rulesets": {"std": ["all", "fractionNumbers"]}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n var a = scope.variables.a.value;\n var c = scope.variables.c.value;\n var maxy = Math.max(Math.abs(a*9+c),Math.abs(c));\n \n var div = Numbas.extensions.jsxgraph.makeBoard('250px','400px',{boundingBox:[-5,maxy+3,5,-maxy-3],grid:true});\n question.display.html.find('#dragpoint').append(div);\n \n var board = div.board;\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 = 7;\n var points = [];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n var point = points[i] = board.create(\n 'glider',\n [i-(num_points-1)/2,0,line],\n {\n name:'',\n size:2,\n snapSizeY: 0.1, // the point will snap to y-coordinates which are multiples of 0.1\n snapToGrid: true\n }\n );\n \n // the contents of the input box for this point\n var studentAnswer = question.parts[1].gaps[i].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n y = evaluate(studentAnswer());\n if(!(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var y = Numbas.math.niceNumber(point.Y());\n studentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;iYou are given the formula:\n

## $y=\\simplify{{a}x+{c}}$

", "variable_groups": [], "variables": {"a": {"templateType": "anything", "definition": "random(-3,-2,-1,-0.5,0.5,1,2,3)", "group": "Ungrouped variables", "description": "", "name": "a"}, "c": {"templateType": "anything", "definition": "random(-4..4 except 0)", "group": "Ungrouped variables", "description": "", "name": "c"}}}, {"name": "Graphing: Linear from calculated values", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/", "name": "Michael Proudman"}], "tags": ["jsxgraph", "JSXgraph", "Jsxgraph", "plot", "quadratic"], "advice": "

## Video Help

\n

\n

", "ungrouped_variables": ["a", "c"], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"description": "

Compute a table of values for a linear function. A JSXgraph plot shows the plot going through the entered values.

", "licence": "None specified"}, "parts": [{"choices": ["

", "

"], "maxMarks": 1, "shuffleChoices": false, "adaptiveMarkingPenalty": 0, "variableReplacementStrategy": "originalfirst", "minMarks": 0, "marks": 0, "distractors": ["", ""], "showFeedbackIcon": true, "displayColumns": 0, "scripts": {}, "prompt": "

The graph of this formula has:

Fill in the table of values for $y=\\simplify{{a}x+{c}}$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$x$$-3$$-2$$-1$$0$$1$$2$$3$
$y$[[0]][[1]][[2]][[3]][[4]][[5]][[6]]
\n
", "customMarkingAlgorithm": "", "customName": ""}, {"gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "0", "correctAnswerFraction": false, "marks": 0.5, "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "showFractionHint": true, "showFeedbackIcon": true, "customName": "", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "allowFractions": false, "minValue": "0", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "customMarkingAlgorithm": ""}, {"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "maxValue": "{c}", "correctAnswerFraction": false, "marks": 0.5, "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "showFractionHint": true, "showFeedbackIcon": true, "customName": "", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "unitTests": [], "useCustomName": false, "allowFractions": false, "minValue": "{c}", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "customMarkingAlgorithm": ""}], "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "unitTests": [], "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Give the coordinates of the y intercept: $\\bigg($[[0]]$,$ [[1]]$\\bigg)$

", "customMarkingAlgorithm": "", "customName": ""}], "rulesets": {"std": ["all", "fractionNumbers"]}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n var a = scope.variables.a.value;\n var c = scope.variables.c.value;\n var maxy = Math.max(Math.abs(a*9+c),Math.abs(c));\n \n var div = Numbas.extensions.jsxgraph.makeBoard('250px','400px',{boundingBox:[-5,maxy+3,5,-maxy-3],grid:true});\n question.display.html.find('#dragpoint').append(div);\n \n var board = div.board;\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 = 7;\n var points = [];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n var point = points[i] = board.create(\n 'glider',\n [i-(num_points-1)/2,0,line],\n {\n name:'',\n size:2,\n snapSizeY: 0.1, // the point will snap to y-coordinates which are multiples of 0.1\n snapToGrid: true\n }\n );\n \n // the contents of the input box for this point\n var studentAnswer = question.parts[1].gaps[i].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n y = evaluate(studentAnswer());\n if(!(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var y = Numbas.math.niceNumber(point.Y());\n studentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;iYou are given the formula:\n

## $y=\\simplify{{a}x+{c}}$

", "variable_groups": [], "variables": {"a": {"templateType": "anything", "definition": "random(-3,-2,-1,-0.5,0.5,1,2,3)", "group": "Ungrouped variables", "description": "", "name": "a"}, "c": {"templateType": "anything", "definition": "random(-4..4 except 0)", "group": "Ungrouped variables", "description": "", "name": "c"}}}, {"name": "Linear Equations - Find the equation of a line through two points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/", "name": "Chris Graham"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1521/", "name": "Bradley Bush"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1592/", "name": "Aiden McCall"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1738/", "name": "Paul Hancock"}], "tags": [], "variablesTest": {"condition": "\n", "maxRuns": 100}, "functions": {"plotPoints": {"definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n var ans;\n var nscope = new Numbas.jme.Scope([scope,{variables:{x:new Numbas.jme.types.TNum(0)}}]);\n//this is the beating heart of whatever plots the function,\n//I've changed this from being curve to functiongraph\n var line = board.create('functiongraph',[function(x){\nif(ans) {\n try {\nnscope.variables.x.value = x;\n var val = Numbas.jme.evaluate(ans,nscope).value;\n return val;\n }\n catch(e) {\nreturn 13;\n }\n}\nelse\n return 13;\n },-12,12]\n , {strokeColor:\"blue\",strokeWidth: 4} );\n \nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: false, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\nquestion.lines = {\n l:line, c:correct_line\n}\n\n $('body').on('question-html-attached',function(e,question,qd) {\nko.computed(function(){\nvar expr = question.parts[2].gaps[0].display.studentAnswer();\n\n//define ans as this \ntry {\n ans = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n ans = null;\n}\nline.updateCurve();\ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "type": "html", "parameters": []}, "correctPoints": {"definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n\nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: true, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\n\n\n$('body').on('question-html-attached',function(e,question,qd) {\nko.computed(function(){\n//define ans as this \ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "type": "html", "parameters": []}}, "ungrouped_variables": ["xa", "xb", "ya", "yb", "m", "c"], "advice": "

We find the equation of a straight line passing through two points by finding the gradient and the $y$-intercept of the line.

\n

#### a)

\n

We can find the gradient ($m$) using the points $A = (x_1,y_1)=(\\var{xa},\\var{ya})$ and $B = (x_2,y_2)=(\\var{xb},\\var{yb})$.

\n

As the definition of gradient is the ratio of vertical change ($y_2-y_1$) to horizontal change ($x_2-x_1$).

\n

\\begin{align}
m &= \\frac{y_2-y_1}{x_2-x_1} \\\0.5em] &= \\frac{\\simplify[!collectNumbers]{{yb}-{ya}}}{\\simplify[!collectNumbers]{{xb}-{xa}}} \\\\[0.5em] &= \\frac{\\simplify[]{{yb}-{ya}}}{\\simplify{{xb}-{xa}}} \\\\[0.5em] &= \\simplify[simplifyFractions,unitDenominator]{({yb-ya})/({xb-xa})}\\text{.} \\end{align} \n #### b) \n Rearranging the equation y=mx+c and substituting either of the points gives \n \\[c = y_1-mx_1 \\quad \\mathrm{or} \\quad c = y_2-mx_2 \\,\\text{.} \

\n

We can then also use this equation with the other point's coordinates to check our answer.

\n

Let's use point $A$ first:

\n

\\\begin{align} c &= y_1-mx_1 \\\\ &= \\var{ya}-\\var[fractionnumbers]{m}\\times\\var{xa} \\\\ & = \\simplify[fractionnumbers]{{ya-m*xa}}\\text{.} \\end{align} \

\n

We then check this against point $B$:

\n

\\\begin{align} y_2 &= mx_2 + c \\\\[0.5em] &= \\simplify[fractionNumbers]{{m}{xb}+{c}} \\\\[0.5em] &= \\var[fractionnumbers]{m*xb+c}\\text{.} \\end{align} \

\n

#### c)

\n

We can now substitute these values for $m$ and $c$ into $y=mx+c$  to get:

\n

\$y=\\simplify[!noLeadingMinus,fractionNumbers,unitFactor]{{m} x+ {c}}\\text{.}\$

\n

The green line drawn on the graph represents the above line equation.

\n

{correctPoints()}

", "parts": [{"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "m", "variableReplacements": [], "unitTests": [], "showFeedbackIcon": true, "allowFractions": true, "mustBeReduced": false, "minValue": "m", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": true}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Calculate the gradient, $m$, of the straight line between these two points.

\n

$m=$ [[0]]

\n

", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "c", "variableReplacements": [], "unitTests": [], "showFeedbackIcon": true, "allowFractions": false, "mustBeReduced": false, "minValue": "c", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": false}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Use this gradient and the coordinates of the points to calculate the $y$-intercept, $c$.

\n

$c=$ [[0]]

", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"answer": "{m}*x+{c}", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "checkingAccuracy": 0.001, "vsetRangePoints": 5, "extendBaseMarkingAlgorithm": true, "checkVariableNames": true, "variableReplacements": [], "unitTests": [], "marks": 1, "vsetRange": [0, 1], "showCorrectAnswer": true, "checkingType": "absdiff", "notallowed": {"showStrings": false, "strings": ["c", "m"], "partialCredit": 0, "message": "

You must input your answer in the form y = mx +c where m and c are numbers.

"}, "expectedVariableNames": ["x"], "type": "jme", "scripts": {}, "customMarkingAlgorithm": "", "failureRate": 1, "answerSimplification": "fractionNumbers", "showPreview": true}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {"mark": {"script": "this.question.lines.l.setAttribute({strokeColor: this.credit==1 ? 'green' : 'red'});\nthis.question.lines.c.setAttribute({visible: this.credit==1});\n", "order": "after"}}, "prompt": "

Give the equation of the straight line through these points in the form $y=mx+c$.

\n

$\\displaystyle y=$ [[0]]

\n

Use the graph to plot your answer and check that it goes through these points.

", "customMarkingAlgorithm": ""}], "rulesets": {}, "preamble": {"js": "", "css": ""}, "metadata": {"description": "

Use two points on a line graph to calculate the gradient and $y$-intercept and hence the equation of the straight line running through both points.

\n

The answer box for the third part plots the function which allows the student to check their answer against the graph before submitting.

\n

This particular example has a positive gradient.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

In this question we will identify the equation of the straight line passing through points  $A=(\\var{xa},\\var{ya})$ and  $B=(\\var{xb},\\var{yb})$ in the form $y = mx + c$.

\n

{plotPoints()}

", "variable_groups": [], "type": "question", "variables": {"m": {"templateType": "anything", "definition": "(ya-yb)/(xa-xb)", "group": "Ungrouped variables", "description": "", "name": "m"}, "xa": {"templateType": "anything", "definition": "random(-4..-1)", "group": "Ungrouped variables", "description": "", "name": "xa"}, "ya": {"templateType": "anything", "definition": "random(-4..2)", "group": "Ungrouped variables", "description": "", "name": "ya"}, "xb": {"templateType": "anything", "definition": "xa+random([2,4] except -xa)", "group": "Ungrouped variables", "description": "", "name": "xb"}, "yb": {"templateType": "anything", "definition": "ya+random([2,4])", "group": "Ungrouped variables", "description": "", "name": "yb"}, "c": {"templateType": "anything", "definition": "ya-m*xa", "group": "Ungrouped variables", "description": "", "name": "c"}}}, {"name": "Linear Equations - Find the equation of a line through two points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/", "name": "Chris Graham"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1521/", "name": "Bradley Bush"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1592/", "name": "Aiden McCall"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1738/", "name": "Paul Hancock"}], "tags": [], "variablesTest": {"condition": "\n", "maxRuns": 100}, "functions": {"plotPoints": {"definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n var ans;\n var nscope = new Numbas.jme.Scope([scope,{variables:{x:new Numbas.jme.types.TNum(0)}}]);\n//this is the beating heart of whatever plots the function,\n//I've changed this from being curve to functiongraph\n var line = board.create('functiongraph',[function(x){\nif(ans) {\n try {\nnscope.variables.x.value = x;\n var val = Numbas.jme.evaluate(ans,nscope).value;\n return val;\n }\n catch(e) {\nreturn 13;\n }\n}\nelse\n return 13;\n },-12,12]\n , {strokeColor:\"blue\",strokeWidth: 4} );\n \nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: false, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\nquestion.lines = {\n l:line, c:correct_line\n}\n\n $('body').on('question-html-attached',function(e,question,qd) {\nko.computed(function(){\nvar expr = question.parts[2].gaps[0].display.studentAnswer();\n\n//define ans as this \ntry {\n ans = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n ans = null;\n}\nline.updateCurve();\ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "type": "html", "parameters": []}, "correctPoints": {"definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n\nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: true, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\n\n\n$('body').on('question-html-attached',function(e,question,qd) {\nko.computed(function(){\n//define ans as this \ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "type": "html", "parameters": []}}, "ungrouped_variables": ["xa", "xb", "ya", "yb", "m", "c"], "advice": "

We find the equation of a straight line passing through two points by finding the gradient and the $y$-intercept of the line.

\n

#### a)

\n

We can find the gradient ($m$) using the points $A = (x_1,y_1)=(\\var{xa},\\var{ya})$ and $B = (x_2,y_2)=(\\var{xb},\\var{yb})$.

\n

As the definition of gradient is the ratio of vertical change ($y_2-y_1$) to horizontal change ($x_2-x_1$).

\n

\\begin{align}
m &= \\frac{y_2-y_1}{x_2-x_1} \\\0.5em] &= \\frac{\\simplify[!collectNumbers]{{yb}-{ya}}}{\\simplify[!collectNumbers]{{xb}-{xa}}} \\\\[0.5em] &= \\frac{\\simplify[]{{yb}-{ya}}}{\\simplify{{xb}-{xa}}} \\\\[0.5em] &= \\simplify[simplifyFractions,unitDenominator]{({yb-ya})/({xb-xa})}\\text{.} \\end{align} \n #### b) \n Rearranging the equation y=mx+c and substituting either of the points gives \n \\[c = y_1-mx_1 \\quad \\mathrm{or} \\quad c = y_2-mx_2 \\,\\text{.} \

\n

We can then also use this equation with the other point's coordinates to check our answer.

\n

Let's use point $A$ first:

\n

\\\begin{align} c &= y_1-mx_1 \\\\ &= \\var{ya}-\\var[fractionnumbers]{m}\\times\\var{xa} \\\\ & = \\simplify[fractionnumbers]{{ya-m*xa}}\\text{.} \\end{align} \

\n

We then check this against point $B$:

\n

\\\begin{align} y_2 &= mx_2 + c \\\\[0.5em] &= \\simplify[fractionNumbers]{{m}{xb}+{c}} \\\\[0.5em] &= \\var[fractionnumbers]{m*xb+c}\\text{.} \\end{align} \

\n

#### c)

\n

We can now substitute these values for $m$ and $c$ into $y=mx+c$  to get:

\n

\$y=\\simplify[!noLeadingMinus,fractionNumbers,unitFactor]{{m} x+ {c}}\\text{.}\$

\n

The green line drawn on the graph represents the above line equation.

\n

{correctPoints()}

", "parts": [{"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "m", "variableReplacements": [], "unitTests": [], "showFeedbackIcon": true, "allowFractions": true, "mustBeReduced": false, "minValue": "m", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": true}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Calculate the gradient, $m$, of the straight line between these two points.

\n

$m=$ [[0]]

\n

", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "c", "variableReplacements": [], "unitTests": [], "showFeedbackIcon": true, "allowFractions": false, "mustBeReduced": false, "minValue": "c", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": false}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Use this gradient and the coordinates of the points to calculate the $y$-intercept, $c$.

\n

$c=$ [[0]]

", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"answer": "{m}*x+{c}", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "checkingAccuracy": 0.001, "vsetRangePoints": 5, "extendBaseMarkingAlgorithm": true, "checkVariableNames": true, "variableReplacements": [], "unitTests": [], "marks": 1, "vsetRange": [0, 1], "showCorrectAnswer": true, "checkingType": "absdiff", "notallowed": {"showStrings": false, "strings": ["c", "m"], "partialCredit": 0, "message": "

You must input your answer in the form y = mx +c where m and c are numbers.

"}, "expectedVariableNames": ["x"], "type": "jme", "scripts": {}, "customMarkingAlgorithm": "", "failureRate": 1, "answerSimplification": "fractionNumbers", "showPreview": true}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {"mark": {"script": "this.question.lines.l.setAttribute({strokeColor: this.credit==1 ? 'green' : 'red'});\nthis.question.lines.c.setAttribute({visible: this.credit==1});\n", "order": "after"}}, "prompt": "

Give the equation of the straight line through these points in the form $y=mx+c$.

\n

$\\displaystyle y=$ [[0]]

\n

Use the graph to plot your answer and check that it goes through these points.

", "customMarkingAlgorithm": ""}], "rulesets": {}, "preamble": {"js": "", "css": ""}, "metadata": {"description": "

Use two points on a line graph to calculate the gradient and $y$-intercept and hence the equation of the straight line running through both points.

\n

The answer box for the third part plots the function which allows the student to check their answer against the graph before submitting.

\n

This particular example has a positive gradient.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

In this question we will identify the equation of the straight line passing through points  $A=(\\var{xa},\\var{ya})$ and  $B=(\\var{xb},\\var{yb})$ in the form $y = mx + c$.

\n

{plotPoints()}

", "variable_groups": [], "type": "question", "variables": {"m": {"templateType": "anything", "definition": "(ya-yb)/(xa-xb)", "group": "Ungrouped variables", "description": "", "name": "m"}, "xa": {"templateType": "anything", "definition": "random(-4..-1)", "group": "Ungrouped variables", "description": "", "name": "xa"}, "ya": {"templateType": "anything", "definition": "random(-4..2)", "group": "Ungrouped variables", "description": "", "name": "ya"}, "xb": {"templateType": "anything", "definition": "xa+random([2,4] except -xa)", "group": "Ungrouped variables", "description": "", "name": "xb"}, "yb": {"templateType": "anything", "definition": "ya+random([2,4])", "group": "Ungrouped variables", "description": "", "name": "yb"}, "c": {"templateType": "anything", "definition": "ya-m*xa", "group": "Ungrouped variables", "description": "", "name": "c"}}}, {"name": "Linear Equations - Find the equation of a line through two points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/", "name": "Chris Graham"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1521/", "name": "Bradley Bush"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1592/", "name": "Aiden McCall"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1738/", "name": "Paul Hancock"}], "tags": [], "variablesTest": {"condition": "\n", "maxRuns": 100}, "functions": {"plotPoints": {"definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n var ans;\n var nscope = new Numbas.jme.Scope([scope,{variables:{x:new Numbas.jme.types.TNum(0)}}]);\n//this is the beating heart of whatever plots the function,\n//I've changed this from being curve to functiongraph\n var line = board.create('functiongraph',[function(x){\nif(ans) {\n try {\nnscope.variables.x.value = x;\n var val = Numbas.jme.evaluate(ans,nscope).value;\n return val;\n }\n catch(e) {\nreturn 13;\n }\n}\nelse\n return 13;\n },-12,12]\n , {strokeColor:\"blue\",strokeWidth: 4} );\n \nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: false, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\nquestion.lines = {\n l:line, c:correct_line\n}\n\n $('body').on('question-html-attached',function(e,question,qd) {\nko.computed(function(){\nvar expr = question.parts[2].gaps[0].display.studentAnswer();\n\n//define ans as this \ntry {\n ans = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n ans = null;\n}\nline.updateCurve();\ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "type": "html", "parameters": []}, "correctPoints": {"definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n\nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: true, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\n\n\n$('body').on('question-html-attached',function(e,question,qd) {\nko.computed(function(){\n//define ans as this \ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "type": "html", "parameters": []}}, "ungrouped_variables": ["xa", "xb", "ya", "yb", "m", "c"], "advice": "

We find the equation of a straight line passing through two points by finding the gradient and the $y$-intercept of the line.

\n

#### a)

\n

We can find the gradient ($m$) using the points $A = (x_1,y_1)=(\\var{xa},\\var{ya})$ and $B = (x_2,y_2)=(\\var{xb},\\var{yb})$.

\n

As the definition of gradient is the ratio of vertical change ($y_2-y_1$) to horizontal change ($x_2-x_1$).

\n

\\begin{align}
m &= \\frac{y_2-y_1}{x_2-x_1} \\\0.5em] &= \\frac{\\simplify[!collectNumbers]{{yb}-{ya}}}{\\simplify[!collectNumbers]{{xb}-{xa}}} \\\\[0.5em] &= \\frac{\\simplify[]{{yb}-{ya}}}{\\simplify{{xb}-{xa}}} \\\\[0.5em] &= \\simplify[simplifyFractions,unitDenominator]{({yb-ya})/({xb-xa})}\\text{.} \\end{align} \n #### b) \n Rearranging the equation y=mx+c and substituting either of the points gives \n \\[c = y_1-mx_1 \\quad \\mathrm{or} \\quad c = y_2-mx_2 \\,\\text{.} \

\n

We can then also use this equation with the other point's coordinates to check our answer.

\n

Let's use point $A$ first:

\n

\\\begin{align} c &= y_1-mx_1 \\\\ &= \\var{ya}-\\var[fractionnumbers]{m}\\times\\var{xa} \\\\ & = \\simplify[fractionnumbers]{{ya-m*xa}}\\text{.} \\end{align} \

\n

We then check this against point $B$:

\n

\\\begin{align} y_2 &= mx_2 + c \\\\[0.5em] &= \\simplify[fractionNumbers]{{m}{xb}+{c}} \\\\[0.5em] &= \\var[fractionnumbers]{m*xb+c}\\text{.} \\end{align} \

\n

#### c)

\n

We can now substitute these values for $m$ and $c$ into $y=mx+c$  to get:

\n

\$y=\\simplify[!noLeadingMinus,fractionNumbers,unitFactor]{{m} x+ {c}}\\text{.}\$

\n

The green line drawn on the graph represents the above line equation.

\n

{correctPoints()}

", "parts": [{"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "m", "variableReplacements": [], "unitTests": [], "showFeedbackIcon": true, "allowFractions": true, "mustBeReduced": false, "minValue": "m", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": true}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Calculate the gradient, $m$, of the straight line between these two points.

\n

$m=$ [[0]]

\n

", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "c", "variableReplacements": [], "unitTests": [], "showFeedbackIcon": true, "allowFractions": false, "mustBeReduced": false, "minValue": "c", "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "correctAnswerFraction": false}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {}, "prompt": "

Use this gradient and the coordinates of the points to calculate the $y$-intercept, $c$.

\n

$c=$ [[0]]

", "customMarkingAlgorithm": ""}, {"variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "unitTests": [], "marks": 0, "gaps": [{"answer": "{m}*x+{c}", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "checkingAccuracy": 0.001, "vsetRangePoints": 5, "extendBaseMarkingAlgorithm": true, "checkVariableNames": true, "variableReplacements": [], "unitTests": [], "marks": 1, "vsetRange": [0, 1], "showCorrectAnswer": true, "checkingType": "absdiff", "notallowed": {"showStrings": false, "strings": ["c", "m"], "partialCredit": 0, "message": "

You must input your answer in the form y = mx +c where m and c are numbers.

"}, "expectedVariableNames": ["x"], "type": "jme", "scripts": {}, "customMarkingAlgorithm": "", "failureRate": 1, "answerSimplification": "fractionNumbers", "showPreview": true}], "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "scripts": {"mark": {"script": "this.question.lines.l.setAttribute({strokeColor: this.credit==1 ? 'green' : 'red'});\nthis.question.lines.c.setAttribute({visible: this.credit==1});\n", "order": "after"}}, "prompt": "

Give the equation of the straight line through these points in the form $y=mx+c$.

\n

$\\displaystyle y=$ [[0]]

\n

Use the graph to plot your answer and check that it goes through these points.

", "customMarkingAlgorithm": ""}], "rulesets": {}, "preamble": {"js": "", "css": ""}, "metadata": {"description": "

Use two points on a line graph to calculate the gradient and $y$-intercept and hence the equation of the straight line running through both points.

\n

The answer box for the third part plots the function which allows the student to check their answer against the graph before submitting.

\n

This particular example has a positive gradient.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

In this question we will identify the equation of the straight line passing through points  $A=(\\var{xa},\\var{ya})$ and  $B=(\\var{xb},\\var{yb})$ in the form $y = mx + c$.

\n

{plotPoints()}

", "variable_groups": [], "type": "question", "variables": {"m": {"templateType": "anything", "definition": "(ya-yb)/(xa-xb)", "group": "Ungrouped variables", "description": "", "name": "m"}, "xa": {"templateType": "anything", "definition": "random(-4..-1)", "group": "Ungrouped variables", "description": "", "name": "xa"}, "ya": {"templateType": "anything", "definition": "random(-4..2)", "group": "Ungrouped variables", "description": "", "name": "ya"}, "xb": {"templateType": "anything", "definition": "xa+random([2,4] except -xa)", "group": "Ungrouped variables", "description": "", "name": "xb"}, "yb": {"templateType": "anything", "definition": "ya+random([2,4])", "group": "Ungrouped variables", "description": "", "name": "yb"}, "c": {"templateType": "anything", "definition": "ya-m*xa", "group": "Ungrouped variables", "description": "", "name": "c"}}}], "pickingStrategy": "all-shuffled", "name": "Group", "pickQuestions": 1}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/", "name": "Michael Proudman"}], "metadata": {"description": "", "licence": "None specified"}, "duration": 0, "navigation": {"showresultspage": "oncompletion", "allowregen": true, "onleave": {"action": "none", "message": ""}, "startpassword": "", "showfrontpage": true, "preventleave": true, "browse": true, "reverse": true}, "extensions": ["jsxgraph"]}