// Numbas version: exam_results_page_options {"name": "Adrian's copy of Access the student's answer to another part in a marking script", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "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.

"}, "name": "Adrian's copy of Access the student's answer to another part in a marking script", "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "", "tags": [], "parts": [{"showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "prompt": "

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

\n

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

", "gaps": [{"variableReplacementStrategy": "originalfirst", "minValue": "n", "mustBeReducedPC": 0, "allowFractions": false, "mustBeReduced": false, "variableReplacements": [], "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "maxValue": "n", "correctAnswerStyle": "plain", "type": "numberentry", "marks": "0", "showFeedbackIcon": false}, {"variableReplacementStrategy": "originalfirst", "minValue": "n^2", "mustBeReducedPC": 0, "allowFractions": false, "mustBeReduced": false, "variableReplacements": [{"part": "p0g0", "must_go_first": false, "variable": "n"}], "showCorrectAnswer": true, "correctAnswerFraction": false, "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "maxValue": "n^2", "correctAnswerStyle": "plain", "type": "numberentry", "marks": 1, "showFeedbackIcon": true}], "type": "gapfill", "variableReplacements": [], "marks": 0, "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+\".\");"}}, "showFeedbackIcon": true}], "variables": {"n": {"description": "", "templateType": "anything", "definition": "1", "name": "n", "group": "Ungrouped variables"}}, "functions": {}, "ungrouped_variables": ["n"], "preamble": {"css": "", "js": ""}, "rulesets": {}, "advice": "", "extensions": [], "type": "question", "contributors": [{"name": "Adrian Jannetta", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/164/"}]}]}], "contributors": [{"name": "Adrian Jannetta", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/164/"}]}