// Numbas version: exam_results_page_options {"name": "Pattern matching - student's answer is a fraction", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"type": "question", "variables": {"b": {"name": "b", "description": "", "templateType": "anything", "definition": "random(-5..5 except 0)", "group": "Ungrouped variables"}, "a": {"name": "a", "description": "", "templateType": "anything", "definition": "random(-5..5)", "group": "Ungrouped variables"}}, "variable_groups": [], "name": "Pattern matching - student's answer is a fraction", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

The student's answer is a fraction of two polynomials. First check that the student's answer is a fraction, then check that the numerator is of the form $x+a$.

\n

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

"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "parts": [{"answer": "(x+{a})/(x+{b})", "checkingaccuracy": 0.001, "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('(??;numerator)/(??;denominator)');\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 $\\\\frac{(\\\\dots)}{(\\\\dots)}$.');\n} else {\n var numerator = m.numerator;\n var numerator_rule = Numbas.jme.compile('x+?');\n m = Numbas.jme.display.matchTree(numerator_rule,numerator,true);\n if(!m) {\n this.multCredit(0.5,\"It doesn't look like the numerator has been simplified.\");\n }\n}", "order": "after"}}, "variableReplacementStrategy": "originalfirst", "vsetrangepoints": 5, "type": "jme", "showCorrectAnswer": true, "prompt": "

Simplify $\\simplify{(x^2+{a+b}x+{a*b})/((x+{b})^2)}$

", "checkingtype": "absdiff", "expectedvariablenames": [], "vsetrange": [0, 1], "checkvariablenames": false, "marks": "1", "variableReplacements": [], "showpreview": true, "showFeedbackIcon": true}], "functions": {}, "tags": [], "extensions": [], "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["a", "b"], "statement": "", "advice": "", "rulesets": {}, "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/"}]}