// Numbas version: finer_feedback_settings {"name": "Numbas demo: custom marking algorithms", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Numbas demo: custom marking algorithms", "tags": [], "metadata": {"description": "

A demo of how custom marking algorithms can be used to replace the built-in marking methods.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

When the built-in marking algorithm doesn't do what you want, you can write your own, either starting from scratch or extending the built-in method.

\n

See this question on the public editor.

", "advice": "", "rulesets": {}, "extensions": [], "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": true, "customName": "Accept any answer with a certain property", "marks": "2", "scripts": {}, "customMarkingAlgorithm": "required_factors (Factors that the student's answer must have):\n [2,3]\n\nisInteger (Is the student's answer an integer?):\n assert(isint(studentNumber),\n fail(\"Your answer is not an integer.\");\n warn(\"Your answer must be an integer.\");\n false\n )\n\ndivisible_by_factors (Is the student's answer divisible by all the required factors?):\n map(\n if(mod(studentNumber,n)=0,\n add_credit(1/len(required_factors), \"Your number is divisible by \"+n+\".\"),\n negative_feedback(\"Your number is not divisible by \"+n+\".\")\n ),\n n,\n required_factors\n )\n\nmark (Mark the student's answer):\n apply(validNumber);\n apply(isInteger);\n apply(divisible_by_factors)\n", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Normally, the number entry part type accepts any number in a given range. In this part, a custom marking algorithm accepts any multiple of 6.

\n

Write a number which is divisible by both 2 and 3.

", "minValue": "6", "maxValue": "6", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": "0", "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "gapfill", "useCustomName": true, "customName": "Combine the answers from a gap-fill part", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "function:\n interpreted_answers[0]\n\nx_value:\n interpreted_answers[1]\n\nvalue_at_point:\n eval(function,[\"x\":x_value])\n\ncorrect_value_at_point:\n if(value_at_point=9,\n correct(),\n incorrect(\"Your function produces the value $\"+value_at_point+\"$ at $x = \"+x_value+\"$.\")\n )\n\nmark:\n assert(all_valid, fail(translate(\"question.can not submit\")));\n apply(correct_value_at_point)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

A custom marking algorithm for a gap-fill part can combine the student's answers to the gaps, which are normally marked individually.

\n

Define a function $f(x)$, and a value of $x$ at which $f(x)=9$.

\n

$f(x) = $ [[0]]

\n

$x = $ [[1]]

", "gaps": [{"type": "jme", "useCustomName": true, "customName": "Function definition", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "x", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "x", "value": ""}]}, {"type": "numberentry", "useCustomName": true, "customName": "Value of $x$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "9", "maxValue": "9", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "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/"}]}]}], "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/"}]}