// Numbas version: exam_results_page_options {"name": "Access the student's answer to another part in a marking script", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "statement": "", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Shows how to retrieve the student's answer to another part from a custom marking script.

"}, "rulesets": {}, "variable_groups": [], "ungrouped_variables": ["n"], "parts": [{"variableReplacementStrategy": "originalfirst", "marks": 0, "type": "gapfill", "gaps": [{"variableReplacementStrategy": "originalfirst", "marks": "0", "minValue": "n", "correctAnswerStyle": "plain", "showCorrectAnswer": true, "correctAnswerFraction": false, "mustBeReducedPC": 0, "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "maxValue": "n", "showFeedbackIcon": false, "scripts": {}, "variableReplacements": [], "mustBeReduced": false}, {"variableReplacementStrategy": "originalfirst", "marks": 1, "minValue": "2n", "correctAnswerStyle": "plain", "showCorrectAnswer": true, "correctAnswerFraction": false, "mustBeReducedPC": 0, "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "maxValue": "2n", "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [{"variable": "n", "part": "p0g0", "must_go_first": false}], "mustBeReduced": false}], "prompt": "

Write a number in the first box: [[0]]

\n

Write double that number in the second box: [[1]]

", "showFeedbackIcon": true, "showCorrectAnswer": true, "variableReplacements": [], "scripts": {"mark": {"order": "after", "script": "// Get the student's answer to the first gap.\n// This is a JME token. Since the first gap is a number entry, it's a TNum object.\nvar studentN = part.question.getPart('p0g0').studentAnswerAsJME();\n\n// Unwrap the JME token to get a JavaScript number.\nstudentN = Numbas.jme.unwrapValue(studentN);\n\n// Now we can do something with the number.\n// For this example, I'll just add a marking comment saying what the number was.\nthis.markingComment(\"In the first part you wrote \"+studentN+\".\");"}}}], "functions": {}, "preamble": {"css": "", "js": ""}, "variables": {"n": {"group": "Ungrouped variables", "description": "", "definition": "1", "name": "n", "templateType": "anything"}}, "type": "question", "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "", "extensions": [], "name": "Access the student's answer to another part in a marking script", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}