// Numbas version: exam_results_page_options {"name": "Q4 Gradient intercept form of a line", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"eqnline": {"definition": "// This function creates the board and sets it up, then returns an\n// HTML div tag containing the board.\n \n// The line is described by the equation \n// y = a*x + b\n\n// This function takes as its parameters the coefficients a and b,\n// and the coordinates (x2,y2) of a point on the line.\n\n// First, make the JSXGraph board.\n// The function provided by the JSXGraph extension wraps the board up in \n// a div tag so that it's easier to embed in the page.\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n{boundingBox: [-11,11,11,-11],\n axis: false,\n showNavigation: false,\n grid: true\n});\n \n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\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// create the static line based on the coefficients a and b\n//var line1 = board.create('line',[[0,b],[1,a+b]],{fixed:true, strokeWidth: 1});\n\n// mark the two given points - one on the y-axis, and one at (x2,y2)\n//var p1 = board.create('point',[0,b],{fixed:true, size:3, name: 'P_1', face: 'cross'});\n//var p2 = board.create('point',[x2,y2],{fixed:true, size:3, name: 'P_2', face: 'cross'});\n\n// Now we can do the clever stuff with the student's answer!\n// We'll add a curve to the board which is a plot of a function we provide.\n// That function will parse the student's input and evaluate it.\n\n// The variable `studentExpression` will store the parsed version of\n// the student's expression.\nvar studentExpression;\n\n// This function evaluates the student's expression at a given point `t`.\nfunction makestudentline(x){\n // Create a JME scope with the variable x set to the given value.\n var nscope = new Numbas.jme.Scope([\nNumbas.jme.builtinScope,\n{variables: {x: new Numbas.jme.types.TNum(x)}}\n ]);\n \n // If the student's input has been parsed, evaluate it\n if(studentExpression) {\ntry {\n var val = Numbas.jme.evaluate(studentExpression,nscope).value;\n return val;\n}\ncatch(e) {\n // If there was an error evaluating the student's expression\n // (wrong variables, or some other weirdness)\n // throw an error\n throw(e)\n}\n }\n // Otherwise, if the student's expression hasn't been parsed\n // (they haven't written anything, or they wrote bad syntax)\n // return 0\n else {\nreturn 0;\n }\n}\nvar studentline = board.create('functiongraph', \n [makestudentline,-11,11],\n {strokeColor:'#00ff00',strokeWidth:2, visible: false}\n );\n\n// This is where some voodoo happens.\n// Because the HTML for the question is inserted into the page after the function eqnline\n// is called, we need to wait until the 'question-html-attached' event is fired\n// to do the interaction with the student input box.\n// So:\n\n// When the question is inserted into the page\nquestion.signals.on('HTMLAttached',function(e) {\n \n // Create a Knockout.js observable\n ko.computed(function(){\n// Get the student's input string from part 0, gap 0.\nvar studentString = question.parts[q].gaps[0].display.studentAnswer();\n\n// Try to parse it as a JME expression\ntry {\n var issue = /[A-W]|[YZ]|[\\^]/i.test(studentString);\n if(issue===false) \n {studentExpression = Numbas.jme.compile(studentString,scope)}\n else{studentExpression = null;\n studentline.hideElement()};///////////////////\n \n \n // If the student didn't write anything, compile returns null\n if(studentExpression === null)\nthrow(new Error('no expression'));\n \n // If everything worked, show the line and update it\n // (this calls makestudentline on a few points)\n studentline.showElement();\n studentline.updateCurve();\n}\ncatch(e) {\n // If something went wrong, hide the curve\n studentExpression = null;\n studentline.hideElement();\n}\n\nboard.update();\n });\n}); \n\nreturn div;", "type": "html", "parameters": [["q", "number"]], "language": "javascript"}}, "ungrouped_variables": ["m1", "b1", "m2", "b2", "m3", "b3"], "name": "Q4 Gradient intercept form of a line", "tags": ["gradient", "intercept", "linear equation", "rebelmaths", "Straight Line", "straight line", "y=mx+b"], "advice": "

For $y=mx+b$, $m$ is the gradient and $b$ is the $y$-intercept.

\n

\n
\n

\n

The gradient (or slope of the line) is

