// Numbas version: finer_feedback_settings {"name": "Santa's elves equation of a straight line", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": ""}, "parts": [{"type": "gapfill", "variableReplacements": [], "gaps": [{"allowFractions": false, "variableReplacementStrategy": "originalfirst", "mustBeReducedPC": 0, "showFeedbackIcon": true, "marks": 1, "maxValue": "11*m+c", "minValue": "11*m+c", "notationStyles": ["plain", "en", "si-en"], "mustBeReduced": false, "correctAnswerStyle": "plain", "variableReplacements": [], "showCorrectAnswer": true, "scripts": {}, "correctAnswerFraction": false, "type": "numberentry"}], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "showFeedbackIcon": true, "marks": 0, "prompt": "

There are roughly 11 million children in the UK. How many elves does Santa need?

\n

[[0]] elves

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

The equation of a straight line is traditionally written

\n

\\[ y = mx+c\\text{,}\\]

\n

where $m$ is the gradient of the line, and $c$ the intercept with the y axis.

\n

In our case, the variables are labelled $E$ and $n$ (rather than $y$ and $x$ respectively). The intercept $c$ is the number of elves required for $0$ children, i.e. the base number, $\\var{c}$. And the gradient $m$ is the number of elves required for each unit $n$, which is given as $\\var{m}$.

\n

", "scripts": {}}], "type": "gapfill", "variableReplacements": [], "gaps": [{"checkingaccuracy": 0.001, "type": "jme", "vsetrange": [0, 1], "checkingtype": "absdiff", "scripts": {}, "showFeedbackIcon": true, "answer": "{m}*n+{c}", "marks": "2", "checkvariablenames": true, "vsetrangepoints": 5, "variableReplacements": [], "expectedvariablenames": ["n"], "showCorrectAnswer": true, "showpreview": true, "variableReplacementStrategy": "originalfirst"}], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "stepsPenalty": 0, "showFeedbackIcon": true, "marks": 0, "prompt": "

Santa makes a plot of the number of elves he requires, $E$, against the number of children, $n$ (in units of million children):

\n

{graphsolution()}

\n

What is the equation of the line?

\n

$E(n)=$ [[0]]

", "scripts": {}}], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"c": {"definition": "random(30..60#10)", "templateType": "anything", "name": "c", "group": "Ungrouped variables", "description": ""}, "m": {"definition": "random(15..30#5)", "templateType": "anything", "name": "m", "group": "Ungrouped variables", "description": ""}}, "name": "Santa's elves equation of a straight line", "extensions": ["jsxgraph"], "ungrouped_variables": ["c", "m"], "preamble": {"css": "", "js": ""}, "advice": "

a)

\n

The number of elves Santa requires is

\n

\\[ ({m}\\times 11) + {c} \\text{.}\\]  

\n

b)

\n

The equation of a straight line is traditionally written

\n

\\[ y = mx+c\\text{,}\\]

\n

where $m$ is the gradient of the line, and $c$ the intercept with the y axis.

\n

In our case, the variables are labelled $E$ and $n$ (rather than $y$ and $x$ respectively). The intercept $c$ is the number of elves required for $0$ children, i.e. the base number, $\\var{c}$. And the gradient $m$ is the number of elves required for each unit $n$, which is given as $\\var{m}$.

\n

Therefore the equation of Santa's line is

\n

\\[ E(n) = \\var{m}x + \\var{c}\\text{.}\\]

\n

To learn more about the equation of a straight line, here is Professor Robin Johnson solving a slightly trickier problem:

\n

", "statement": "

Note that this question is randomised, including the graph (try clicking \"Try another question like this one\"), and that you get a preview of the answer when you type in an expression. One more thing: the correct answer is written in terms of the variable n, go on try a different letter, like x, it separates the validation from the marking to help you out.

\n
\n

Santa is reviewing the personnel requirements for the North Pole's UK division. He requires {c} elves to do the basic administrative jobs, plus {m} elves for every 1 million children, to manage toy making and the like.

\n

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "functions": {"graphsolution": {"definition": "JXG.Options.layer['curve'] = 9;\nJXG.Options.layer['line'] = 7;\n\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n {boundingBox:[-0.7,12*m+c,13,-45],\n axis:false,\n showNavigation:false,\n grid:false});\nvar brd = div.board; \nxaxis = brd.create('axis', [[0, 0], [1,0]], \n\t\t {name:'$$n$$', \n strokeColor: 'black',\n fixed: true,\n withLabel: true,\n label: {position: 'rt', offset: [0, -15], fontSize: 17}\n\t\t\t});\nyaxis = brd.create('axis', [[0, 0], [0, 1]], \n\t\t {name:'$$E$$', \n strokeColor: 'black',\n fixed: true,\n\t\t withLabel: true,\n label: {position: 'rt', offset: [-20, 0], fontSize: 17}\n\t\t\t});\t\n\nvar q=brd.create('line',[[0,c],[10,c+(m*10)]],{fixed:true,strokeColor:'blue',strokeWidth:2,straightFirst:false});\nvar tree;\n//n is the variable in the equation to be input\n var nscope = new Numbas.jme.Scope([scope,{variables:{n:new Numbas.jme.types.TNum(0)}}]);\n//create a functiongraph from the student input\nfunction userf(n){\nif(tree) {\n try {\nnscope.variables.n.value = n;\n var val = Numbas.jme.evaluate(tree,nscope).value;\n return val;\n }\n catch(e) {\nreturn 0;\n }\n}\nelse\n return -100;\n}\nvar curve=brd.create('functiongraph',[userf,0,12],{strokeColor:'red',strokeWidth:2,dash:2});\n\n //pick up the student answer and is parsed\n question.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\nvar expr = question.parts[1].gaps[0].display.studentAnswer();\ntry {\n tree = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n tree = null;\n}\ncurve.updateCurve();\n\nbrd.update();\n});\n }); \n\nreturn div;\n ", "language": "javascript", "type": "html", "parameters": []}}, "tags": [], "variable_groups": [], "type": "question", "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}]}]}], "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}]}