// Numbas version: exam_results_page_options {"name": "Terry's copy of Straight lines: graphing y=mx+b by finding some points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "", "showQuestionGroupNames": false, "variable_groups": [], "functions": {"twopoints": {"definition": "\nvar div = Numbas.extensions.jsxgraph.makeBoard('600px','600px',{boundingBox:[-13,13,13,-13],grid:true,axis:false});\nvar board = div.board;\n\n// create the x-axis.\nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true});\nvar xticks = board.create('ticks',[xaxis,2],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n});\n\n// create the y-axis\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true });\nvar yticks = board.create('ticks',[yaxis,2],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n});\n\n\nvar x1 = 0;\nvar y1 = 0;\nvar x2 = 2;\nvar y2 = 0;\n\n\n\nvar a = board.create('point',[x1,y1],{name:'$y$ int',snapSizeX:1,snapSizeY:1,snapToGrid:true,showInfobox:false});\na.on('drag',function(){\n var x1 = Numbas.math.niceNumber(a.X());\n var y1 = Numbas.math.niceNumber(a.Y());\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(x1);//could just have x instead of a.X()\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(y1);\n});\n\nvar b = board.create('point',[x2,y2],{name:'next nice point',snapSizeX:1,snapSizeY:1,snapToGrid:true,showInfobox:false});\nb.on('drag',function(){\n var x2 = Numbas.math.niceNumber(b.X());\n var y2 = Numbas.math.niceNumber(b.Y());\n Numbas.exam.currentQuestion.parts[0].gaps[2].display.studentAnswer(x2);//could just have x instead of a.X()\n Numbas.exam.currentQuestion.parts[0].gaps[3].display.studentAnswer(y2);\n});\n\n\nvar line = board.create('line',[a,b], {strokeColor:'#00ff00',strokeWidth:2});\n\n\nquestion.signals.on('HTMLAttached',function(e) {\n ko.computed(function(){ \n var x1 = parseFloat(question.parts[0].gaps[0].display.studentAnswer());\n var y1 = parseFloat(question.parts[0].gaps[1].display.studentAnswer());\n if(!(isNaN(x1) || isNaN(y1)) && board.mode!=board.BOARD_MODE_DRAG) {\n a.moveTo([x1,y1],100);//what does the 100 do?\n }\n var x2 = parseFloat(question.parts[0].gaps[2].display.studentAnswer());\n var y2 = parseFloat(question.parts[0].gaps[3].display.studentAnswer());\n if(!(isNaN(x2) || isNaN(y2)) && board.mode!=board.BOARD_MODE_DRAG) {\n b.moveTo([x2,y2],100);//what does the 100 do?\n } \n });\n});\n\nreturn div;\n\n", "language": "javascript", "type": "html", "parameters": []}, "tableofvalues": {"definition": "\nvar div = Numbas.extensions.jsxgraph.makeBoard('600px','600px',{boundingBox:[-13,13,13,-13],grid:true,axis:false});\nvar board = div.board;\n\n// create the x-axis.\nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true});\nvar xticks = board.create('ticks',[xaxis,2],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n});\n\n// create the y-axis\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true });\nvar yticks = board.create('ticks',[yaxis,2],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n});\n\n\nvar y0 = 0;\nvar y1 = 0;\nvar y2 = 0;\n\nvar glide0 = board.create('line',[[0,0],[0,1]],{visible: false});\nvar glide1 = board.create('line',[[1,0],[1,1]],{visible: false});\nvar glide2 = board.create('line',[[2,0],[2,1]],{visible: false});\n\nvar a = board.create('glider',[0,0,glide0],{name:'',showInfobox:false,snapSizeX:.01,snapSizeY:.01,snapToGrid:true});\na.on('drag',function(){\n var y0 = Numbas.math.niceNumber(a.Y());\n Numbas.exam.currentQuestion.parts[1].gaps[0].display.studentAnswer(y0);\n});\n\nvar b = board.create('glider',[0,1,glide1],{name:'',showInfobox:false,snapSizeX:.01,snapSizeY:.01,snapToGrid:true});\nb.on('drag',function(){\n var y1 = Numbas.math.niceNumber(b.Y());\n Numbas.exam.currentQuestion.parts[1].gaps[1].display.studentAnswer(y1);\n});\n\nvar c = board.create('glider',[0,2,glide2],{name:'',showInfobox:false,snapSizeX:.01,snapSizeY:.01,snapToGrid:true});\nc.on('drag',function(){\n var y2 = Numbas.math.niceNumber(c.Y());\n Numbas.exam.currentQuestion.parts[1].gaps[2].display.studentAnswer(y2);\n});\n\n\nvar lineab = board.create('line',[a,b],{strokeWidth:2,strokeColor:'#00ff00',straightLast:false});\nvar linebc = board.create('line',[b,c],{strokeWidth:2,strokeColor:'#00ff00',straightFirst:false});\n\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\nquestion.signals.on('HTMLAttached',function(e) {\n ko.computed(function(){ \n var y0 = evaluate(question.parts[1].gaps[0].display.studentAnswer());\n if(!(isNaN(y0)) && board.mode!=board.BOARD_MODE_DRAG) {\n a.moveTo([0,y0],100);//what does the 100 do?\n }\n var y1 = evaluate(question.parts[1].gaps[1].display.studentAnswer());\n if(!(isNaN(y1)) && board.mode!=board.BOARD_MODE_DRAG) {\n b.moveTo([0,y1],100);//what does the 100 do?\n }\n var y2 = evaluate(question.parts[1].gaps[2].display.studentAnswer());\n if(!(isNaN(y2)) && board.mode!=board.BOARD_MODE_DRAG) {\n c.moveTo([0,y2],100);//what does the 100 do?\n } \n });\n});\n\nreturn div;\n\n", "language": "javascript", "type": "html", "parameters": []}}, "rulesets": {}, "parts": [{"stepsPenalty": 0, "steps": [{"marks": 0, "prompt": "

