// Numbas version: exam_results_page_options {"name": "Some custom part types", "extensions": [], "custom_part_types": [{"source": {"pk": 3, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/3/edit"}, "name": "Give a numerical input for an expression", "short_name": "give-a-numerical-input-for-an-expression", "description": "

The student gives a point $x$ at which to evaluate a given function $f$. The answer is correct if $f(x)$ is the expected value.

", "help_url": "", "input_widget": "number", "input_options": {"correctAnswer": "settings[\"correctAnswer\"]", "hint": {"static": true, "value": ""}, "allowedNotationStyles": {"static": true, "value": ["plain", "en", "si-en"]}, "allowFractions": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\nif(equal,\n correct()\n,\n incorrect(settings[\"student_value_description\"]+\" $\"+student_value+\"$.\")\n)\n\ninterpreted_answer:\nstudentAnswer\n\nstudent_value:\neval(settings[\"expression\"],[\"x\":studentAnswer])\n\nequal:\nwithintolerance(student_value,settings[\"expected_value\"],0.00001)", "marking_notes": [{"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(equal,\n correct()\n,\n incorrect(settings[\"student_value_description\"]+\" $\"+student_value+\"$.\")\n)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "studentAnswer"}, {"name": "student_value", "description": "", "definition": "eval(settings[\"expression\"],[\"x\":studentAnswer])"}, {"name": "equal", "description": "", "definition": "withintolerance(student_value,settings[\"expected_value\"],0.00001)"}], "settings": [{"name": "expected_value", "label": "Expected value", "help_url": "", "hint": "The value that the function should take at the given point.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The value that the student should write.", "input_type": "string", "default_value": "", "subvars": true}, {"name": "student_value_description", "label": "Description of the student's value", "help_url": "", "hint": "", "input_type": "string", "default_value": "The value at your point is", "subvars": true}, {"name": "expression", "label": "Function to evaluate", "help_url": "", "hint": "The function that will be applied to the student's number.
The student's number will be substituted for $x$ in this expression.", "input_type": "mathematical_expression", "default_value": "", "subvars": true}], "public_availability": "always", "published": true, "extensions": []}, {"source": {"pk": 2, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/2/edit"}, "name": "List of numbers", "short_name": "list-of-numbers", "description": "

The answer is a comma-separated list of numbers.

\n

The list is marked correct if each number occurs the same number of times as in the expected answer, and no extra numbers are present.

\n

You can optionally treat the answer as a set, so the number of occurrences doesn't matter, only whether each number is included or not.

", "help_url": "", "input_widget": "string", "input_options": {"correctAnswer": "join(\n if(settings[\"correctAnswerFractions\"],\n map(let([a,b],rational_approximation(x), string(a/b)),x,settings[\"correctAnswer\"])\n ,\n settings[\"correctAnswer\"]\n ),\n settings[\"separator\"] + \" \"\n)", "hint": {"static": false, "value": "if(settings[\"show_input_hint\"],\n \"Enter a list of numbers separated by {settings['separator']}.\",\n \"\"\n)"}, "allowEmpty": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "bits:\nlet(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)\n\nexpected_numbers:\nlet(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)\n\nvalid_numbers:\nif(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )\n\nis_sorted:\nassert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )\n\nincluded:\nmap(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentThe separate items in the student's answer

", "definition": "let(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)"}, {"name": "expected_numbers", "description": "", "definition": "let(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)"}, {"name": "valid_numbers", "description": "

Is every number in the student's list valid?

", "definition": "if(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )"}, {"name": "is_sorted", "description": "

Are the student's answers in ascending order?

", "definition": "assert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )"}, {"name": "included", "description": "

Is each number in the expected answer present in the student's list the correct number of times?

", "definition": "map(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentHas every number been included the right number of times?

", "definition": "all(included)"}, {"name": "no_extras", "description": "

True if the student's list doesn't contain any numbers that aren't in the expected answer.

", "definition": "if(all(map(x in expected_numbers, x, interpreted_answer)),\n true\n ,\n incorrect(\"Your answer contains \"+extra_numbers[0]+\" but should not.\");\n false\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "if(lower(studentAnswer) in [\"empty\",\"\u2205\"],[],\n map(\n if(settings[\"allowFractions\"],parsenumber_or_fraction(x,notationStyles), parsenumber(x,notationStyles))\n ,x\n ,bits\n )\n)"}, {"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(studentanswer=\"\",fail(\"You have not entered an answer\"),false);\napply(valid_numbers);\napply(included);\napply(no_extras);\ncorrectif(all_included and no_extras)"}, {"name": "notationStyles", "description": "", "definition": "[\"en\"]"}, {"name": "isSet", "description": "

Should the answer be considered as a set, so the number of times an element occurs doesn't matter?

", "definition": "settings[\"isSet\"]"}, {"name": "extra_numbers", "description": "

Numbers included in the student's answer that are not in the expected list.

", "definition": "filter(not (x in expected_numbers),x,interpreted_answer)"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The list of numbers that the student should enter. The order does not matter.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "allowFractions", "label": "Allow the student to enter fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "correctAnswerFractions", "label": "Display the correct answers as fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "isSet", "label": "Is the answer a set?", "help_url": "", "hint": "If ticked, the number of times an element occurs doesn't matter, only whether it's included at all.", "input_type": "checkbox", "default_value": false}, {"name": "show_input_hint", "label": "Show the input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true}, {"name": "separator", "label": "Separator", "help_url": "", "hint": "The substring that should separate items in the student's list", "input_type": "string", "default_value": ",", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}, {"source": {"pk": 4, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/4/edit"}, "name": "Number entry modulo", "short_name": "number-entry-modulo", "description": "

The student's answer should be equivalent to the expected answer modulo the base set by the question author.

", "help_url": "", "input_widget": "number", "input_options": {"correctAnswer": "string(mod(settings[\"expected\"],settings[\"modulo\"]))", "hint": {"static": false, "value": "if(settings[\"show_hint\"], \"$\\\\pmod{\"+settings[\"modulo\"]+\"}$\", \"\")"}, "allowedNotationStyles": {"static": true, "value": ["plain", "en", "si-en"]}, "allowFractions": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\ncorrectif(interpreted_answer = expected_modulo)\n\ninterpreted_answer:\nmod(studentanswer,settings[\"modulo\"])\n\nexpected_modulo:\nmod(settings[\"expected\"],settings[\"modulo\"])", "marking_notes": [{"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "correctif(interpreted_answer = expected_modulo)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "mod(studentanswer,settings[\"modulo\"])"}, {"name": "expected_modulo", "description": "

The expected answer, modulo the base.

", "definition": "mod(settings[\"expected\"],settings[\"modulo\"])"}], "settings": [{"name": "expected", "label": "Expected answer", "help_url": "", "hint": "

Answers congruent to this number, modulo the base defined below, will be marked correct.

", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "modulo", "label": "Base", "help_url": "", "hint": "Answers are compared modulo this number.", "input_type": "code", "default_value": "10", "evaluate": true}, {"name": "show_hint", "label": "Show modulo hint?", "help_url": "", "hint": "If ticked, $\\pmod{\\texttt{base}}$ will be shown to the right of the input box.", "input_type": "checkbox", "default_value": true}], "public_availability": "always", "published": true, "extensions": []}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Some custom part types", "tags": [], "metadata": {"description": "

Examples of the following custom part types: Yes/no, List of numbers, Give a numerical input for an expression, Number entry modulo.

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

This demo question contains some instances of custom part types.

", "advice": "

a)

\n

The discriminant of this quadratic is $\\simplify[]{{a_b}^2 - 4*{a_a}*{a_c} = {a_b^2-4*a_a*a_c}}$. This is not negative, so the quadratic has at least one real-valued solution. This is negative, so the quadratic has no real-valued solutions.

\n

b)

\n

The first five terms are:

\n

\\begin{align}
a_0 &= \\var{b_0} \\\\
a_1 &= \\var{b_1} \\\\
a_2 &= a_1+a_0 = \\var{b_0+b_1} \\\\
a_3 &= a_2+a_1 = \\var{b_0+2b_1} \\\\
a_4 &= a_3+a_2 = \\var{2b_0+3b_1}
\\end{align}

\n

c)

\n

$\\simplify{cos(pi/2 + n*pi)} = 0$ for all integers $n$, so we need $\\simplify{x/{c}pi = pi/2+n*pi}$.

\n

One solution is $x = \\var{c/2}$.

\n

d)

\n

One solution is $\\var{d_rem}$.

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"a_c": {"name": "a_c", "group": "Yes/no", "definition": "random(-5 .. 5#1)", "description": "", "templateType": "randrange", "can_override": false}, "c": {"name": "c", "group": "Give input to function", "definition": "random(1 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "b_0": {"name": "b_0", "group": "List of numbers", "definition": "random(1 .. 9#1)", "description": "", "templateType": "randrange", "can_override": false}, "d_base": {"name": "d_base", "group": "Number modulo", "definition": "random(5 .. 15#2)", "description": "", "templateType": "randrange", "can_override": false}, "a_solvable": {"name": "a_solvable", "group": "Yes/no", "definition": "a_b^2-4*a_a*a_c > 0", "description": "", "templateType": "anything", "can_override": false}, "b_1": {"name": "b_1", "group": "List of numbers", "definition": "random(1 .. 9#1)", "description": "", "templateType": "randrange", "can_override": false}, "d_rem": {"name": "d_rem", "group": "Number modulo", "definition": "random(0..d_base-1)", "description": "", "templateType": "anything", "can_override": false}, "a_b": {"name": "a_b", "group": "Yes/no", "definition": "random(-5 .. 5#1)", "description": "", "templateType": "randrange", "can_override": false}, "a_a": {"name": "a_a", "group": "Yes/no", "definition": "random(-5 .. 5#1)", "description": "", "templateType": "randrange", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": [], "variable_groups": [{"name": "Yes/no", "variables": ["a_a", "a_b", "a_c", "a_solvable"]}, {"name": "List of numbers", "variables": ["b_0", "b_1"]}, {"name": "Give input to function", "variables": ["c"]}, {"name": "Number modulo", "variables": ["d_base", "d_rem"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "list-of-numbers", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

A sequence is defined by

\n

\\begin{align}
a_0 &= \\var{b_0} \\\\
a_1 &= \\var{b_1} \\\\
a_{n+2} &= a_{n+1} + a_n
\\end{align}

\n

Write the first five terms of the sequence.

", "settings": {"correctAnswer": "[\n b_0,\n b_1,\n b_0+b_1,\n b_0+2*b_1,\n 2*b_0+3*b_1\n]", "allowFractions": false, "correctAnswerFractions": false, "isSet": false, "show_input_hint": true, "separator": ","}}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

A function is defined by

\n

\\[ f(x) = \\simplify[basic,unitdenominator]{cos(x/{c}*pi)} \\]

\n

Find $x$ such that $f(x) = 0$.

\n

$x = $ [[0]]

", "gaps": [{"type": "give-a-numerical-input-for-an-expression", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"expected_value": "0", "correctAnswer": "{c/2}", "student_value_description": "The value at your point is", "expression": "cos(x/{c}*pi)"}}], "sortAnswers": false}, {"type": "number-entry-modulo", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write down a number which has remainder $\\var{d_rem}$ when divided by $\\var{d_base}$.

", "settings": {"expected": "d_rem", "modulo": "d_base", "show_hint": true}}], "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/"}]}]}], "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/"}]}