// Numbas version: exam_results_page_options {"name": "Get Python to work out the right answer", "extensions": ["programming"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Get Python to work out the right answer", "tags": [], "metadata": {"description": "

This question shows how to use the programming extension's run_code function to run some Python code and use its result in the marking of a non-code part type.

\n

Python is used to calculate the correct answer for a number entry part type. This could be done

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "extensions": ["programming"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "pre_submit:\n[run_code(\"pyodide\",[\"\"\"\nsum(x**3 for x in range(10))\n\"\"\"]\n)]\n\ntarget: pre_submit[\"code_result\"][0][\"result\"]\n\nminvalue: target\n\nmaxvalue: target\n\nmark:\n feedback(\"target = {target}\");\n apply(base_mark)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Compute $\\sum_{i=1}^9 i^3$

", "minValue": "1", "maxValue": "1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Aamir Khan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4537/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Aamir Khan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4537/"}]}