\n\n

The $y$-intercept is the value of $y$ that the line crosses the $y$-axis at. Since the $y$-axis is the line that corresponds to $x=0$, the $y$-intercept is the $y$-value when $x=0$.

\n

\n
\n

\n

For example, given the equation $y=\\frac{2}{3}x-4$, we can see that the gradient is $\\frac{2}{3}$ and the $y$-intercept is $-4$. This constant gradient of $\\frac{2}{3}$ means that for a run of 3 we need a rise of 2 to stay on the line. Note it also means that say if we run across 6, we need to rise by 4, since $\\frac{2}{3}=\\frac{4}{6}$.

", "rulesets": {}, "parts": [{"prompt": "

Find the equation of the line which passes through (0 , {b1}) and has a slope of {m1}.

\n

Write the answer in the form y = mx + b.

\n

$y=$ [[0]]

\n

The following is the graph of the equation that you entered:

\n

{eqnline(0)}

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"notallowed": {"message": "", "showStrings": false, "strings": ["sin", " cos", " exp", " "], "partialCredit": 0}, "variableReplacements": [], "expectedvariablenames": ["x"], "checkingaccuracy": 0.001, "type": "jme", "showpreview": true, "vsetrangepoints": 5, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "answersimplification": "all", "scripts": {}, "answer": "{m1}*x+{b1}", "marks": 1, "checkvariablenames": true, "checkingtype": "absdiff", "vsetrange": [0, 1]}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Find the equation of the line which passes through (0 , {b2}) and has a slope of {m2}.

\n

Write the answer in the form y = mx + b.

\n

$y=$ [[0]]

\n

The following is the graph of the equation that you entered:

\n

{eqnline(1)}

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"notallowed": {"message": "", "showStrings": false, "strings": ["sin", " cos", " exp", " "], "partialCredit": 0}, "variableReplacements": [], "expectedvariablenames": ["x"], "checkingaccuracy": 0.001, "type": "jme", "showpreview": true, "vsetrangepoints": 5, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "answersimplification": "all", "scripts": {}, "answer": "{m2}*x+{b2}", "marks": 1, "checkvariablenames": true, "checkingtype": "absdiff", "vsetrange": [0, 1]}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Find the equation of the line which passes through (0 , {b3}) and has a slope of {m3}.

\n

Write the answer in the form y = mx + b.

\n

$y=$ [[0]]

\n

The following is the graph of the equation that you entered:

\n

{eqnline(2)}

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"notallowed": {"message": "", "showStrings": false, "strings": ["sin", " cos", " exp", " "], "partialCredit": 0}, "variableReplacements": [], "expectedvariablenames": ["x"], "checkingaccuracy": 0.001, "type": "jme", "showpreview": true, "vsetrangepoints": 5, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "answersimplification": "all", "scripts": {}, "answer": "{m3}*x+{b3}", "marks": 1, "checkvariablenames": true, "checkingtype": "absdiff", "vsetrange": [0, 1]}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "statement": "", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"css": "", "js": ""}, "variables": {"b2": {"definition": "random(-10..10#0.25 except[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10])", "templateType": "anything", "group": "Ungrouped variables", "name": "b2", "description": ""}, "m2": {"definition": "random(-12.5..12.5#0.1 except [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10])", "templateType": "anything", "group": "Ungrouped variables", "name": "m2", "description": ""}, "m1": {"definition": "random(-12.5..12.5 except 0)", "templateType": "anything", "group": "Ungrouped variables", "name": "m1", "description": ""}, "b1": {"definition": "random(-10..10#0.1 except[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10])", "templateType": "anything", "group": "Ungrouped variables", "name": "b1", "description": ""}, "m3": {"definition": "random(-12.5..12.5#0.25 except [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10])", "templateType": "anything", "group": "Ungrouped variables", "name": "m3", "description": ""}, "b3": {"definition": "random(-10..10#0.1 except[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10])", "templateType": "anything", "group": "Ungrouped variables", "name": "b3", "description": ""}}, "metadata": {"notes": "", "description": "

Identifying gradient and $y$-intercept from $y=mx+b$.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "TEAME CIT", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/591/"}]}]}], "contributors": [{"name": "TEAME CIT", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/591/"}]}