// Numbas version: exam_results_page_options {"question_groups": [{"pickingStrategy": "all-ordered", "name": "Group", "pickQuestions": 1, "questions": [{"name": "Convert from one metric unit to another", "extensions": ["quantities"], "custom_part_types": [{"source": {"pk": 7, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/7/edit"}, "name": "Quantity with units", "short_name": "quantity", "description": "

The student enters a quantity with units.

The scalar part of the student's quantity

", "definition": "match_student_number[1]"}, {"name": "raw_student_units", "description": "

The units of the student's quantity, before converting.

The units of the student's quantity.

\n

If the student used units incompatible with the units in the expected answer, and the \"what to do if incompatible units used\" option is set to \"mark as if correct units used\", the student's units are ignored and the expected units are used instead.

", "definition": "if(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)"}, {"name": "student_quantity", "description": "

The student's answer, interpreted as a quantity.

\n

Marking fails if the student does not enter a valid quantity.

", "definition": "apply(student_units);\ntry(\n student_number * student_units,\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "correct_quantity", "description": "", "definition": "settings[\"correctAnswer\"]"}, {"name": "compatible", "description": "

Are the units of the student's quantity compatible with the units of the expected quantity?

", "definition": "if(compatible(raw_student_units,correct_quantity),\n true\n,\n let(message,\"Your answer does not have the correct dimensions.\",\n if(settings[\"incompatible_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n if(settings[\"incompatible_units_action\"]=\"convert\",\n incorrect(\"Your answer does not have the correct dimensions. It will be marked as if the correct dimensions were used, and then a penalty will be applied.\")\n ,\n incorrect(\"Your answer does not have the correct dimensions.\");\n end()\n )\n );\n false\n )\n)"}, {"name": "correct_units", "description": "", "definition": "units(correct_quantity)"}, {"name": "same_units", "description": "

/Are the student's quantity and the expected quantity in exactly the same units?

", "definition": "assert(raw_student_units=correct_units,\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+units_string(correct_units)+\".\", \"Your answer is not in the expected units.\"),\n switch(\n settings[\"different_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n settings[\"different_units_action\"]=\"incorrect\",\n incorrect(message); \n warn(message);\n end()\n ,\n settings[\"different_units_action\"]=\"warn\",\n warn(message);\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)"}, {"name": "has_units", "description": "", "definition": "assert(not unitless(student_quantity),\n assert(settings[\"allow_unitless\"],\n warn(\"You must include the units in your answer.\");\n fail(\"You did not include units in your answer.\")\n )\n)"}, {"name": "can_compare", "description": "

Can the student's answer be compared with the correct answer? True if compatible units used, or \"mark as if correct units used\" selected.

", "definition": "compatible or settings[\"incompatible_units_action\"]=\"convert\""}, {"name": "close_enough", "description": "

Is the student's quantity within the allowed tolerance of the expected answer?

", "definition": "if(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)"}, {"name": "wiggle", "description": "", "definition": "units(correct_quantity)*abs(eval(settings[\"wiggle\"]))"}, {"name": "valid_number", "description": "

Is the scalar part of the student's answer a valid number?

", "definition": "if(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )\n"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The expected quantity.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "hint", "label": "Input hint", "help_url": "", "hint": "", "input_type": "dropdown", "default_value": "remind units", "choices": [{"value": "none", "label": "None"}, {"value": "remind units", "label": "Remind to include units"}, {"value": "show units", "label": "Show required units"}]}, {"name": "allow_unitless", "label": "Allow unitless answer?", "help_url": "", "hint": "If not ticked, the student is prevented from submitting an answer without specifying units.", "input_type": "checkbox", "default_value": true}, {"name": "incompatible_units_action", "label": "What to do if incompatible units used", "help_url": "", "hint": "If the student's answer is given in units incompatible with the correct answer's units:
\n
\n
• \"Prevent submission\": Prevent the student from submitting until they use compatible units
• \n
• \"Mark as incorrect\": Mark the student's answer as incorrect.
• \n
• \"Mark as if correct units used\": Mark the student's answer as if they used the correct units, and apply the \"different units used\" penalty.
• \n
", "input_type": "dropdown", "default_value": "incorrect", "choices": [{"value": "incorrect", "label": "Mark as incorrect"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "convert", "label": "Mark as if correct units used"}]}, {"name": "different_units_action", "label": "What to do if different units used", "help_url": "", "hint": "If the student's answer is given in different units to the expected answer:
\n
\n
• \"Convert\" - silently convert the student's answer to the units used in the correct answer.
• \n
• \"Warn and convert\" - show a warning to the student, but convert.
• \n
• \"Prevent submission\" - don't allow the student to submit, and show a warning that they must use the same units.
• \n
• \"Mark incorrect\" - the student's answer is marked as incorrect.
• \n
", "input_type": "dropdown", "default_value": "convert", "choices": [{"value": "convert", "label": "Convert"}, {"value": "warn", "label": "Warn and convert"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "incorrect", "label": "Mark incorrect"}]}, {"name": "different_units_penalty", "label": "Penalty if different units used", "help_url": "", "hint": "This penalty is applied if the student gives their answer in different units to the expected answer. The selected percentage of the student's score is taken away.", "input_type": "percent", "default_value": "100"}, {"name": "wiggle", "label": "Margin of error", "help_url": "", "hint": "The student's answer is marked correct if the difference between it and the correct answer is at most this value, measured in the same units as the correct answer.", "input_type": "mathematical_expression", "default_value": "10^-12", "subvars": true}], "public_availability": "always", "published": true, "extensions": ["quantities"]}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "variable_groups": [], "parts": [{"unitTests": [], "sortAnswers": false, "marks": 0, "showCorrectAnswer": true, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "prompt": "

Write $\\var{from_amount}$ in {units_string(to_unit)}.

\n

$\\var{from_amount} =$ [[0]]

", "extendBaseMarkingAlgorithm": true, "gaps": [{"settings": {"allow_unitless": true, "different_units_action": "incorrect", "correctAnswer": "to_amount", "hint": "none", "wiggle": "10^-12", "different_units_penalty": "100"}, "unitTests": [], "marks": 1, "showCorrectAnswer": true, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "extendBaseMarkingAlgorithm": true, "type": "quantity", "scripts": {}, "customName": "", "useCustomName": false, "customMarkingAlgorithm": "", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst"}], "type": "gapfill", "scripts": {}, "customName": "", "useCustomName": false, "customMarkingAlgorithm": "", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst"}], "tags": [], "ungrouped_variables": ["units", "from_unit", "to_unit", "scale", "amount", "from_amount", "to_amount", "q"], "statement": "", "preamble": {"js": "", "css": ""}, "metadata": {"description": "

Convert a metric measurement to another order of magnitude, e.g. g to kg.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "advice": "

There are $\\var{(from_unit/to_unit) * units(to_unit)}$ in $\\var{units(from_unit)}$.

\n

To convert $\\var{from_amount}$ to {units_string(to_unit)}, multiply by {1/scale}:

\n

\$\\var{abs(from_amount)} \\times \\var{1/scale} = \\var{abs(to_amount)} \$

\n

So $\\var{from_amount} = \\var{to_amount}$.

", "functions": {}, "variables": {"from_amount": {"name": "from_amount", "description": "

The amount to display to the student.

", "templateType": "anything", "definition": "precround(amount * scale * from_unit,9)", "group": "Ungrouped variables"}, "from_unit": {"name": "from_unit", "description": "

The unit the amount is given to the student in.

", "templateType": "anything", "definition": "qty(units[0])", "group": "Ungrouped variables"}, "scale": {"name": "scale", "description": "

The number of \"from\" units in the \"to\" unit

", "templateType": "anything", "definition": "abs(to_unit/from_unit)", "group": "Ungrouped variables"}, "q": {"name": "q", "description": "", "templateType": "anything", "definition": "units(to_amount)*10^-12", "group": "Ungrouped variables"}, "units": {"name": "units", "description": "

Some sets of units that you might reasonably convert between. A set of units is randomly picked, and then shuffled. The first item in the list is the \"from\" unit, and the second item is the \"to\" unit.

", "templateType": "anything", "definition": "shuffle(random([\n [\"g\",\"kg\"],\n [\"m\",\"cm\",\"mm\",\"km\"],\n [\"l\",\"ml\",\"cl\"]\n]))", "group": "Ungrouped variables"}, "to_amount": {"name": "to_amount", "description": "", "templateType": "anything", "definition": "from_amount in to_unit", "group": "Ungrouped variables"}, "to_unit": {"name": "to_unit", "description": "

The unit the student must convert to.

", "templateType": "anything", "definition": "qty(units[1])", "group": "Ungrouped variables"}, "amount": {"name": "amount", "description": "

The amount of the \"to\" unit to use.

\n

Picked to use a variety of different precisions and orders of magnitude. If the step size was always 0.01, you'd very rarely get a round number or multiple of 10, so instead we pick a step size at random.

", "templateType": "anything", "definition": "random(10..random(100, 1000) # random(1, 0.1, 0.01, 10))", "group": "Ungrouped variables"}}, "rulesets": {}}, {"name": "Calculate density in SI units at various orders of magnitude", "extensions": ["quantities"], "custom_part_types": [{"source": {"pk": 7, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/7/edit"}, "name": "Quantity with units", "short_name": "quantity", "description": "

The student enters a quantity with units.

The scalar part of the student's quantity

", "definition": "match_student_number[1]"}, {"name": "raw_student_units", "description": "

The units of the student's quantity, before converting.

The units of the student's quantity.

\n

If the student used units incompatible with the units in the expected answer, and the \"what to do if incompatible units used\" option is set to \"mark as if correct units used\", the student's units are ignored and the expected units are used instead.

", "definition": "if(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)"}, {"name": "student_quantity", "description": "

The student's answer, interpreted as a quantity.

\n

Marking fails if the student does not enter a valid quantity.

", "definition": "apply(student_units);\ntry(\n student_number * student_units,\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "correct_quantity", "description": "", "definition": "settings[\"correctAnswer\"]"}, {"name": "compatible", "description": "

Are the units of the student's quantity compatible with the units of the expected quantity?

", "definition": "if(compatible(raw_student_units,correct_quantity),\n true\n,\n let(message,\"Your answer does not have the correct dimensions.\",\n if(settings[\"incompatible_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n if(settings[\"incompatible_units_action\"]=\"convert\",\n incorrect(\"Your answer does not have the correct dimensions. It will be marked as if the correct dimensions were used, and then a penalty will be applied.\")\n ,\n incorrect(\"Your answer does not have the correct dimensions.\");\n end()\n )\n );\n false\n )\n)"}, {"name": "correct_units", "description": "", "definition": "units(correct_quantity)"}, {"name": "same_units", "description": "

/Are the student's quantity and the expected quantity in exactly the same units?

", "definition": "assert(raw_student_units=correct_units,\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+units_string(correct_units)+\".\", \"Your answer is not in the expected units.\"),\n switch(\n settings[\"different_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n settings[\"different_units_action\"]=\"incorrect\",\n incorrect(message); \n warn(message);\n end()\n ,\n settings[\"different_units_action\"]=\"warn\",\n warn(message);\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)"}, {"name": "has_units", "description": "", "definition": "assert(not unitless(student_quantity),\n assert(settings[\"allow_unitless\"],\n warn(\"You must include the units in your answer.\");\n fail(\"You did not include units in your answer.\")\n )\n)"}, {"name": "can_compare", "description": "

Can the student's answer be compared with the correct answer? True if compatible units used, or \"mark as if correct units used\" selected.

", "definition": "compatible or settings[\"incompatible_units_action\"]=\"convert\""}, {"name": "close_enough", "description": "

Is the student's quantity within the allowed tolerance of the expected answer?

", "definition": "if(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)"}, {"name": "wiggle", "description": "", "definition": "units(correct_quantity)*abs(eval(settings[\"wiggle\"]))"}, {"name": "valid_number", "description": "

Is the scalar part of the student's answer a valid number?

", "definition": "if(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )\n"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The expected quantity.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "hint", "label": "Input hint", "help_url": "", "hint": "", "input_type": "dropdown", "default_value": "remind units", "choices": [{"value": "none", "label": "None"}, {"value": "remind units", "label": "Remind to include units"}, {"value": "show units", "label": "Show required units"}]}, {"name": "allow_unitless", "label": "Allow unitless answer?", "help_url": "", "hint": "If not ticked, the student is prevented from submitting an answer without specifying units.", "input_type": "checkbox", "default_value": true}, {"name": "incompatible_units_action", "label": "What to do if incompatible units used", "help_url": "", "hint": "If the student's answer is given in units incompatible with the correct answer's units:
\n
\n
• \"Prevent submission\": Prevent the student from submitting until they use compatible units
• \n
• \"Mark as incorrect\": Mark the student's answer as incorrect.
• \n
• \"Mark as if correct units used\": Mark the student's answer as if they used the correct units, and apply the \"different units used\" penalty.
• \n
", "input_type": "dropdown", "default_value": "incorrect", "choices": [{"value": "incorrect", "label": "Mark as incorrect"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "convert", "label": "Mark as if correct units used"}]}, {"name": "different_units_action", "label": "What to do if different units used", "help_url": "", "hint": "If the student's answer is given in different units to the expected answer:
\n
\n
• \"Convert\" - silently convert the student's answer to the units used in the correct answer.
• \n
• \"Warn and convert\" - show a warning to the student, but convert.
• \n
• \"Prevent submission\" - don't allow the student to submit, and show a warning that they must use the same units.
• \n
• \"Mark incorrect\" - the student's answer is marked as incorrect.
• \n
", "input_type": "dropdown", "default_value": "convert", "choices": [{"value": "convert", "label": "Convert"}, {"value": "warn", "label": "Warn and convert"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "incorrect", "label": "Mark incorrect"}]}, {"name": "different_units_penalty", "label": "Penalty if different units used", "help_url": "", "hint": "This penalty is applied if the student gives their answer in different units to the expected answer. The selected percentage of the student's score is taken away.", "input_type": "percent", "default_value": "100"}, {"name": "wiggle", "label": "Margin of error", "help_url": "", "hint": "The student's answer is marked correct if the difference between it and the correct answer is at most this value, measured in the same units as the correct answer.", "input_type": "mathematical_expression", "default_value": "10^-12", "subvars": true}], "public_availability": "always", "published": true, "extensions": ["quantities"]}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "variable_groups": [], "parts": [{"settings": {"allow_unitless": false, "different_units_action": "convert", "correctAnswer": "as_si(density)", "hint": "remind units", "wiggle": "10^-12", "different_units_penalty": "100"}, "unitTests": [], "marks": 1, "showCorrectAnswer": true, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "prompt": "

What is the object's density, in SI units?

", "extendBaseMarkingAlgorithm": true, "type": "quantity", "scripts": {}, "customName": "", "useCustomName": false, "customMarkingAlgorithm": "", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst"}], "tags": [], "ungrouped_variables": ["density", "volume", "mass", "units"], "statement": "

An object has mass {mass} and volume {volume}.

", "preamble": {"js": "", "css": ""}, "metadata": {"description": "

Given mass and volume of an object in SI units, calculate its density. The units are given at different orders of magnitude.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "advice": "

Density is given by the formula

\n

\$\\text{Density} = \\frac{\\text{Mass}}{\\text{Volume}} \$

\n

In this case,

\n

\$\\text{Density} = \\frac{\\var{mass}}{\\var{volume}} = \\var{density} \$

", "functions": {}, "variables": {"volume": {"name": "volume", "description": "", "templateType": "anything", "definition": "random(300..500#100)*quantity(\"m^3\")", "group": "Ungrouped variables"}, "mass": {"name": "mass", "description": "", "templateType": "anything", "definition": "density*volume in units", "group": "Ungrouped variables"}, "density": {"name": "density", "description": "", "templateType": "anything", "definition": "random(1..10)*units/quantity(\"m^3\")", "group": "Ungrouped variables"}, "units": {"name": "units", "description": "", "templateType": "anything", "definition": "quantity(random([\"kg\",\"g\",\"mg\"]))", "group": "Ungrouped variables"}}, "rulesets": {}}, {"name": "Posting a parcel - calculate volume and surface area", "extensions": ["quantities"], "custom_part_types": [{"source": {"pk": 7, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/7/edit"}, "name": "Quantity with units", "short_name": "quantity", "description": "

The student enters a quantity with units.

The scalar part of the student's quantity

", "definition": "match_student_number[1]"}, {"name": "raw_student_units", "description": "

The units of the student's quantity, before converting.

The units of the student's quantity.

\n

If the student used units incompatible with the units in the expected answer, and the \"what to do if incompatible units used\" option is set to \"mark as if correct units used\", the student's units are ignored and the expected units are used instead.

", "definition": "if(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)"}, {"name": "student_quantity", "description": "

The student's answer, interpreted as a quantity.

\n

Marking fails if the student does not enter a valid quantity.

", "definition": "apply(student_units);\ntry(\n student_number * student_units,\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "correct_quantity", "description": "", "definition": "settings[\"correctAnswer\"]"}, {"name": "compatible", "description": "

Are the units of the student's quantity compatible with the units of the expected quantity?

", "definition": "if(compatible(raw_student_units,correct_quantity),\n true\n,\n let(message,\"Your answer does not have the correct dimensions.\",\n if(settings[\"incompatible_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n if(settings[\"incompatible_units_action\"]=\"convert\",\n incorrect(\"Your answer does not have the correct dimensions. It will be marked as if the correct dimensions were used, and then a penalty will be applied.\")\n ,\n incorrect(\"Your answer does not have the correct dimensions.\");\n end()\n )\n );\n false\n )\n)"}, {"name": "correct_units", "description": "", "definition": "units(correct_quantity)"}, {"name": "same_units", "description": "

/Are the student's quantity and the expected quantity in exactly the same units?

", "definition": "assert(raw_student_units=correct_units,\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+units_string(correct_units)+\".\", \"Your answer is not in the expected units.\"),\n switch(\n settings[\"different_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n settings[\"different_units_action\"]=\"incorrect\",\n incorrect(message); \n warn(message);\n end()\n ,\n settings[\"different_units_action\"]=\"warn\",\n warn(message);\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)"}, {"name": "has_units", "description": "", "definition": "assert(not unitless(student_quantity),\n assert(settings[\"allow_unitless\"],\n warn(\"You must include the units in your answer.\");\n fail(\"You did not include units in your answer.\")\n )\n)"}, {"name": "can_compare", "description": "

Can the student's answer be compared with the correct answer? True if compatible units used, or \"mark as if correct units used\" selected.

", "definition": "compatible or settings[\"incompatible_units_action\"]=\"convert\""}, {"name": "close_enough", "description": "

Is the student's quantity within the allowed tolerance of the expected answer?

", "definition": "if(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)"}, {"name": "wiggle", "description": "", "definition": "units(correct_quantity)*abs(eval(settings[\"wiggle\"]))"}, {"name": "valid_number", "description": "

Is the scalar part of the student's answer a valid number?

", "definition": "if(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )\n"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The expected quantity.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "hint", "label": "Input hint", "help_url": "", "hint": "", "input_type": "dropdown", "default_value": "remind units", "choices": [{"value": "none", "label": "None"}, {"value": "remind units", "label": "Remind to include units"}, {"value": "show units", "label": "Show required units"}]}, {"name": "allow_unitless", "label": "Allow unitless answer?", "help_url": "", "hint": "If not ticked, the student is prevented from submitting an answer without specifying units.", "input_type": "checkbox", "default_value": true}, {"name": "incompatible_units_action", "label": "What to do if incompatible units used", "help_url": "", "hint": "If the student's answer is given in units incompatible with the correct answer's units:
\n
\n
• \"Prevent submission\": Prevent the student from submitting until they use compatible units
• \n
• \"Mark as incorrect\": Mark the student's answer as incorrect.
• \n
• \"Mark as if correct units used\": Mark the student's answer as if they used the correct units, and apply the \"different units used\" penalty.
• \n
", "input_type": "dropdown", "default_value": "incorrect", "choices": [{"value": "incorrect", "label": "Mark as incorrect"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "convert", "label": "Mark as if correct units used"}]}, {"name": "different_units_action", "label": "What to do if different units used", "help_url": "", "hint": "If the student's answer is given in different units to the expected answer:
\n
\n
• \"Convert\" - silently convert the student's answer to the units used in the correct answer.
• \n
• \"Warn and convert\" - show a warning to the student, but convert.
• \n
• \"Prevent submission\" - don't allow the student to submit, and show a warning that they must use the same units.
• \n
• \"Mark incorrect\" - the student's answer is marked as incorrect.
• \n
", "input_type": "dropdown", "default_value": "convert", "choices": [{"value": "convert", "label": "Convert"}, {"value": "warn", "label": "Warn and convert"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "incorrect", "label": "Mark incorrect"}]}, {"name": "different_units_penalty", "label": "Penalty if different units used", "help_url": "", "hint": "This penalty is applied if the student gives their answer in different units to the expected answer. The selected percentage of the student's score is taken away.", "input_type": "percent", "default_value": "100"}, {"name": "wiggle", "label": "Margin of error", "help_url": "", "hint": "The student's answer is marked correct if the difference between it and the correct answer is at most this value, measured in the same units as the correct answer.", "input_type": "mathematical_expression", "default_value": "10^-12", "subvars": true}], "public_availability": "always", "published": true, "extensions": ["quantities"]}], "resources": [["question-resources/box_pooNgKk.svg", "/srv/numbas/media/question-resources/box_pooNgKk.svg"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "variable_groups": [], "parts": [{"settings": {"allow_unitless": true, "different_units_action": "convert", "correctAnswer": "width*height*length in \"m^3\"", "hint": "remind units", "wiggle": "10^-12", "different_units_penalty": "100"}, "unitTests": [], "marks": 1, "showCorrectAnswer": true, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "prompt": "

What is the volume of the parcel?

", "extendBaseMarkingAlgorithm": true, "type": "quantity", "scripts": {}, "customName": "", "useCustomName": false, "customMarkingAlgorithm": "", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst"}, {"settings": {"allow_unitless": true, "different_units_action": "convert", "correctAnswer": "surface_area in \"m^2\"", "hint": "remind units", "wiggle": "10^-12", "different_units_penalty": "100"}, "unitTests": [], "marks": 1, "showCorrectAnswer": true, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "prompt": "

What is the surface area of the parcel?

", "extendBaseMarkingAlgorithm": true, "type": "quantity", "scripts": {}, "customName": "", "useCustomName": false, "customMarkingAlgorithm": "", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst"}, {"unitTests": [], "variableReplacements": [], "marks": 0, "matrix": "classification_matrix", "minMarks": 0, "adaptiveMarkingPenalty": 0, "type": "1_n_2", "shuffleChoices": false, "customName": "", "useCustomName": false, "showCellAnswerState": true, "showFeedbackIcon": true, "displayColumns": 0, "showCorrectAnswer": true, "displayType": "radiogroup", "prompt": "

The parcel company classifies parcels based on the following formula:

\n

\$d = 2(a+b) + c \$

\n

Where $a$ and $b$ are the two shortest sides of the parcel, and $c$ is the longest side.

\n

The parcels are classified as follows:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SizeClass
$d<\\var{small_limit}$Small
$\\var{small_limit} \\leq d < \\var{large_limit}$Medium
$d \\geq \\var{large_limit}$Large
\n

How is this parcel classified?

", "choices": ["Small", "Medium", "Large"], "customMarkingAlgorithm": "", "scripts": {}, "maxMarks": 0, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst"}], "tags": [], "ungrouped_variables": ["width", "height", "length", "volume", "surface_area", "sorted_sides", "d", "small_limit", "large_limit", "classification_matrix"], "statement": "

You need to post a parcel with the following dimensions:

\n
\n
• Width: {width}
• \n
• Height: {height}
• \n
• Length: {length}
• \n
\n

(not drawn to scale)

", "preamble": {"js": "", "css": ""}, "metadata": {"description": "

Given a parcel's width, height and length, calculate its volume and surface area. Additionally, classify its size based on a formula inspired by a real delivery company (as mad as it sounds!).

\n

The student must give units with each measurement.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "advice": "

#### a)

\n

The volume of the parcel is given by

\n

\\begin{align}
\\text{volume} &= \\text{width} \\times \\text{height} \\times \\text{length} \\\\
&= \\var{width} \\times \\var{height} \\times \\var{length} \\\\
&= \\var{volume in \"m^3\"}
\\end{align}

", "functions": {}, "variables": {"large_limit": {"name": "large_limit", "description": "", "templateType": "anything", "definition": "qty(250,\"cm\")", "group": "Ungrouped variables"}, "small_limit": {"name": "small_limit", "description": "", "templateType": "anything", "definition": "qty(100,\"cm\")", "group": "Ungrouped variables"}, "sorted_sides": {"name": "sorted_sides", "description": "", "templateType": "anything", "definition": "sort([width,height,length])", "group": "Ungrouped variables"}, "surface_area": {"name": "surface_area", "description": "", "templateType": "anything", "definition": "2*(width*height + width*length + length*height)", "group": "Ungrouped variables"}, "d": {"name": "d", "description": "", "templateType": "anything", "definition": "2*(sorted_sides[0]+sorted_sides[1])+sorted_sides[2]", "group": "Ungrouped variables"}, "volume": {"name": "volume", "description": "", "templateType": "anything", "definition": "width*length*height in \"m^3\"", "group": "Ungrouped variables"}, "classification_matrix": {"name": "classification_matrix", "description": "", "templateType": "anything", "definition": "switch(\n d=large_limit,\n [0,0,1]\n ,\n [0,1,0]\n)", "group": "Ungrouped variables"}, "width": {"name": "width", "description": "", "templateType": "anything", "definition": "quantity(random(20..50#5), \"cm\")", "group": "Ungrouped variables"}, "length": {"name": "length", "description": "

The length of the parcel. Randomly given in either metres or centimetres.

", "templateType": "anything", "definition": "quantity(random(50..250#10),\"cm\") in random(\"m\",\"cm\")", "group": "Ungrouped variables"}, "height": {"name": "height", "description": "", "templateType": "anything", "definition": "quantity(random(10..scalar(width in \"cm\")#10),\"cm\")", "group": "Ungrouped variables"}}, "rulesets": {}}, {"name": "Calculate concentration of solution", "extensions": ["quantities"], "custom_part_types": [{"source": {"pk": 7, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/7/edit"}, "name": "Quantity with units", "short_name": "quantity", "description": "

The student enters a quantity with units.

The scalar part of the student's quantity

", "definition": "match_student_number[1]"}, {"name": "raw_student_units", "description": "

The units of the student's quantity, before converting.

The units of the student's quantity.

\n

If the student used units incompatible with the units in the expected answer, and the \"what to do if incompatible units used\" option is set to \"mark as if correct units used\", the student's units are ignored and the expected units are used instead.

", "definition": "if(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)"}, {"name": "student_quantity", "description": "

The student's answer, interpreted as a quantity.

\n

Marking fails if the student does not enter a valid quantity.

", "definition": "apply(student_units);\ntry(\n student_number * student_units,\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "correct_quantity", "description": "", "definition": "settings[\"correctAnswer\"]"}, {"name": "compatible", "description": "

Are the units of the student's quantity compatible with the units of the expected quantity?

", "definition": "if(compatible(raw_student_units,correct_quantity),\n true\n,\n let(message,\"Your answer does not have the correct dimensions.\",\n if(settings[\"incompatible_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n if(settings[\"incompatible_units_action\"]=\"convert\",\n incorrect(\"Your answer does not have the correct dimensions. It will be marked as if the correct dimensions were used, and then a penalty will be applied.\")\n ,\n incorrect(\"Your answer does not have the correct dimensions.\");\n end()\n )\n );\n false\n )\n)"}, {"name": "correct_units", "description": "", "definition": "units(correct_quantity)"}, {"name": "same_units", "description": "

/Are the student's quantity and the expected quantity in exactly the same units?

", "definition": "assert(raw_student_units=correct_units,\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+units_string(correct_units)+\".\", \"Your answer is not in the expected units.\"),\n switch(\n settings[\"different_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n settings[\"different_units_action\"]=\"incorrect\",\n incorrect(message); \n warn(message);\n end()\n ,\n settings[\"different_units_action\"]=\"warn\",\n warn(message);\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)"}, {"name": "has_units", "description": "", "definition": "assert(not unitless(student_quantity),\n assert(settings[\"allow_unitless\"],\n warn(\"You must include the units in your answer.\");\n fail(\"You did not include units in your answer.\")\n )\n)"}, {"name": "can_compare", "description": "

Can the student's answer be compared with the correct answer? True if compatible units used, or \"mark as if correct units used\" selected.

", "definition": "compatible or settings[\"incompatible_units_action\"]=\"convert\""}, {"name": "close_enough", "description": "

Is the student's quantity within the allowed tolerance of the expected answer?

", "definition": "if(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)"}, {"name": "wiggle", "description": "", "definition": "units(correct_quantity)*abs(eval(settings[\"wiggle\"]))"}, {"name": "valid_number", "description": "

Is the scalar part of the student's answer a valid number?

", "definition": "if(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )\n"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The expected quantity.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "hint", "label": "Input hint", "help_url": "", "hint": "", "input_type": "dropdown", "default_value": "remind units", "choices": [{"value": "none", "label": "None"}, {"value": "remind units", "label": "Remind to include units"}, {"value": "show units", "label": "Show required units"}]}, {"name": "allow_unitless", "label": "Allow unitless answer?", "help_url": "", "hint": "If not ticked, the student is prevented from submitting an answer without specifying units.", "input_type": "checkbox", "default_value": true}, {"name": "incompatible_units_action", "label": "What to do if incompatible units used", "help_url": "", "hint": "If the student's answer is given in units incompatible with the correct answer's units:
\n
\n
• \"Prevent submission\": Prevent the student from submitting until they use compatible units
• \n
• \"Mark as incorrect\": Mark the student's answer as incorrect.
• \n
• \"Mark as if correct units used\": Mark the student's answer as if they used the correct units, and apply the \"different units used\" penalty.
• \n
", "input_type": "dropdown", "default_value": "incorrect", "choices": [{"value": "incorrect", "label": "Mark as incorrect"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "convert", "label": "Mark as if correct units used"}]}, {"name": "different_units_action", "label": "What to do if different units used", "help_url": "", "hint": "If the student's answer is given in different units to the expected answer:
\n
\n
• \"Convert\" - silently convert the student's answer to the units used in the correct answer.
• \n
• \"Warn and convert\" - show a warning to the student, but convert.
• \n
• \"Prevent submission\" - don't allow the student to submit, and show a warning that they must use the same units.
• \n
• \"Mark incorrect\" - the student's answer is marked as incorrect.
• \n
", "input_type": "dropdown", "default_value": "convert", "choices": [{"value": "convert", "label": "Convert"}, {"value": "warn", "label": "Warn and convert"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "incorrect", "label": "Mark incorrect"}]}, {"name": "different_units_penalty", "label": "Penalty if different units used", "help_url": "", "hint": "This penalty is applied if the student gives their answer in different units to the expected answer. The selected percentage of the student's score is taken away.", "input_type": "percent", "default_value": "100"}, {"name": "wiggle", "label": "Margin of error", "help_url": "", "hint": "The student's answer is marked correct if the difference between it and the correct answer is at most this value, measured in the same units as the correct answer.", "input_type": "mathematical_expression", "default_value": "10^-12", "subvars": true}], "public_availability": "always", "published": true, "extensions": ["quantities"]}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "parts": [{"settings": {"different_units_action": "convert", "correctAnswer": "concentration_acid", "allow_unitless": false, "different_units_penalty": "100", "wiggle": "10^-12", "hint": "show units"}, "showFeedbackIcon": true, "useCustomName": false, "variableReplacements": [], "steps": [{"settings": {"different_units_action": "incorrect", "correctAnswer": "amount_alkali in \"dm^3\"", "allow_unitless": false, "different_units_penalty": "100", "wiggle": "10^-12", "hint": "show units"}, "showFeedbackIcon": true, "useCustomName": false, "prompt": "

First, convert the amount of sodium hydroxide to {units_string(qty(\"dm^3\"))}.

\n

\$\\var{qty(1,\"cm^3\")} = \\var{qty(1,\"cm^3\") in \"dm^3\"} \$

", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "unitTests": [], "type": "quantity", "scripts": {}, "customName": "", "adaptiveMarkingPenalty": 0, "marks": 1, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"settings": {"different_units_action": "convert", "correctAnswer": "moles_alkali", "allow_unitless": false, "different_units_penalty": "100", "wiggle": "10^-12", "hint": "show units"}, "showFeedbackIcon": true, "useCustomName": false, "prompt": "

Next, work out the number of moles of sodium hydroxide:

\n

\$\\text{number of moles} = \\text{concentration} \\times \\text{volume} \$

", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "unitTests": [], "type": "quantity", "scripts": {}, "customName": "", "adaptiveMarkingPenalty": 0, "marks": 1, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"settings": {"different_units_action": "convert", "correctAnswer": "moles_acid in \"mol\"", "allow_unitless": false, "different_units_penalty": "100", "wiggle": "10^-12", "hint": "show units"}, "showFeedbackIcon": true, "useCustomName": false, "prompt": "

Work out the number of moles of acid using the balanced equation

\n

\$\\mathrm{HCl_{(aq)} + NaOH_{(aq)} \\rightarrow NaCl_{(aq)} + H_2O_{(l)}} \$

\n

This is a 1:1 reaction, so how many moles of $\\mathrm{HCl}$ are neutralised by the $\\mathrm{NaOH}$?

", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "unitTests": [], "type": "quantity", "scripts": {}, "customName": "", "adaptiveMarkingPenalty": 0, "marks": 1, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"settings": {"different_units_action": "convert", "correctAnswer": "concentration_acid in \"mol/dm^3\"", "allow_unitless": false, "different_units_penalty": "100", "wiggle": "10^-12", "hint": "show units"}, "showFeedbackIcon": true, "useCustomName": false, "prompt": "

Finally, work out the concentration of the acid:

\n

\$\\text{concentration} = \\frac{\\text{number of moles}}{\\text{volume}} \$

", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "unitTests": [], "type": "quantity", "scripts": {}, "customName": "", "adaptiveMarkingPenalty": 0, "marks": 1, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}], "prompt": "

What was the concentration of the hydrochloric acid?

", "extendBaseMarkingAlgorithm": true, "stepsPenalty": 0, "unitTests": [], "type": "quantity", "scripts": {}, "customName": "", "adaptiveMarkingPenalty": 0, "marks": "10", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}], "variable_groups": [], "ungrouped_variables": ["amount_acid", "amount_alkali", "concentration_alkali", "moles_alkali", "reaction_ratio", "moles_acid", "concentration_acid"], "tags": [], "statement": "

{amount_acid} of dilute hydrochloric acid is neutralised by {amount_alkali} of {concentration_alkali} sodium hydroxide.

", "variables": {"moles_alkali": {"definition": "amount_alkali*concentration_alkali in \"mol\"", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "moles_alkali"}, "concentration_alkali": {"definition": "qty(random(0.2..0.9#0.1), \"mol/dm^3\")", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "concentration_alkali"}, "moles_acid": {"definition": "reaction_ratio * moles_alkali", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "moles_acid"}, "reaction_ratio": {"definition": "1", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "reaction_ratio"}, "amount_alkali": {"definition": "(random(2..3)/random(1,2,5))*amount_acid", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "amount_alkali"}, "amount_acid": {"definition": "qty(random(10..40#5),\"cm^3\")", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "amount_acid"}, "concentration_acid": {"definition": "moles_acid/amount_acid in \"mol/dm^3\"", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "concentration_acid"}}, "functions": {}, "rulesets": {}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Calculate the concentration of a dilute acid given the amount and concentration of dilute alkali to neutralise it. Cribbed from this Bitesize problem.

\n

There are steps to break down the calculation, and the student must give units at each step.

"}, "preamble": {"css": "", "js": ""}, "advice": "

Since the acid is neutralised, we can conclude that all of it has reacted with the sodium hydroxide.

\n

The equation of the reaction is:

\n

\$\\mathrm{HCl_{(aq)} + NaOH_{(aq)} \\rightarrow NaCl_{(aq)} + H_2O_{(l)}} \$

\n

1 mole of $\\mathrm{HCl}$ reacts with 1 mole of $\\mathrm{NaOH}$, so the number of moles of $\\mathrm{HCl}$ must be the same as the number of moles of $\\mathrm{NaOH}$.

\n

To work out the number of moles of $\\mathrm{NaOH}$, use the formula:

\n

\$\\text{number of moles} = \\text{concentration} \\times \\text{volume} \$

\n

Since the concentration is given in {units_string(concentration_alkali)}, first convert the amount of sodium hydroxide to the same units:

\n

\$\\var{amount_alkali} = \\var{amount_alkali in (qty(1,\"mol\")/concentration_alkali)} \$

\n

Now, the number of moles of $\\mathrm{NaOH}$ is:

\n

\\begin{align}
\\text{number of moles} &= \\text{concentration} \\times \\text{volume}  \\\\
&= \\var{concentration_alkali} \\times \\var{amount_alkali in \"dm^3\"} \\\\
&= \\var{moles_alkali}
\\end{align}

\n

Finally, we can work out the concentration of the hydrochloric acid:

\n

\\begin{align}
\\text{concentration} &= \\frac{\\text{number of moles}}{\\text{volume}} \\\\
&= \\simplify{{moles_acid}/{amount_acid}} \\\\
&= \\simplify{{moles_acid}/{amount_acid}} \\\\
&= \\var{concentration_acid}
\\end{align}

", "variablesTest": {"maxRuns": 100, "condition": ""}}]}], "showQuestionGroupNames": false, "name": "Quantities extension demo", "navigation": {"allowregen": true, "showfrontpage": false, "onleave": {"action": "none", "message": ""}, "reverse": true, "browse": true, "preventleave": false, "showresultspage": "oncompletion"}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "duration": 0, "percentPass": 0, "showstudentname": true, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Some questions that use the quantities extension to handle units.

"}, "feedback": {"intro": "", "showactualmark": true, "feedbackmessages": [], "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0}, "type": "exam", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": ["quantities"], "custom_part_types": [{"source": {"pk": 7, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/7/edit"}, "name": "Quantity with units", "short_name": "quantity", "description": "

The student enters a quantity with units.

The scalar part of the student's quantity

", "definition": "match_student_number[1]"}, {"name": "raw_student_units", "description": "

The units of the student's quantity, before converting.

The units of the student's quantity.

\n

If the student used units incompatible with the units in the expected answer, and the \"what to do if incompatible units used\" option is set to \"mark as if correct units used\", the student's units are ignored and the expected units are used instead.

", "definition": "if(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)"}, {"name": "student_quantity", "description": "

The student's answer, interpreted as a quantity.

\n

Marking fails if the student does not enter a valid quantity.

", "definition": "apply(student_units);\ntry(\n student_number * student_units,\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "correct_quantity", "description": "", "definition": "settings[\"correctAnswer\"]"}, {"name": "compatible", "description": "

Are the units of the student's quantity compatible with the units of the expected quantity?

", "definition": "if(compatible(raw_student_units,correct_quantity),\n true\n,\n let(message,\"Your answer does not have the correct dimensions.\",\n if(settings[\"incompatible_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n if(settings[\"incompatible_units_action\"]=\"convert\",\n incorrect(\"Your answer does not have the correct dimensions. It will be marked as if the correct dimensions were used, and then a penalty will be applied.\")\n ,\n incorrect(\"Your answer does not have the correct dimensions.\");\n end()\n )\n );\n false\n )\n)"}, {"name": "correct_units", "description": "", "definition": "units(correct_quantity)"}, {"name": "same_units", "description": "

/Are the student's quantity and the expected quantity in exactly the same units?

", "definition": "assert(raw_student_units=correct_units,\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+units_string(correct_units)+\".\", \"Your answer is not in the expected units.\"),\n switch(\n settings[\"different_units_action\"]=\"prevent\",\n warn(message);\n fail(message)\n ,\n settings[\"different_units_action\"]=\"incorrect\",\n incorrect(message); \n warn(message);\n end()\n ,\n settings[\"different_units_action\"]=\"warn\",\n warn(message);\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(1-settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)"}, {"name": "has_units", "description": "", "definition": "assert(not unitless(student_quantity),\n assert(settings[\"allow_unitless\"],\n warn(\"You must include the units in your answer.\");\n fail(\"You did not include units in your answer.\")\n )\n)"}, {"name": "can_compare", "description": "

Can the student's answer be compared with the correct answer? True if compatible units used, or \"mark as if correct units used\" selected.

", "definition": "compatible or settings[\"incompatible_units_action\"]=\"convert\""}, {"name": "close_enough", "description": "

Is the student's quantity within the allowed tolerance of the expected answer?

", "definition": "if(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)"}, {"name": "wiggle", "description": "", "definition": "units(correct_quantity)*abs(eval(settings[\"wiggle\"]))"}, {"name": "valid_number", "description": "

Is the scalar part of the student's answer a valid number?

", "definition": "if(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )\n"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The expected quantity.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "hint", "label": "Input hint", "help_url": "", "hint": "", "input_type": "dropdown", "default_value": "remind units", "choices": [{"value": "none", "label": "None"}, {"value": "remind units", "label": "Remind to include units"}, {"value": "show units", "label": "Show required units"}]}, {"name": "allow_unitless", "label": "Allow unitless answer?", "help_url": "", "hint": "If not ticked, the student is prevented from submitting an answer without specifying units.", "input_type": "checkbox", "default_value": true}, {"name": "incompatible_units_action", "label": "What to do if incompatible units used", "help_url": "", "hint": "If the student's answer is given in units incompatible with the correct answer's units:
\n
\n
• \"Prevent submission\": Prevent the student from submitting until they use compatible units
• \n
• \"Mark as incorrect\": Mark the student's answer as incorrect.
• \n
• \"Mark as if correct units used\": Mark the student's answer as if they used the correct units, and apply the \"different units used\" penalty.
• \n
", "input_type": "dropdown", "default_value": "incorrect", "choices": [{"value": "incorrect", "label": "Mark as incorrect"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "convert", "label": "Mark as if correct units used"}]}, {"name": "different_units_action", "label": "What to do if different units used", "help_url": "", "hint": "If the student's answer is given in different units to the expected answer:
\n
\n
• \"Convert\" - silently convert the student's answer to the units used in the correct answer.
• \n
• \"Warn and convert\" - show a warning to the student, but convert.
• \n
• \"Prevent submission\" - don't allow the student to submit, and show a warning that they must use the same units.
• \n
• \"Mark incorrect\" - the student's answer is marked as incorrect.
• \n
", "input_type": "dropdown", "default_value": "convert", "choices": [{"value": "convert", "label": "Convert"}, {"value": "warn", "label": "Warn and convert"}, {"value": "prevent", "label": "Prevent submission"}, {"value": "incorrect", "label": "Mark incorrect"}]}, {"name": "different_units_penalty", "label": "Penalty if different units used", "help_url": "", "hint": "This penalty is applied if the student gives their answer in different units to the expected answer. The selected percentage of the student's score is taken away.", "input_type": "percent", "default_value": "100"}, {"name": "wiggle", "label": "Margin of error", "help_url": "", "hint": "The student's answer is marked correct if the difference between it and the correct answer is at most this value, measured in the same units as the correct answer.", "input_type": "mathematical_expression", "default_value": "10^-12", "subvars": true}], "public_availability": "always", "published": true, "extensions": ["quantities"]}], "resources": [["question-resources/box_pooNgKk.svg", "/srv/numbas/media/question-resources/box_pooNgKk.svg"]]}