// 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": {"preventleave": false, "showfrontpage": false, "allowregen": true}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Access the student's answer to another part in a marking script", "extensions": [], "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["n"], "rulesets": {}, "tags": [], "parts": [{"scripts": {"mark": {"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+\".\");", "order": "after"}}, "type": "gapfill", "prompt": "

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

\n

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

", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "gaps": [{"allowFractions": false, "showFeedbackIcon": false, "maxValue": "n", "notationStyles": ["plain", "en", "si-en"], "marks": "0", "type": "numberentry", "correctAnswerStyle": "plain", "mustBeReduced": false, "mustBeReducedPC": 0, "correctAnswerFraction": false, "minValue": "n", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": []}, {"allowFractions": false, "showFeedbackIcon": true, "maxValue": "2n", "notationStyles": ["plain", "en", "si-en"], "marks": 1, "type": "numberentry", "correctAnswerStyle": "plain", "mustBeReduced": false, "mustBeReducedPC": 0, "correctAnswerFraction": false, "minValue": "2n", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [{"must_go_first": false, "variable": "n", "part": "p0g0"}]}], "variableReplacements": []}], "advice": "", "variables": {"n": {"group": "Ungrouped variables", "description": "", "templateType": "anything", "name": "n", "definition": "1"}}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}], "functions": {}, "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.

"}, "type": "question", "statement": "", "variable_groups": [], "preamble": {"js": "", "css": ""}}]}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}]}