-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquantity_part_type.json
1 lines (1 loc) · 7.11 KB
/
quantity_part_type.json
1
{"input_widget":"string","published":false,"can_be_step":true,"can_be_gap":true,"input_options":{"hint":{"value":"switch(\n settings[\"hint\"]=\"remind units\",\n \"Include units in your answer.\",\n settings[\"hint\"]=\"show units\",\n \"Give your answer in \"+units_string(settings[\"correctAnswer\"])\n ,\n \"\"\n)","static":false},"correctAnswer":"string(settings[\"correctAnswer\"])","allowEmpty":{"value":false,"static":true}},"help_url":"","name":"Quantity","marking_script":"mark:\napply(student_quantity);\napply(has_units);\napply(compatible);\ncorrectif(student_quantity=correct_quantity);\napply(same_units)\n\ninterpreted_answer:\nstudent_quantity\n\nallowed_notation_styles:\n[\"plain\",\"en\"]\n\nmatch_student_number:\nmatchnumber(studentAnswer,allowed_notation_styles)\n\nstudent_number:\nmatch_student_number[1]\n\nstudent_units:\nstudentAnswer[len(match_student_number[0])..len(studentAnswer)]\n\nstudent_quantity:\ntry(\n student_number * quantity(student_units),\n message,\n warn(\"Your answer is not a valid quantity.\");\n incorrect(message)\n)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nassert(compatible(student_quantity,correct_quantity),\n incorrect(\"Your answer does not have the correct dimensions.\");\n end();\n false\n)\n\ncorrect_units:\nunits_string(correct_quantity)\n\nsame_units:\nassert(units(student_quantity)=units(correct_quantity),\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+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(settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)\n\nhas_units:\nassert(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)","source":{"edit_page":"/part_type/27/edit","author":{"pk":1,"name":"Christian Lawson-Perfect"},"pk":27},"settings":[{"input_type":"code","evaluate":true,"default_value":"","hint":"The expected quantity.","label":"Correct answer","help_url":"","name":"correctAnswer"},{"input_type":"dropdown","default_value":"remind units","hint":"","choices":[{"value":"none","label":"None"},{"value":"remind units","label":"Remind to include units"},{"value":"show units","label":"Show required units"}],"label":"Input hint","help_url":"","name":"hint"},{"input_type":"checkbox","default_value":true,"hint":"If not ticked, the student is prevented from submitting an answer without specifying units.","label":"Allow unitless answer?","help_url":"","name":"allow_unitless"},{"input_type":"dropdown","default_value":"convert","hint":"If the student's answer is given in different units to the expected answer:<br />\n<ul>\n<li>\"Convert\" - silently convert the student's answer to the units used in the correct answer.</li>\n<li>\"Warn and convert\" - show a warning to the student, but convert.</li>\n<li>\"Prevent submission\" - don't allow the student to submit, and show a warning that they must use the same units.</li>\n<li>\"Mark incorrect\" - the student's answer is marked as incorrect.</li>\n</ul>","choices":[{"value":"convert","label":"Convert"},{"value":"warn","label":"Warn and convert"},{"value":"Prevent","label":"Prevent submission"},{"value":"incorrect","label":"Mark incorrect"}],"label":"What to do if different units used","help_url":"","name":"different_units_action"},{"input_type":"percent","default_value":"100","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 retained.","label":"Penalty if different units used","help_url":"","name":"different_units_penalty"}],"extensions":["quantities"],"description":"<p>The student enters a quantity with units. Their answer is marked correct if they give both the right amount and the right units.</p>","public_availability":"restricted","marking_notes":[{"description":"This is the main marking note. It should award credit and provide feedback based on the student's answer.","name":"mark","definition":"apply(student_quantity);\napply(has_units);\napply(compatible);\ncorrectif(student_quantity=correct_quantity);\napply(same_units)"},{"description":"A value representing the student's answer to this part.","name":"interpreted_answer","definition":"student_quantity"},{"description":"","name":"allowed_notation_styles","definition":"[\"plain\",\"en\"]"},{"description":"","name":"match_student_number","definition":"matchnumber(studentAnswer,allowed_notation_styles)"},{"description":"","name":"student_number","definition":"match_student_number[1]"},{"description":"","name":"student_units","definition":"studentAnswer[len(match_student_number[0])..len(studentAnswer)]"},{"description":"<p>The student's answer, interpreted as a quantity.</p>\n<p>Marking fails if the student does not enter a valid quantity.</p>","name":"student_quantity","definition":"try(\n student_number * quantity(student_units),\n message,\n warn(\"Your answer is not a valid quantity.\");\n incorrect(message)\n)"},{"description":"","name":"correct_quantity","definition":"settings[\"correctAnswer\"]"},{"description":"<p>Are the units of the student's quantity compatible with the units of the expected quantity?</p>","name":"compatible","definition":"assert(compatible(student_quantity,correct_quantity),\n incorrect(\"Your answer does not have the correct dimensions.\");\n end();\n false\n)"},{"description":"","name":"correct_units","definition":"units_string(correct_quantity)"},{"description":"<p>Are the student's quantity and the expected quantity in exactly the same units?</p>","name":"same_units","definition":"assert(units(student_quantity)=units(correct_quantity),\n let(\n message,if(settings[\"hint\"]=\"show units\",\"You did not give your answer in \"+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(settings[\"different_units_penalty\"],message)\n ,\n settings[\"different_units_penalty\"]<1,\n multiply_credit(settings[\"different_units_penalty\"],message)\n ,\n false\n )\n );\n false\n)"},{"description":"","name":"has_units","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)"}],"short_name":"quantity"}