Following the written instructions above. You can drag the points on the graph to help determine the coordinates.

", "scripts": {}, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "information", "showCorrectAnswer": true}], "prompt": "

In sketching or graphing a straight line, we only need to plot two points and then draw the straight line through them. Any two points will do, but it is easier to plot when the coordinates are whole numbers.

\n

One method is to find the $y$-intercept and then use the gradient to find another \"nice\" point. 

\n

\n

Given the equation $y=\\simplify{{rise}/{run} x +{b}}$ the $y$-intercept gives us the coordinates $\\bigg($[[0]], [[1]]$\\bigg)$, then by going up {rise} and across {run} (that is, using the gradient) we get to the coordinates $\\bigg($[[2]], [[3]]$\\bigg)$.

\n

\n

{twopoints()}

\n

", "scripts": {}, "variableReplacementStrategy": "originalfirst", "marks": 0, "variableReplacements": [], "gaps": [{"correctAnswerFraction": false, "marks": 1, "scripts": {}, "minValue": "0", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "0", "allowFractions": false, "showPrecisionHint": false, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "marks": 1, "scripts": {}, "minValue": "{b}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "{b}", "allowFractions": false, "showPrecisionHint": false, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "marks": 1, "scripts": {}, "minValue": "{run}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "{run}", "allowFractions": false, "showPrecisionHint": false, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "marks": 1, "scripts": {}, "minValue": "{rise+b}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "{rise+b}", "allowFractions": false, "showPrecisionHint": false, "showCorrectAnswer": true}], "type": "gapfill", "showCorrectAnswer": true}, {"stepsPenalty": 0, "steps": [{"marks": 0, "prompt": "

Take the values of $x$ provided in the table and substitute them into the equation for $y$. Put each $y$ value in the table under the corresponding $x$ value. Once you are finished the points on the graph should form a straight line.  If they don't it is likely some of your values are incorrect.

\n

\n
\n

\n

For example, say you have $y=\\frac{2}{3}x-1$, and we need to fill in the following table of values

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$x$012
$y$                     
\n

\n

We take $x=0$ and substitute it into $y=\\frac{2}{3}x-1$ and get $y=\\frac{2}{3}\\times 0 -1=-1$.

\n

We take $x=1$ and substitute it into $y=\\frac{2}{3}x-1$ and get $y=\\frac{2}{3}\\times 1 -1=-\\frac{1}{3}$.

\n

We take $x=2$ and substitute it into $y=\\frac{2}{3}x-1$ and get $y=\\frac{2}{3}\\times 2 -1=\\frac{1}{3}$.

So we fill the table out as shown:

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$x$012
$y$   -1        -1/3        1/3    
\n

", "scripts": {}, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "information", "showCorrectAnswer": true}], "prompt": "

Another common method (to find points on a line) is to use a table of values.

\n

\n

Given the equation $y=\\simplify{{rise1}/{run1} x+ {b1}}$ fill in the table of values:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$x$012
$y$[[0]][[1]][[2]]
\n

Notice, with this approach we are more likely to get fractions (which are often a bit harder to plot).

\n

{tableofvalues()}

", "scripts": {}, "variableReplacementStrategy": "originalfirst", "marks": 0, "variableReplacements": [], "gaps": [{"correctAnswerFraction": true, "marks": 1, "scripts": {}, "minValue": "{b1}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "{b1}", "allowFractions": true, "showPrecisionHint": false, "showCorrectAnswer": true}, {"correctAnswerFraction": true, "marks": 1, "scripts": {}, "minValue": "{rise1}/{run1}+{b1}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "{rise1}/{run1}+{b1}", "allowFractions": true, "showPrecisionHint": false, "showCorrectAnswer": true}, {"correctAnswerFraction": true, "marks": 1, "scripts": {}, "minValue": "{2*rise1}/{run1}+{b1}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "type": "numberentry", "maxValue": "{2*rise1}/{run1}+{b1}", "allowFractions": true, "showPrecisionHint": false, "showCorrectAnswer": true}], "type": "gapfill", "showCorrectAnswer": true}], "metadata": {"description": "", "notes": "", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "preamble": {"js": "", "css": ""}, "advice": "", "variablesTest": {"maxRuns": 100, "condition": "\n"}, "ungrouped_variables": ["b", "run", "rise", "b1", "run1", "rise1"], "variables": {"run": {"definition": "random(2,3,5,7)", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "run"}, "run1": {"definition": "random(2,3,5,7)", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "run1"}, "b": {"definition": "random(-12..5 except 0)", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "b"}, "b1": {"definition": "random(-12..12 except 0)", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "b1"}, "rise": {"definition": "if(run=2,random(1,3,5,7),if(run=3,random(1,2,4,5,7),if(run=5,random(1,2,3,4,6,7),if(run=7,random(1,2,3,4,5,6)))))", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "rise"}, "rise1": {"definition": "if(run1=2,random(1,3,5,7,9,11),if(run1=3,random(1,2,4,5,7,8,10),if(run1=5,random(1,2,3,4,6,7,8,9),if(run1=7,random(1,2,3,4,5,6,8,9,10,11)))))", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "rise1"}}, "tags": ["gradient intercept", "graphing straight lines", "linear", "plotting points", "straight lines", "table of values"], "name": "Terry's copy of Straight lines: graphing y=mx+b by finding some points", "type": "question", "question_groups": [{"questions": [], "pickingStrategy": "all-ordered", "pickQuestions": 0, "name": ""}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Terry Young", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3130/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Terry Young", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3130/"}]}