// Numbas version: exam_results_page_options {"navigation": {"browse": true, "preventleave": true, "onleave": {"message": "

Question unanswered!

", "action": "warnifunattempted"}, "allowsteps": true, "startpassword": "", "showfrontpage": true, "showresultspage": "oncompletion", "allowregen": true, "reverse": true}, "metadata": {"description": "", "licence": "None specified"}, "name": "LO3 Practice Problems", "timing": {"timedwarning": {"message": "", "action": "none"}, "timeout": {"message": "", "action": "none"}, "allowPause": true}, "percentPass": "0", "duration": 0, "showQuestionGroupNames": false, "showstudentname": true, "feedback": {"showtotalmark": true, "showanswerstate": true, "advicethreshold": 0, "showactualmark": true, "intro": "

These practice problems cover LO3 Free and Forced Vibration for Damped and Undamped cases.

", "allowrevealanswer": true, "feedbackmessages": []}, "question_groups": [{"pickQuestions": 1, "pickingStrategy": "all-shuffled", "name": "AMR222", "questions": [{"name": "LO3.2 - Forced Vibration 2", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_with_3_springs_and_force.png", "/srv/numbas/media/question-resources/mass_with_3_springs_and_force.png"], ["question-resources/mass_with_3_springs_damper_and_force.png", "/srv/numbas/media/question-resources/mass_with_3_springs_damper_and_force.png"], ["question-resources/Cantilever_mass.png", "/srv/numbas/media/question-resources/Cantilever_mass.png"], ["question-resources/horizontal_mass_spring_damper.png", "/srv/numbas/media/question-resources/horizontal_mass_spring_damper.png"], ["question-resources/mass_damper_spring_oOx9vMZ.png", "/srv/numbas/media/question-resources/mass_damper_spring_oOx9vMZ.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "tags": [], "parts": [{"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": true, "settings": {"different_units_action": "convert", "correctAnswer": "quantity({wd}, \"rad/s\")", "hint": "remind units", "wiggle": "{error}*{wn}", "different_units_penalty": "100", "allow_unitless": true}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

What would be the damped angular frequency of this system? Note: if the result is imaginary, answer \"0 rad/s\"

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": true, "settings": {"different_units_action": "convert", "correctAnswer": "quantity (({sprktot}/{mass1})^0.5, \"rad/s\")", "hint": "remind units", "wiggle": "{error}*({sprktot}/{mass1})^0.5", "different_units_penalty": "100", "allow_unitless": false}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

What would be the natural angular frequency of this system?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"correctAnswerStyle": "plain", "prompt": "

What would be the damping ratio for this system?

", "adaptiveMarkingPenalty": 0, "scripts": {}, "mustBeReducedPC": 0, "minValue": "{minerror}*{zeta}", "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacements": [], "showFeedbackIcon": true, "mustBeReduced": false, "unitTests": [], "type": "numberentry", "useCustomName": false, "correctAnswerFraction": false, "showFractionHint": true, "allowFractions": false, "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "{maxerror}*{zeta}", "marks": 1, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "displayAnswer": "{dampness}", "adaptiveMarkingPenalty": 0, "showFeedbackIcon": true, "unitTests": [], "type": "patternmatch", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

Would you describe this system as damped, underdamped, or critically damped?

", "matchMode": "exact", "extendBaseMarkingAlgorithm": true, "customName": "", "answer": "{dampness}", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"correctAnswerStyle": "plain", "prompt": "

Consiering the maximum desirable deflection reported ({Xmax} m), what would be the magnification factor for this system?

", "adaptiveMarkingPenalty": 0, "scripts": {}, "mustBeReducedPC": 0, "minValue": "{minerror}*{magfactor}", "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacements": [], "showFeedbackIcon": true, "mustBeReduced": false, "unitTests": [], "type": "numberentry", "useCustomName": false, "correctAnswerFraction": false, "showFractionHint": true, "allowFractions": false, "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "{maxerror}*{magfactor}", "marks": 1, "variableReplacementStrategy": "originalfirst"}, {"correctAnswerStyle": "plain", "prompt": "

If instead of deflection, we considered the force F(t) to have an angular frequency of {w} rad/s, what would be the magnification factor in this case?

", "adaptiveMarkingPenalty": 0, "scripts": {}, "mustBeReducedPC": 0, "minValue": "{minerror}*1/(((((1-(({w}/{wn})^2))^2)+((2*{zeta}*{w}/{wn})^2)))^0.5)", "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacements": [], "showFeedbackIcon": true, "mustBeReduced": false, "unitTests": [], "type": "numberentry", "useCustomName": false, "correctAnswerFraction": false, "showFractionHint": true, "allowFractions": false, "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "{maxerror}*1/(((((1-(({w}/{wn})^2))^2)+((2*{zeta}*{w}/{wn})^2)))^0.5)", "marks": 1, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": true, "settings": {"different_units_action": "convert", "correctAnswer": "quantity (arctan((2*{zeta}*{w}/{wn})/(1-({w}/{wn})^2)), \"rad\") ", "hint": "remind units", "wiggle": "{error}*{arctan((2*{zeta}*{w}/{wn})/(1-({w}/{wn})^2))}", "different_units_penalty": "100", "allow_unitless": true}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

Considering the force F(t) to have an angular frequency of {w} rad/s, what would be the phase angle for the system's response?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}], "variables": {"wd": {"name": "wd", "description": "", "definition": "{wn}*((1-({zeta}^2))^0.5)", "templateType": "anything", "group": "Results"}, "zeta": {"name": "zeta", "description": "", "definition": "{damc1}/((4*{sprktot}*{mass1})^0.5)", "templateType": "anything", "group": "Results"}, "error": {"name": "error", "description": "", "definition": "abs({maxerror}-{minerror})", "templateType": "anything", "group": "Ungrouped variables"}, "wn": {"name": "wn", "description": "", "definition": "({sprktot}/{mass1})^0.5", "templateType": "anything", "group": "Results"}, "damc1": {"name": "damc1", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "mass1": {"name": "mass1", "description": "", "definition": "random(10 .. 250#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "maxerror": {"name": "maxerror", "description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "definition": "1.1", "templateType": "anything", "group": "Ungrouped variables"}, "sprktot": {"name": "sprktot", "description": "", "definition": "{sprk1}", "templateType": "anything", "group": "Results"}, "w": {"name": "w", "description": "", "definition": "random(0.01 .. 10#0.01)", "templateType": "randrange", "group": "Ungrouped variables"}, "minerror": {"name": "minerror", "description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "definition": "0.9", "templateType": "anything", "group": "Ungrouped variables"}, "g": {"name": "g", "description": "", "definition": "9.81", "templateType": "anything", "group": "Ungrouped variables"}, "F0": {"name": "F0", "description": "", "definition": "random(100 .. 2000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "sprk3": {"name": "sprk3", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "Xmax": {"name": "Xmax", "description": "", "definition": "random(0.05 .. 0.3#0.01)", "templateType": "randrange", "group": "Ungrouped variables"}, "sprk2": {"name": "sprk2", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "magfactor": {"name": "magfactor", "description": "", "definition": "{Xmax}/{X0}", "templateType": "anything", "group": "Results"}, "X0": {"name": "X0", "description": "", "definition": "{F0}/{sprktot}", "templateType": "anything", "group": "Results"}, "dampness": {"name": "dampness", "description": "", "definition": "if ({zeta}>1, \"overdamped\", (if ({zeta}<1, \"underdamped\", \"critically damped\")))", "templateType": "anything", "group": "Results"}, "sprk1": {"name": "sprk1", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}}, "metadata": {"licence": "None specified", "description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems."}, "variable_groups": [{"name": "Results", "variables": ["wn", "X0", "sprktot", "magfactor", "zeta", "dampness", "wd"]}], "functions": {}, "advice": "", "rulesets": {}, "preamble": {"js": "", "css": ""}, "statement": "

The following diagram represents a mass suspended by a spring-damper system:

\n

\n

\n

The mass is {mass1} kg, the spring constant is k = {sprk1} N/m, and  the damping coefficient is C = {damc1} Ns/m. A force F(t) = {F0}sin(wt) N is applied to the system vertically. A maximum deflection for this system's safety has been determined to be {Xmax}.

", "ungrouped_variables": ["mass1", "sprk1", "sprk2", "sprk3", "damc1", "g", "maxerror", "minerror", "F0", "Xmax", "w", "error"], "variablesTest": {"condition": "", "maxRuns": 100}}, {"name": "LO3.1 - Free Vibration 5", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_wit_2_springs.png", "/srv/numbas/media/question-resources/mass_wit_2_springs.png"], ["question-resources/horizontal_spring_with_mass.png", "/srv/numbas/media/question-resources/horizontal_spring_with_mass.png"], ["question-resources/mass_with_6_springs_and_2_dampers.png", "/srv/numbas/media/question-resources/mass_with_6_springs_and_2_dampers.png"], ["question-resources/mass_damper_spring.png", "/srv/numbas/media/question-resources/mass_damper_spring.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "preamble": {"js": "", "css": ""}, "rulesets": {}, "variable_groups": [{"variables": ["zeta", "dampness", "wn"], "name": "Results"}], "ungrouped_variables": ["mass1", "sprk1", "damc1", "g", "maxerror", "minerror", "f1", "x0", "vmax"], "parts": [{"showCorrectAnswer": true, "prompt": "

What would be the natural angular frequency of the system? Note: if the result is imaginary, answer \"0 rad/s\"

", "adaptiveMarkingPenalty": 0, "type": "quantity", "customMarkingAlgorithm": "", "useCustomName": false, "settings": {"allow_unitless": false, "different_units_penalty": "100", "different_units_action": "prevent", "wiggle": "{error}*{wn}", "correctAnswer": "quantity({wn}, \"rad/s\")", "hint": "remind units"}, "variableReplacementStrategy": "originalfirst", "marks": 1, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "showFeedbackIcon": false, "scripts": {}, "unitTests": []}, {"showCorrectAnswer": true, "prompt": "

What would be the natural damped frequency of the system?

", "adaptiveMarkingPenalty": 0, "type": "quantity", "customMarkingAlgorithm": "", "useCustomName": false, "settings": {"allow_unitless": false, "different_units_penalty": "100", "different_units_action": "prevent", "wiggle": "{error}*{wn}*((1-{zeta}^2)^0.5)", "correctAnswer": "quantity(({wn}*((1-{zeta}^2)^0.5)), \"rad/s\")", "hint": "remind units"}, "variableReplacementStrategy": "originalfirst", "marks": 1, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "showFeedbackIcon": false, "scripts": {}, "unitTests": []}, {"showCorrectAnswer": false, "prompt": "

What would be the oscillatoy period of the system?

", "adaptiveMarkingPenalty": 0, "type": "quantity", "customMarkingAlgorithm": "", "useCustomName": false, "settings": {"allow_unitless": false, "different_units_penalty": "100", "different_units_action": "prevent", "wiggle": "{error}*(2*pi)/({wn}*((1-({zeta})^2)^0.5))", "correctAnswer": "quantity((2*pi)/({wn}*((1-({zeta})^2)^0.5)), \"s\")", "hint": "remind units"}, "variableReplacementStrategy": "originalfirst", "marks": 1, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "showFeedbackIcon": false, "scripts": {}, "unitTests": []}, {"showCorrectAnswer": true, "correctAnswerStyle": "plain", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "useCustomName": false, "marks": 1, "customName": "", "mustBeReducedPC": 0, "allowFractions": false, "prompt": "

What would be the damping ratio of this system?

", "maxValue": "{maxerror}*{zeta}", "correctAnswerFraction": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "showFractionHint": true, "mustBeReduced": false, "unitTests": [], "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "scripts": {}, "minValue": "{minerror}*{zeta}"}, {"showCorrectAnswer": true, "displayAnswer": "{dampness}", "prompt": "

Would you describe this system as damped, underdamped, or critically damped?

", "matchMode": "exact", "adaptiveMarkingPenalty": 0, "type": "patternmatch", "answer": "{dampness}", "customMarkingAlgorithm": "", "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 1, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "showFeedbackIcon": true, "scripts": {}, "unitTests": []}], "functions": {}, "variables": {"wn": {"description": "", "group": "Results", "definition": "({sprk1}/{mass1})^0.5", "templateType": "anything", "name": "wn"}, "sprk1": {"description": "", "group": "Ungrouped variables", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "name": "sprk1"}, "mass1": {"description": "", "group": "Ungrouped variables", "definition": "random(10 .. 10000#1)", "templateType": "randrange", "name": "mass1"}, "g": {"description": "", "group": "Ungrouped variables", "definition": "9.81", "templateType": "anything", "name": "g"}, "maxerror": {"description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "group": "Ungrouped variables", "definition": "1.1", "templateType": "anything", "name": "maxerror"}, "vmax": {"description": "", "group": "Ungrouped variables", "definition": "{x0}*({sprk1}/{mass1})^0.5", "templateType": "anything", "name": "vmax"}, "f1": {"description": "", "group": "Ungrouped variables", "definition": "random(10 .. 4500#10)", "templateType": "randrange", "name": "f1"}, "dampness": {"description": "", "group": "Results", "definition": "if ({zeta}>1, \"overdamped\", (if ({zeta}<1, \"underdamped\", \"critically damped\")))", "templateType": "anything", "name": "dampness"}, "damc1": {"description": "", "group": "Ungrouped variables", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "name": "damc1"}, "minerror": {"description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "group": "Ungrouped variables", "definition": "0.9", "templateType": "anything", "name": "minerror"}, "x0": {"description": "

Starting position of the system.

", "group": "Ungrouped variables", "definition": "{f1}/{sprk1}", "templateType": "anything", "name": "x0"}, "zeta": {"description": "", "group": "Results", "definition": "{damc1}/((4*{sprk1}*{mass1})^0.5)", "templateType": "anything", "name": "zeta"}}, "metadata": {"description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems.", "licence": "None specified"}, "advice": "", "tags": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "statement": "

The following diagram represents a mass connected to a spring-damper system and a vertically-applied force.

\n

\n

The mass is m = {mass1} kg, and the spring constant is k = {sprk1} N/m, and the damping coefficient is C = {damc1} Ns/m; x represents vertical displacement.

"}, {"name": "LO3.2 - Forced Vibration 1", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_with_3_springs_and_force.png", "/srv/numbas/media/question-resources/mass_with_3_springs_and_force.png"], ["question-resources/mass_with_3_springs_damper_and_force.png", "/srv/numbas/media/question-resources/mass_with_3_springs_damper_and_force.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "rulesets": {}, "functions": {}, "tags": [], "ungrouped_variables": ["mass1", "sprk1", "sprk2", "sprk3", "damc1", "g", "maxerror", "minerror", "F0", "Xmax", "w", "error"], "statement": "

The following diagram represents a mass suspended by a spring-damper system:

\n

\n

\n

The mass is {mass1} kg, and the spring constants are k1 = {sprk1} N/m, k2 = {sprk2} N/m, k3 = {sprk3} N/m, and the dampinc coefficient is C1 = {damc1} Ns/m. A force F(t) = {F0}sin(wt) N is applied to the system vertically. A maximum deflection for this system's safety has been determined to be {Xmax}.

", "preamble": {"js": "", "css": ""}, "variable_groups": [{"variables": ["wn", "X0", "sprktot", "magfactor", "zeta", "dampness"], "name": "Results"}], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"licence": "None specified", "description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems."}, "variables": {"dampness": {"group": "Results", "description": "", "definition": "if ({zeta}>1, \"overdamped\", (if ({zeta}<1, \"underdamped\", \"critically damped\")))", "templateType": "anything", "name": "dampness"}, "mass1": {"group": "Ungrouped variables", "description": "", "definition": "random(10 .. 250#1)", "templateType": "randrange", "name": "mass1"}, "X0": {"group": "Results", "description": "", "definition": "{F0}/{sprktot}", "templateType": "anything", "name": "X0"}, "minerror": {"group": "Ungrouped variables", "description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "definition": "0.9", "templateType": "anything", "name": "minerror"}, "sprktot": {"group": "Results", "description": "", "definition": "({sprk1}*{sprk2}/({sprk1}+{sprk2})) + {sprk3}", "templateType": "anything", "name": "sprktot"}, "damc1": {"group": "Ungrouped variables", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "name": "damc1"}, "zeta": {"group": "Results", "description": "", "definition": "{damc1}/((4*{sprktot}*{mass1})^0.5)", "templateType": "anything", "name": "zeta"}, "magfactor": {"group": "Results", "description": "", "definition": "{Xmax}/{X0}", "templateType": "anything", "name": "magfactor"}, "maxerror": {"group": "Ungrouped variables", "description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "definition": "1.1", "templateType": "anything", "name": "maxerror"}, "F0": {"group": "Ungrouped variables", "description": "", "definition": "random(100 .. 2000#1)", "templateType": "randrange", "name": "F0"}, "error": {"group": "Ungrouped variables", "description": "", "definition": "abs({maxerror}-{minerror})", "templateType": "anything", "name": "error"}, "sprk1": {"group": "Ungrouped variables", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "name": "sprk1"}, "Xmax": {"group": "Ungrouped variables", "description": "", "definition": "random(0.05 .. 0.3#0.01)", "templateType": "randrange", "name": "Xmax"}, "wn": {"group": "Results", "description": "", "definition": "({sprktot}/{mass1})^0.5", "templateType": "anything", "name": "wn"}, "g": {"group": "Ungrouped variables", "description": "", "definition": "9.81", "templateType": "anything", "name": "g"}, "sprk3": {"group": "Ungrouped variables", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "name": "sprk3"}, "w": {"group": "Ungrouped variables", "description": "", "definition": "random(0.01 .. 10#0.01)", "templateType": "randrange", "name": "w"}, "sprk2": {"group": "Ungrouped variables", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "name": "sprk2"}}, "advice": "", "parts": [{"showFeedbackIcon": true, "settings": {"correctAnswer": "quantity (({sprktot}/{mass1})^0.5, \"rad/s\")", "hint": "remind units", "different_units_action": "prevent", "wiggle": "{error}*{({sprktot}/{mass1})^0.5}", "allow_unitless": true, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

What would be the natural angular frequency of this system?

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}, {"showFeedbackIcon": true, "settings": {"correctAnswer": "quantity(({wn}*((1-{zeta}^2)^0.5)), \"rad/s\")", "hint": "remind units", "different_units_action": "convert", "wiggle": "{error}*({wn}*((1-{zeta}^2)^0.5))", "allow_unitless": true, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

What would be the damped angular frequency of this system? Note: if the answer is imaginary, answer \"0 rad/s\".

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}, {"mustBeReduced": false, "type": "numberentry", "allowFractions": false, "prompt": "

What would be the damping ratio for this system?

", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "minValue": "{minerror}*{zeta}", "showFeedbackIcon": true, "unitTests": [], "useCustomName": false, "maxValue": "{maxerror}*{zeta}", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "correctAnswerStyle": "plain", "marks": 1, "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "scripts": {}}, {"showFeedbackIcon": true, "unitTests": [], "useCustomName": false, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "answer": "{dampness}", "prompt": "

Would you describe this system as damped, underdamped, or critically damped?

", "matchMode": "exact", "extendBaseMarkingAlgorithm": true, "displayAnswer": "{dampness}", "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}, {"mustBeReduced": false, "type": "numberentry", "allowFractions": false, "prompt": "

Consiering the maximum desirable deflection reported ({Xmax} m), what would be the magnification factor for this system?

", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "minValue": "{minerror}*{magfactor}", "showFeedbackIcon": true, "unitTests": [], "useCustomName": false, "maxValue": "{maxerror}*{magfactor}", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "correctAnswerStyle": "plain", "marks": 1, "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "scripts": {}}, {"mustBeReduced": false, "type": "numberentry", "allowFractions": false, "prompt": "

If instead of deflection, we considered the force F(t) to have an angular frequency of {w} rad/s, what would be the magnification factor in this case?

", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "minValue": "{minerror}*1/(((((1-(({w}/{wn})^2))^2)+((2*{zeta}*{w}/{wn})^2)))^0.5)", "showFeedbackIcon": true, "unitTests": [], "useCustomName": false, "maxValue": "{maxerror}*1/(((((1-(({w}/{wn})^2))^2)+((2*{zeta}*{w}/{wn})^2)))^0.5)", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "correctAnswerStyle": "plain", "marks": 1, "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "scripts": {}}, {"showFeedbackIcon": true, "settings": {"correctAnswer": "quantity (arctan((2*{zeta}*{w}/{wn})/(1-({w}/{wn})^2)), \"rad\") ", "hint": "remind units", "different_units_action": "convert", "wiggle": "{error}*arctan((2*{zeta}*{w}/{wn})/(1-({w}/{wn})^2))", "allow_unitless": true, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

Considering the force F(t) to have an angular frequency of {w} rad/s, what would be the phase angle for the system's response?

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}]}, {"name": "LO3.1 - Free Vibration 3", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_wit_2_springs.png", "/srv/numbas/media/question-resources/mass_wit_2_springs.png"], ["question-resources/horizontal_spring_with_mass.png", "/srv/numbas/media/question-resources/horizontal_spring_with_mass.png"], ["question-resources/mass_with_6_springs_and_2_dampers.png", "/srv/numbas/media/question-resources/mass_with_6_springs_and_2_dampers.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "tags": [], "parts": [{"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": true, "settings": {"different_units_action": "prevent", "correctAnswer": "quantity({k1k2}, \"N/m\")", "hint": "remind units", "wiggle": "{error}*{k1k2}", "different_units_penalty": "100", "allow_unitless": false}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

What would be the combined spring constant for k1 and k2?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": false, "settings": {"different_units_action": "prevent", "correctAnswer": "quantity({k4k5k6}, \"N/m\")", "hint": "remind units", "wiggle": "{error}*{k4k5k6}", "different_units_penalty": "100", "allow_unitless": false}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

What would be the combined spring constant for k4, k5, and k6?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": false, "settings": {"different_units_action": "prevent", "correctAnswer": "quantity({ktot}, \"N/m\")", "hint": "remind units", "wiggle": "{error}*{ktot}", "different_units_penalty": "100", "allow_unitless": false}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

What would be the total spring constant for the system?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": false, "settings": {"different_units_action": "prevent", "correctAnswer": "quantity({damc1damc2}, \"N*s/m\")", "hint": "remind units", "wiggle": "{error}*{damc1damc2}", "different_units_penalty": "100", "allow_unitless": false}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

What would be the total damping coefficient for the system?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "adaptiveMarkingPenalty": 0, "showFeedbackIcon": false, "settings": {"different_units_action": "prevent", "correctAnswer": "quantity(({ktot}/{mass1})^0.5, \"rad/s\")", "hint": "remind units", "wiggle": "{error}*({ktot}/{mass1})^0.5", "different_units_penalty": "100", "allow_unitless": false}, "unitTests": [], "type": "quantity", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

If the mass attached to the spring-damper system is {mass1} kg, what would be the natural angular frequency of the system?

", "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}, {"correctAnswerStyle": "plain", "prompt": "

If the mass attached to the spring-damper system is {mass1} kg, what would be the damping ratio of this system?

", "adaptiveMarkingPenalty": 0, "scripts": {}, "mustBeReducedPC": 0, "minValue": "{minerror}*{zeta}", "customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacements": [], "showFeedbackIcon": true, "mustBeReduced": false, "unitTests": [], "type": "numberentry", "useCustomName": false, "correctAnswerFraction": false, "showFractionHint": true, "allowFractions": false, "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "maxValue": "{maxerror}*{zeta}", "marks": 1, "variableReplacementStrategy": "originalfirst"}, {"variableReplacements": [], "displayAnswer": "{dampness}", "adaptiveMarkingPenalty": 0, "showFeedbackIcon": true, "unitTests": [], "type": "patternmatch", "useCustomName": false, "marks": 1, "scripts": {}, "prompt": "

Would you describe this system as damped, underdamped, or critically damped?

", "matchMode": "exact", "extendBaseMarkingAlgorithm": true, "customName": "", "answer": "{dampness}", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}], "variables": {"damc2": {"name": "damc2", "description": "", "definition": "random(500 .. 2000#10)", "templateType": "randrange", "group": "Ungrouped variables"}, "sprk6": {"name": "sprk6", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "f1": {"name": "f1", "description": "", "definition": "random(10 .. 4500#10)", "templateType": "randrange", "group": "Ungrouped variables"}, "damc1damc2": {"name": "damc1damc2", "description": "", "definition": "{damc1}*{damc2}/({damc1}+{damc2})", "templateType": "anything", "group": "Results"}, "sprk3": {"name": "sprk3", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "sprk2": {"name": "sprk2", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "dampness": {"name": "dampness", "description": "", "definition": "if ({zeta}>1, \"overdamped\", (if ({zeta}<1, \"underdamped\", \"critically damped\")))", "templateType": "anything", "group": "Results"}, "sprk1": {"name": "sprk1", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "k1k2": {"name": "k1k2", "description": "", "definition": "{sprk1}*{sprk2}/({sprk1}+{sprk2})", "templateType": "anything", "group": "Results"}, "error": {"name": "error", "description": "", "definition": "abs({maxerror}-{minerror})", "templateType": "anything", "group": "Ungrouped variables"}, "zeta": {"name": "zeta", "description": "", "definition": "{damc1damc2}/((4*{ktot}*{mass1})^0.5)", "templateType": "anything", "group": "Results"}, "damc1": {"name": "damc1", "description": "", "definition": "random(500 .. 2000#10)", "templateType": "randrange", "group": "Ungrouped variables"}, "mass1": {"name": "mass1", "description": "", "definition": "random(100 .. 250#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "sprk5": {"name": "sprk5", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "k4k5k6": {"name": "k4k5k6", "description": "", "definition": "1/((1/{sprk4})+(1/{sprk5})+(1/{sprk6}))", "templateType": "anything", "group": "Results"}, "g": {"name": "g", "description": "", "definition": "9.81", "templateType": "anything", "group": "Ungrouped variables"}, "minerror": {"name": "minerror", "description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "definition": "0.9", "templateType": "anything", "group": "Ungrouped variables"}, "sprk4": {"name": "sprk4", "description": "", "definition": "random(100 .. 10000#1)", "templateType": "randrange", "group": "Ungrouped variables"}, "x0": {"name": "x0", "description": "

Starting position of the system.

", "definition": "{f1}/{sprk1}", "templateType": "anything", "group": "Ungrouped variables"}, "vmax": {"name": "vmax", "description": "", "definition": "{x0}*({sprk1}/{mass1})^0.5", "templateType": "anything", "group": "Ungrouped variables"}, "ktot": {"name": "ktot", "description": "", "definition": "{k4k5k6}+{k1k2}+{sprk3}", "templateType": "anything", "group": "Results"}, "maxerror": {"name": "maxerror", "description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "definition": "1.1", "templateType": "anything", "group": "Ungrouped variables"}}, "metadata": {"licence": "None specified", "description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems."}, "variable_groups": [{"name": "Results", "variables": ["k1k2", "k4k5k6", "damc1damc2", "ktot", "zeta", "dampness"]}], "functions": {}, "advice": "", "rulesets": {}, "preamble": {"js": "", "css": ""}, "statement": "

The following diagram represents a mass connected to a spring-damper system.

\n

\n

The mass is {mass1} kg, and the spring constants are as follows: k1 = {sprk1} N/m, k2 = {sprk2} N/m, k3 = {sprk3} N/m, k4 = {sprk4} N/m, k5 = {sprk5} N/m, k6 = {sprk6} N/m. The damping coefficients are C1 = {damc1} Ns/m and C2 = {damc2} Ns/m,

", "ungrouped_variables": ["mass1", "sprk1", "sprk2", "sprk3", "sprk5", "sprk4", "sprk6", "damc1", "damc2", "g", "maxerror", "minerror", "f1", "x0", "vmax", "error"], "variablesTest": {"condition": "", "maxRuns": 100}}, {"name": "LO3.1 - Free Vibration 2", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_wit_2_springs.png", "/srv/numbas/media/question-resources/mass_wit_2_springs.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "rulesets": {}, "functions": {}, "tags": [], "ungrouped_variables": ["mass1", "sprk1", "sprk2", "sprktot", "g", "maxerror", "minerror", "error"], "statement": "

The following diagram represents a mass suspended by a spring system:

\n

\n

The mass is {mass1} kg, and the spring constants are k1 = {sprk1} N/m, k2 = {sprk2} N/m.

\n

", "preamble": {"js": "", "css": ""}, "variable_groups": [], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"licence": "None specified", "description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems."}, "variables": {"sprk1": {"group": "Ungrouped variables", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "name": "sprk1"}, "mass1": {"group": "Ungrouped variables", "description": "", "definition": "random(10 .. 250#1)", "templateType": "randrange", "name": "mass1"}, "g": {"group": "Ungrouped variables", "description": "", "definition": "9.81", "templateType": "anything", "name": "g"}, "minerror": {"group": "Ungrouped variables", "description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "definition": "0.9", "templateType": "anything", "name": "minerror"}, "error": {"group": "Ungrouped variables", "description": "", "definition": "abs({maxerror}-{minerror})", "templateType": "anything", "name": "error"}, "sprktot": {"group": "Ungrouped variables", "description": "", "definition": "({sprk1}*{sprk2}/({sprk1}+{sprk2}))", "templateType": "anything", "name": "sprktot"}, "maxerror": {"group": "Ungrouped variables", "description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "definition": "1.1", "templateType": "anything", "name": "maxerror"}, "sprk2": {"group": "Ungrouped variables", "description": "", "definition": "random(500 .. 10000#1)", "templateType": "randrange", "name": "sprk2"}}, "advice": "", "parts": [{"showFeedbackIcon": true, "settings": {"correctAnswer": "quantity({sprktot}, \"N/m\")", "hint": "remind units", "different_units_action": "prevent", "wiggle": "{error}*{sprktot}", "allow_unitless": false, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

What would be the total spring constant for the spring system?

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}, {"showFeedbackIcon": true, "settings": {"correctAnswer": "quantity({mass1}*(-1)*{g}/{sprktot}, \"m\")", "hint": "remind units", "different_units_action": "prevent", "wiggle": "{error}*{mass1}*(-1)*{g}/{sprktot}", "allow_unitless": false, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

If no other forces are acting on the system, by how much will the springs be compressed (static deflection)?

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}, {"showFeedbackIcon": true, "settings": {"correctAnswer": "quantity(({sprktot}/{mass1})^0.5, \"rad/s\")", "hint": "remind units", "different_units_action": "prevent", "wiggle": "{error}*({sprktot}/{mass1})^0.5", "allow_unitless": false, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

What would be the natural frequency of this system?

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}]}, {"name": "LO3.1 - Free Vibration 1", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "statement": "

The following diagram represents a mass suspended by a spring system:

\n

\n

The mass is {mass1} kg, and the spring constants are k1 = {sprk1} N/m, k2 = {sprk2} N/m, k3 = {sprk3} N/m. 

\n

", "advice": "", "rulesets": {}, "tags": [], "parts": [{"customName": "", "showCorrectAnswer": true, "type": "quantity", "unitTests": [], "variableReplacements": [], "scripts": {}, "customMarkingAlgorithm": "", "useCustomName": false, "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "prompt": "

What would be the total spring constant for the spring system?

", "variableReplacementStrategy": "originalfirst", "settings": {"correctAnswer": "quantity({sprktot}, \"N/m\")", "different_units_action": "prevent", "allow_unitless": false, "different_units_penalty": "100", "wiggle": "{error}*{sprktot}", "hint": "remind units"}, "marks": 1}, {"customName": "", "showCorrectAnswer": true, "type": "quantity", "unitTests": [], "variableReplacements": [], "scripts": {}, "customMarkingAlgorithm": "", "useCustomName": false, "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "prompt": "

If no other forces are acting on the system, by how much will the springs be compressed?

", "variableReplacementStrategy": "originalfirst", "settings": {"correctAnswer": "quantity ({mass1}*(-1)*{g}/{sprktot}, \"m\")", "different_units_action": "convert", "allow_unitless": true, "different_units_penalty": "100", "wiggle": "{error}*{mass1}*(-1)*{g}/{sprktot}", "hint": "remind units"}, "marks": 1}, {"customName": "", "showCorrectAnswer": true, "type": "quantity", "unitTests": [], "variableReplacements": [], "scripts": {}, "customMarkingAlgorithm": "", "useCustomName": false, "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "adaptiveMarkingPenalty": 0, "prompt": "

What would be the natural angular frequency of this system?

", "variableReplacementStrategy": "originalfirst", "settings": {"correctAnswer": "quantity (({sprktot}/{mass1})^0.5, \"rad/s\")", "different_units_action": "convert", "allow_unitless": true, "different_units_penalty": "100", "wiggle": "{error}*({sprktot}/{mass1})^0.5", "hint": "remind units"}, "marks": 1}], "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["mass1", "sprk1", "sprk2", "sprk3", "sprktot", "g", "maxerror", "minerror", "error"], "variables": {"g": {"group": "Ungrouped variables", "definition": "9.81", "name": "g", "description": "", "templateType": "anything"}, "maxerror": {"group": "Ungrouped variables", "definition": "1.1", "name": "maxerror", "description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "templateType": "anything"}, "sprk2": {"group": "Ungrouped variables", "definition": "random(500 .. 10000#1)", "name": "sprk2", "description": "", "templateType": "randrange"}, "minerror": {"group": "Ungrouped variables", "definition": "0.9", "name": "minerror", "description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "templateType": "anything"}, "mass1": {"group": "Ungrouped variables", "definition": "random(10 .. 250#1)", "name": "mass1", "description": "", "templateType": "randrange"}, "error": {"group": "Ungrouped variables", "definition": "abs({maxerror}-{minerror})", "name": "error", "description": "", "templateType": "anything"}, "sprk1": {"group": "Ungrouped variables", "definition": "random(500 .. 10000#1)", "name": "sprk1", "description": "", "templateType": "randrange"}, "sprk3": {"group": "Ungrouped variables", "definition": "random(500 .. 10000#1)", "name": "sprk3", "description": "", "templateType": "randrange"}, "sprktot": {"group": "Ungrouped variables", "definition": "({sprk1}*{sprk2}/({sprk1}+{sprk2})) + {sprk3}", "name": "sprktot", "description": "", "templateType": "anything"}}, "metadata": {"licence": "None specified", "description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems."}, "functions": {}}, {"name": "LO3.1 - Free Vibration 4", "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_wit_2_springs.png", "/srv/numbas/media/question-resources/mass_wit_2_springs.png"], ["question-resources/horizontal_spring_with_mass.png", "/srv/numbas/media/question-resources/horizontal_spring_with_mass.png"], ["question-resources/mass_with_6_springs_and_2_dampers.png", "/srv/numbas/media/question-resources/mass_with_6_springs_and_2_dampers.png"], ["question-resources/mass_damper_spring.png", "/srv/numbas/media/question-resources/mass_damper_spring.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "rulesets": {}, "functions": {}, "tags": [], "ungrouped_variables": ["mass1", "sprk1", "damc1", "g", "maxerror", "minerror", "f1", "x0", "vmax", "error"], "statement": "

The following diagram represents a mass connected to a spring-damper system and a vertically-applied force.

\n

\n

The mass is m = {mass1} kg, and the spring constant is k = {sprk1} N/m, and the damping coefficient is C = {damc1} Ns/m; x represents vertical displacement.

", "preamble": {"js": "", "css": ""}, "variable_groups": [{"variables": ["zeta", "dampness", "wn"], "name": "Results"}], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"licence": "None specified", "description": "This question deals with basic concepts of harmonic oscillators, vibration, and spring-damper systems."}, "variables": {"dampness": {"group": "Results", "description": "", "definition": "if ({zeta}>1, \"overdamped\", (if ({zeta}<1, \"underdamped\", \"critically damped\")))", "templateType": "anything", "name": "dampness"}, "mass1": {"group": "Ungrouped variables", "description": "", "definition": "{sprk1}/4", "templateType": "anything", "name": "mass1"}, "x0": {"group": "Ungrouped variables", "description": "

Starting position of the system.

", "definition": "{f1}/{sprk1}", "templateType": "anything", "name": "x0"}, "minerror": {"group": "Ungrouped variables", "description": "

Adjust to set the top limit of acceptable variation on result (by default 0.9, which allows results up to 10% above calculated result). Multiply this times result in numeric response answers.

", "definition": "0.9", "templateType": "anything", "name": "minerror"}, "damc1": {"group": "Ungrouped variables", "description": "", "definition": "(4*{sprk1}*{mass1})^0.5", "templateType": "anything", "name": "damc1"}, "zeta": {"group": "Results", "description": "", "definition": "{damc1}/((4*{sprk1}*{mass1})^0.5)", "templateType": "anything", "name": "zeta"}, "wn": {"group": "Results", "description": "", "definition": "({sprk1}/{mass1})^0.5", "templateType": "anything", "name": "wn"}, "maxerror": {"group": "Ungrouped variables", "description": "

Adjust to set the top limit of acceptable variation on result (by default 1.1, which allows results up to 10% above calculated result). Multiply this by the result in numeric response answers.

", "definition": "1.1", "templateType": "anything", "name": "maxerror"}, "error": {"group": "Ungrouped variables", "description": "", "definition": "abs({maxerror}-{minerror})", "templateType": "anything", "name": "error"}, "sprk1": {"group": "Ungrouped variables", "description": "", "definition": "random(100 .. 100000#500)", "templateType": "randrange", "name": "sprk1"}, "g": {"group": "Ungrouped variables", "description": "", "definition": "9.81", "templateType": "anything", "name": "g"}, "f1": {"group": "Ungrouped variables", "description": "", "definition": "random(10 .. 4500#10)", "templateType": "randrange", "name": "f1"}, "vmax": {"group": "Ungrouped variables", "description": "", "definition": "{x0}*({sprk1}/{mass1})^0.5", "templateType": "anything", "name": "vmax"}}, "advice": "", "parts": [{"showFeedbackIcon": false, "settings": {"correctAnswer": "quantity({wn}, \"rad/s\")", "hint": "remind units", "different_units_action": "prevent", "wiggle": "{error}*{wn}", "allow_unitless": false, "different_units_penalty": "100"}, "unitTests": [], "useCustomName": false, "type": "quantity", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "prompt": "

What would be the natural angular frequency of the system?

", "extendBaseMarkingAlgorithm": true, "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": false, "marks": 1}, {"mustBeReduced": false, "type": "numberentry", "allowFractions": false, "prompt": "

What would be the damping ratio of this system?

", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "minValue": "{minerror}*{zeta}", "showFeedbackIcon": true, "unitTests": [], "useCustomName": false, "maxValue": "{maxerror}*{zeta}", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "correctAnswerStyle": "plain", "marks": 1, "correctAnswerFraction": false, "extendBaseMarkingAlgorithm": true, "scripts": {}}, {"showFeedbackIcon": true, "unitTests": [], "useCustomName": false, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "adaptiveMarkingPenalty": 0, "answer": "{dampness}", "prompt": "

Would you describe this system as damped, underdamped, or critically damped?

", "matchMode": "exact", "extendBaseMarkingAlgorithm": true, "displayAnswer": "{dampness}", "scripts": {}, "customName": "", "variableReplacements": [], "showCorrectAnswer": true, "marks": 1}]}]}], "contributors": [{"name": "Amnael Orozco", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4010/"}], "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.

", "help_url": "https://github.com/numbas/numbas-extension-quantities", "input_widget": "string", "input_options": {"correctAnswer": "plain_string(settings[\"correctAnswer\"])", "hint": {"static": false, "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)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\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\nraw_student_units:\ntry(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)\n\nstudent_units:\nif(compatible(raw_student_units,correct_units) or settings[\"incompatible_units_action\"]<>\"convert\",\n raw_student_units,\n correct_units\n)\n\nstudent_quantity:\napply(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)\n\ncorrect_quantity:\nsettings[\"correctAnswer\"]\n\ncompatible:\nif(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)\n\ncorrect_units:\nunits(correct_quantity)\n\nsame_units:\nassert(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)\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)\n\ncan_compare:\ncompatible or settings[\"incompatible_units_action\"]=\"convert\"\n\nclose_enough:\nif(can_compare,\n student_quantity>=correct_quantity - wiggle \n and \n student_quantity<=correct_quantity + wiggle \n,\n false\n)\n\nwiggle:\nunits(correct_quantity)*abs(eval(settings[\"wiggle\"]))\n\nvalid_number:\nif(isNaN(student_number),\n warn(translate(\"part.numberentry.answer invalid\"));\n fail(translate(\"part.numberentry.answer invalid\"))\n,\n true\n )", "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": "apply(valid_number);\napply(student_quantity);\napply(has_units);\napply(compatible);\ntry(\n correctif(close_enough),\n x,\n apply(student_quantity)\n);\napply(same_units)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_quantity"}, {"name": "allowed_notation_styles", "description": "", "definition": "[\"plain\",\"en\"]"}, {"name": "match_student_number", "description": "", "definition": "matchnumber(studentAnswer,allowed_notation_styles)"}, {"name": "student_number", "description": "

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.

", "definition": "try(\n quantity(studentAnswer[len(match_student_number[0])..len(studentAnswer)]),\n message,\n warn(\"Your answer is not a valid quantity.\");\n fail(\"Your answer is not a valid quantity.\")\n)"}, {"name": "student_units", "description": "

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", "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", "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/Mass_with_3_springs.png", "/srv/numbas/media/question-resources/Mass_with_3_springs.png"], ["question-resources/image_H0ahEr5.png", "/srv/numbas/media/question-resources/image_H0ahEr5.png"], ["question-resources/image_c50Rmu3.png", "/srv/numbas/media/question-resources/image_c50Rmu3.png"], ["question-resources/mass_with_3_springs_and_force.png", "/srv/numbas/media/question-resources/mass_with_3_springs_and_force.png"], ["question-resources/mass_with_3_springs_damper_and_force.png", "/srv/numbas/media/question-resources/mass_with_3_springs_damper_and_force.png"], ["question-resources/Cantilever_mass.png", "/srv/numbas/media/question-resources/Cantilever_mass.png"], ["question-resources/horizontal_mass_spring_damper.png", "/srv/numbas/media/question-resources/horizontal_mass_spring_damper.png"], ["question-resources/mass_damper_spring_oOx9vMZ.png", "/srv/numbas/media/question-resources/mass_damper_spring_oOx9vMZ.png"], ["question-resources/mass_wit_2_springs.png", "/srv/numbas/media/question-resources/mass_wit_2_springs.png"], ["question-resources/horizontal_spring_with_mass.png", "/srv/numbas/media/question-resources/horizontal_spring_with_mass.png"], ["question-resources/mass_with_6_springs_and_2_dampers.png", "/srv/numbas/media/question-resources/mass_with_6_springs_and_2_dampers.png"], ["question-resources/mass_damper_spring.png", "/srv/numbas/media/question-resources/mass_damper_spring.png"]]}