// Numbas version: exam_results_page_options {"name": "Sp\u00f8rsm\u00e5l 1", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variables": {"c": {"definition": "ya-m*xa", "name": "c", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "xa": {"definition": "random(-4..-1)", "name": "xa", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "xb": {"definition": "xa+random([2,4] except -xa)", "name": "xb", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "m": {"definition": "(ya-yb)/(xa-xb)", "name": "m", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "yb": {"definition": "ya+random([2,4])", "name": "yb", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "ya": {"definition": "random(-4..2)", "name": "ya", "description": "", "templateType": "anything", "group": "Ungrouped variables"}}, "statement": "

En rett linje går gjennom de to punktene med koordinatene $A=(\\var{xa},\\var{ya})$ og  $B=(\\var{xb},\\var{yb})$.

\n

{plotPoints()}

\n

", "variablesTest": {"condition": "\n", "maxRuns": 100}, "rulesets": {}, "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"}, "name": "Sp\u00f8rsm\u00e5l 1", "extensions": ["jsxgraph"], "advice": "

Vi finner ekvasjonen for ei rett linje gjennom å først finne stigningstallet til linja.

\n

a)

\n

Vi finner stigningstallet ($a$) ved å bruke punktene $A = (x_1,y_1)=(\\var{xa},\\var{ya})$ og $B = (x_2,y_2)=(\\var{xb},\\var{yb})$.

\n

Vi får da

\n

\\begin{align}
a &= \\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

Sett nå in stigningstallet og et av punktene i ettpunktsfoemelen. 

\n

\n

", "preamble": {"js": "", "css": ""}, "tags": [], "functions": {"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\nquestion.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\n//define ans as this \ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "language": "javascript", "parameters": [], "type": "html"}, "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 question.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\nvar expr = question.parts[1].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", "parameters": [], "type": "html"}}, "ungrouped_variables": ["xa", "xb", "ya", "yb", "m", "c"], "parts": [{"gaps": [{"variableReplacementStrategy": "originalfirst", "maxValue": "m", "showFeedbackIcon": true, "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": true, "scripts": {}, "showCorrectAnswer": true, "customMarkingAlgorithm": "", "minValue": "m", "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "allowFractions": true, "mustBeReducedPC": 0}], "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "scripts": {}, "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 0, "type": "gapfill", "prompt": "

Stigningstallet $a$ til en linje gjennom to punkter $(x_{1},y_{1})$ og $(x_{2},y_{2})$ er gitt ved

\n

$ a=\\frac{y_{2}-y_{1}}{x_{2}-x_{1}}$. Finn stigningstallet til linja ved bruk av punktene som er gitt i grafen. 

\n

$a=$ [[0]]

\n

"}, {"gaps": [{"variableReplacementStrategy": "originalfirst", "vsetRange": [0, 1], "checkingType": "absdiff", "checkingAccuracy": 0.001, "showFeedbackIcon": true, "variableReplacements": [], "answer": "{m}*x+{c}", "scripts": {}, "showCorrectAnswer": true, "customMarkingAlgorithm": "", "answerSimplification": "fractionNumbers", "failureRate": 1, "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 1, "type": "jme", "showPreview": true, "notallowed": {"strings": ["c", "m"], "message": "

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

", "showStrings": false, "partialCredit": 0}, "checkVariableNames": true, "expectedVariableNames": ["x"], "vsetRangePoints": 5}], "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "scripts": {"mark": {"order": "after", "script": "this.question.lines.l.setAttribute({strokeColor: this.credit==1 ? 'green' : 'red'});\nthis.question.lines.c.setAttribute({visible: this.credit==1});\n"}}, "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 0, "type": "gapfill", "prompt": "

Ei rett linje som går gjennom punktet $(x_{1},y_{1})$ og har stigningstallet $a$, er gitt ved likninga

\n

$ y-y_{1}=a(x-x_{1}) $.

\n

Finn likninga for linja i grafen ovenfor. Skriv svaret på formen $y=ax+b$

\n

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

"}], "variable_groups": [], "type": "question", "contributors": [{"name": "Ida Landg\u00e4rds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2336/"}]}]}], "contributors": [{"name": "Ida Landg\u00e4rds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2336/"}]}