// Numbas version: exam_results_page_options {"name": "Ben's copy of Randomise variable names - expression() version", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Ben's copy of Randomise variable names - expression() version", "rulesets": {}, "advice": "

Multiply the numerators together, and then multiply the denominators together, to obtain

\n

", "variablesTest": {"maxRuns": 100, "condition": ""}, "extensions": [], "variable_groups": [], "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["a_name", "a", "b_name", "b", "c", "d_name", "d"], "tags": [], "statement": "

Simplify the following expression: $\\simplify[]{ ({a}/{b}) * ({c}/{d}) }$

\n

\n

a, {a}, $\\var{a}$ \\{a\\}, $\\{a\\}$, ${a}$, $\\\\var\\{a\\}$,

", "functions": {}, "variables": {"d": {"name": "d", "templateType": "anything", "group": "Ungrouped variables", "definition": "expression(d_name)", "description": ""}, "c": {"name": "c", "templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..6)", "description": ""}, "d_name": {"name": "d_name", "templateType": "anything", "group": "Ungrouped variables", "definition": "random([\"f\",\"g\",\"h\",\"j\"])", "description": ""}, "a_name": {"name": "a_name", "templateType": "anything", "group": "Ungrouped variables", "definition": "random([\"a\",\"b\",\"c\",\"d\"])", "description": "

The name of the first variable, as a string

"}, "a": {"name": "a", "templateType": "anything", "group": "Ungrouped variables", "definition": "expression(a_name)", "description": "

The name of the first variable, as a JME expression which can be substituted into other expressions.

"}, "b_name": {"name": "b_name", "templateType": "anything", "group": "Ungrouped variables", "definition": "random([\"p\",\"q\",\"r\",\"s\"])", "description": ""}, "b": {"name": "b", "templateType": "anything", "group": "Ungrouped variables", "definition": "expression(b_name)", "description": ""}}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

A method of randomly choosing variable names - use the expression() JME function to create a variable name from a randomly chosen string.

\n

(This question also uses a custom marking script to check that the student has simplified the expression)

"}, "parts": [{"showCorrectAnswer": true, "marks": 1, "showFeedbackIcon": true, "scripts": {"mark": {"script": "// get the names of variables a,b and c.\nvar a_name = question.unwrappedVariables.a_name;\nvar b_name = question.unwrappedVariables.b_name;\nvar d_name = question.unwrappedVariables.d_name;\n\n// get the value of c\nvar c = question.unwrappedVariables.c;\n\n// create an expression the student's answer should match:\n// it should be (a*c)/(b*d)\nvar pattern;\nif(c==1) {\n pattern = '('+a_name+')/('+b_name+'*'+d_name+')';\n} else {\n pattern = '('+a_name+'*'+c+')/('+b_name+'*'+d_name+')';\n}\n\ntry {\n var match = Numbas.jme.display.matchExpression(pattern,this.studentAnswer,true);\n} catch(e) {\n this.setCredit(0); // if the student's answer isn't a valid expression, give 0 credit\n}\n\nif(match) {\n // if the student's answer matches the pattern, mark it correct\n this.setCredit(1,R('part.marking.correct'));\n} else {\n this.setCredit(0,R('part.marking.incorrect')); \n}", "order": "instead"}}, "showpreview": true, "answer": "({a}*{c})/({b}*{d})", "type": "jme", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "answersimplification": "all", "vsetrange": [0, 1], "expectedvariablenames": ["a", "b", "c", "d", "p", "q", "r", "s", "f", "g", "h", "j"], "checkvariablenames": true, "checkingaccuracy": 0.001, "vsetrangepoints": 5, "checkingtype": "absdiff"}], "type": "question", "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}