// Numbas version: exam_results_page_options {"name": "Randomise variable names - list of coefficients version", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {}, "ungrouped_variables": ["a", "b", "c", "d"], "statement": "

Simplify the following expression: \$\\simplify{(({a[0]}*a + {a[1]}*b + {a[2]}*c + {a[3]}*d) / ({b[0]}*p + {b[1]}*q + {b[2]}*r + {b[3]}*s)) * ({c} / ({d[0]}*f + {d[1]}*g + {d[2]}*h + {d[3]}*j))}\$.

", "variablesTest": {"maxRuns": 100, "condition": ""}, "tags": [], "parts": [{"vsetrangepoints": 5, "showCorrectAnswer": true, "checkvariablenames": true, "showpreview": true, "variableReplacements": [], "scripts": {"mark": {"script": "// get the names of variables a,b and c.\nvar a_name = [\"a\",\"b\",\"c\",\"d\"][question.unwrappedVariables.a.indexOf(1)];\nvar b_name = [\"p\",\"q\",\"r\",\"s\"][question.unwrappedVariables.b.indexOf(1)];\nvar d_name = [\"f\",\"g\",\"h\",\"j\"][question.unwrappedVariables.d.indexOf(1)];\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"}}, "answersimplification": "all", "answer": "(({a[0]}*a+{a[1]}*b+{a[2]}*c+{a[3]}*d)*{c})/(({b[0]}*p+{b[1]}*q+{b[2]}*r+{b[3]}*s)*({d[0]}*f+{d[1]}*g+{d[2]}*h+{d[3]}*j))", "marks": 1, "variableReplacementStrategy": "originalfirst", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showFeedbackIcon": true, "checkingtype": "absdiff", "expectedvariablenames": ["a", "b", "c", "d", "p", "q", "r", "s", "f", "g", "h", "j"], "type": "jme"}], "variable_groups": [], "variables": {"d": {"name": "d", "description": "", "group": "Ungrouped variables", "definition": "shuffle([1,0,0,0])", "templateType": "anything"}, "b": {"name": "b", "description": "", "group": "Ungrouped variables", "definition": "shuffle([1,0,0,0])", "templateType": "anything"}, "a": {"name": "a", "description": "

Element j is 1 if `a_options[j]` is the name of variable a, otherwise 0.

\n

We will multiply each of the names by this so that the unused names are cancelled to 0 in any expression, leaving only the name we want to use.

", "group": "Ungrouped variables", "definition": "shuffle([1,0,0,0])", "templateType": "anything"}, "c": {"name": "c", "description": "", "group": "Ungrouped variables", "definition": "random(1..6)", "templateType": "anything"}}, "metadata": {"description": "

One method of randomly choosing names for variables. For each variable, we have 4 options. Create a list of 4 numbers, which is 1 for the name we want to use, and 0 otherwise.

\n

Then, whenever we use that variable, multiply each of the possible names by the corresponding number in the list. When the expression is simplified, the unwanted names will cancel to 0, leaving only the name we want.

\n

This is quite clunky!

\n

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

", "licence": "Creative Commons Attribution 4.0 International"}, "preamble": {"css": "", "js": ""}, "name": "Randomise variable names - list of coefficients version", "advice": "

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

\n

\\[ \\simplify{(({a[0]}*a + {a[1]}*b + {a[2]}*c + {a[3]}*d) * ({c})) / (({b[0]}*p + {b[1]}*q + {b[2]}*r + {b[3]}*s)*({d[0]}*f + {d[1]}*g + {d[2]}*h + {d[3]}*j))} \\]

", "type": "question", "extensions": [], "functions": {}, "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/"}]}