// 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": [{"variables": {"n": {"name": "n", "templateType": "anything", "definition": "1", "description": "", "group": "Ungrouped variables"}}, "type": "question", "statement": "", "name": "Access the student's answer to another part in a marking script", "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.

"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "parts": [{"type": "gapfill", "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"}}, "marks": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showCorrectAnswer": true, "gaps": [{"notationStyles": ["plain", "en", "si-en"], "scripts": {}, "variableReplacementStrategy": "originalfirst", "mustBeReducedPC": 0, "showCorrectAnswer": true, "type": "numberentry", "mustBeReduced": false, "maxValue": "n", "showFeedbackIcon": false, "minValue": "n", "allowFractions": false, "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": false, "marks": "0"}, {"notationStyles": ["plain", "en", "si-en"], "scripts": {}, "variableReplacementStrategy": "originalfirst", "mustBeReducedPC": 0, "showCorrectAnswer": true, "type": "numberentry", "mustBeReduced": false, "maxValue": "2n", "showFeedbackIcon": true, "minValue": "2n", "allowFractions": false, "correctAnswerStyle": "plain", "variableReplacements": [{"part": "p0g0", "must_go_first": false, "variable": "n"}], "correctAnswerFraction": false, "marks": 1}], "prompt": "

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

\n

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

", "showFeedbackIcon": true}], "functions": {}, "tags": [], "extensions": [], "variable_groups": [], "rulesets": {}, "ungrouped_variables": ["n"], "preamble": {"css": "", "js": ""}, "advice": "", "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/"}]}