// Numbas version: exam_results_page_options {"name": "Denis's copy of Pattern matching - factorise an equation", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"extensions": [], "advice": "", "tags": [], "variables": {"b": {"definition": "random(-5..5 except 0)", "name": "b", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "a": {"definition": "random(-5..5)", "name": "a", "group": "Ungrouped variables", "description": "", "templateType": "anything"}}, "variable_groups": [], "functions": {}, "variablesTest": {"maxRuns": 100, "condition": ""}, "ungrouped_variables": ["a", "b"], "metadata": {"description": "

The student is asked to factorise a quadratic $x^2 + ax + b$. A custom marking script uses pattern matching to ensure that the student's answer is of the form $(x+a)(x+b)$, $(x+a)^2$, or $x(x+a)$.

\n

To find the script, look in the Scripts tab of part a.

", "licence": "Creative Commons Attribution 4.0 International"}, "preamble": {"css": "", "js": ""}, "parts": [{"type": "jme", "checkvariablenames": false, "vsetrange": [0, 1], "showFeedbackIcon": true, "checkingtype": "absdiff", "prompt": "

Factorise $\\simplify{x^2+{a+b}x+{a*b}}$

", "showpreview": true, "variableReplacements": [], "vsetrangepoints": 5, "expectedvariablenames": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "checkingaccuracy": 0.001, "answer": "(x+{a})(x+{b})", "marks": "1", "scripts": {"mark": {"script": "// Parse the student's answer as a syntax tree\nvar studentTree = Numbas.jme.compile(this.studentAnswer,Numbas.jme.builtinScope);\n\n// Create the pattern to match against \n// we just want two sets of brackets, each containing two terms\n// or one of the brackets might not have a constant term\n// or for repeated roots, you might write (x+a)^2\nvar rule = Numbas.jme.compile('m_any( (x+??)(x+??), (x+??)^2, x*(x+??) )');\n\n// Check the student's answer matches the pattern. \nvar m = Numbas.jme.display.matchTree(rule,studentTree,true);\n// If not, take away marks\nif(!m) {\n this.multCredit(0.5,'Your answer is not in the form $(\\\\dots)(\\\\dots)$.');\n}\n", "order": "after"}}}, {"type": "jme", "checkvariablenames": false, "vsetrange": [0, 1], "showFeedbackIcon": true, "checkingtype": "absdiff", "prompt": "

Factorise $\\simplify{x^2+{a+b}x+{a*b}}$

", "showpreview": true, "variableReplacements": [], "vsetrangepoints": 5, "expectedvariablenames": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "checkingaccuracy": 0.001, "answer": "(x+{a})(x+{b})", "marks": "1", "scripts": {"mark": {"script": "// Parse the student's answer as a syntax tree\nvar studentTree = Numbas.jme.compile(this.studentAnswer,Numbas.jme.builtinScope);\n\n// Create the pattern to match against \n// we just want two sets of brackets, each containing two terms\n// or one of the brackets might not have a constant term\n// or for repeated roots, you might write (x+a)^2\nvar rule = Numbas.jme.compile('m_any( (x+??)(x+??), (x+??)^2, x*(x+??) )');\n\n// Check the student's answer matches the pattern. \nvar m = Numbas.jme.display.matchTree(rule,studentTree,true);\n// If not, take away marks\nif(!m) {\n this.multCredit(0.5,'Your answer is not in the form $(\\\\dots)(\\\\dots)$.');\n}\n", "order": "after"}}}], "rulesets": {}, "name": "Denis's copy of Pattern matching - factorise an equation", "statement": "", "type": "question", "contributors": [{"name": "Denis Flynn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1216/"}]}]}], "contributors": [{"name": "Denis Flynn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1216/"}]}