// Numbas version: exam_results_page_options {"name": "Use an aswer to a mathematical expression part in a subsequent part", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variables": {"f": {"name": "f", "description": "", "definition": "poly_with_root(root)", "templateType": "anything", "group": "Ungrouped variables"}, "root": {"name": "root", "description": "", "definition": "random(-5..5)", "templateType": "anything", "group": "Ungrouped variables"}}, "type": "question", "statement": "", "name": "Use an aswer to a mathematical expression part in a subsequent part", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

This question asks the student to give a function with a particular root. It then asks them to divide by (x-{root}), and uses adaptive marking to mark against the previous answer.

\n

This uses the \"expression\" data type, which is currently undocumented and experimental.

"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "parts": [{"answer": "x-{a}", "checkingaccuracy": 0.001, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "vsetrangepoints": 5, "showCorrectAnswer": true, "prompt": "

Write a polynomial $f(x)$ of degree at least 2 which satisfies $\\simplify{f({root})} = 0$.

", "checkingtype": "absdiff", "type": "jme", "vsetrange": [0, 1], "checkvariablenames": false, "marks": "1", "expectedvariablenames": [], "showpreview": true, "scripts": {"mark": {"order": "instead", "script": "try {\n var expr = Numbas.jme.compile(this.studentAnswer);\n} catch(e) {\n this.answered = false;\n this.setCredit(0);\n return;\n}\nthis.answered = true;\nvar root_ok = Numbas.jme.builtinScope.evaluate(expr,{x:variables.root}).value == 0;\n\nvar v = [0,1,2].map(function(x){return Numbas.jme.builtinScope.evaluate(expr,{x:x}).value});\nvar non_linear = v[1]-v[0] != v[2]-v[1];\n\nif(root_ok) {\n this.addCredit(0.5,'Your function has a root at $x='+variables.root+'$.');\n}\nif(non_linear) {\n this.addCredit(0.5,'Your function has at least two real roots.');\n}\n"}}}, {"type": "gapfill", "scripts": {}, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showCorrectAnswer": true, "gaps": [{"answer": "({f})/(x-{root})", "checkingaccuracy": 0.001, "variableReplacements": [{"variable": "f", "must_go_first": true, "part": "p0"}], "variableReplacementStrategy": "originalfirst", "vsetrangepoints": 5, "showCorrectAnswer": true, "checkingtype": "absdiff", "type": "jme", "vsetrange": [0, 1], "checkvariablenames": false, "marks": 1, "expectedvariablenames": [], "showpreview": true, "scripts": {}}], "prompt": "

$\\simplify{ f(x)/(x-{root})} = $ [[0]]

", "marks": 0}], "showQuestionGroupNames": false, "functions": {"poly_with_root": {"type": "expression", "definition": "return Numbas.jme.compile('x-('+root+')');", "language": "javascript", "parameters": [["root", "number"]]}}, "tags": [], "variable_groups": [], "rulesets": {}, "ungrouped_variables": ["root", "f"], "preamble": {"css": "", "js": ""}, "advice": "", "question_groups": [{"name": "", "questions": [], "pickQuestions": 0, "pickingStrategy": "all-ordered"}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}