// Numbas version: exam_results_page_options {"name": "Mark an equation - check difference is 0", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variables": {}, "type": "question", "statement": "", "name": "Mark an equation - check difference is 0", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

One way of checking an equation is valid is to check that the difference between the LHS and RHS is 0.

"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "parts": [{"answer": "cos(x)^2+sin(x)^2=1", "checkingaccuracy": 0.001, "scripts": {"mark": {"order": "instead", "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\nvar rule = new Numbas.jme.display.Rule('?;left=?;right',[],'');\n\n// Check the student's answer matches the pattern\nvar m = rule.match(studentTree);\nif(!m) {\n this.setCredit(0,'Your answer is not an equation.');\n return;\n}\n\n// Create a pattern to rearrange the equation, and convert it to JME\nvar difftree = Numbas.jme.compile('left-right');\ndifftree.args[0] = m.left;\ndifftree.args[1] = m.right;\nvar diffexpr = Numbas.jme.display.treeToJME(difftree);\n\n// Compare the rearranged expression with 0 (`0x` so it uses the same variable names)\nif(Numbas.jme.compare('precround('+diffexpr+',3)','0x',this.settings,this.markingScope)) {\n this.setCredit(1,'Difference is 0 - your equation holds.');\n}"}}, "vsetrangepoints": 5, "showCorrectAnswer": true, "prompt": "

Write an equation, for example $\\cos(x)^2+\\sin(x)^2=1$

", "checkingtype": "absdiff", "type": "jme", "vsetrange": [0, 1], "checkvariablenames": false, "marks": 1, "expectedvariablenames": [], "showpreview": true}], "showQuestionGroupNames": false, "functions": {}, "tags": ["custom marking"], "variable_groups": [], "rulesets": {}, "ungrouped_variables": [], "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/"}]}