Units Overview - mkraska/meclib GitHub Wiki
There are various ways to handle scientific units in STACK.
Variables with Units in Question Design and Input
Question Variables
Define the variables with units which are to be used for display (e.g. as given values in the question text).
stack_unit_si_declare(true); /* this initializes unit definitions */
F: 3*kN;
A: 4*cm^2;
sigma: F/A;
Question Text
-
display of given values:
{@'F=F@}
-
place input field:
<p>\( \sigma= \) [input:S_sigma](/mkraska/meclib/wiki/input:S_sigma) [validation:S_sigma](/mkraska/meclib/wiki/validation:S_sigma) [feedback:sigma](/mkraska/meclib/wiki/feedback:sigma)</p>
-
Hide multiplication sign:
<p>{@(make_multsgn("blank"),'F=F)@}</p>
Input
Changes of pre-sets:
Field | Value |
---|---|
Input type | Units (Einheiten) |
Model answer | variable which stores value and unit: sigma |
Input box size | 8 |
Insert stars | Insert stars for spaces only |
Syntax hint | Number with unit (Zahl mit Einheit) |
Hint attribute | Placeholder |
Forbid float | No |
Show the validation | Yes, compact |
PRT
Field | Value |
---|---|
Auto-simplify | No |
Feedback style | Compact |
Answer test | UnitsRelative |
SAns | S_sigma |
TAns | sigma |
Test options | 0.005 (requires 3 significant digits) |
Quiet | Yes |
False feedback | {@fb_unit(S_sigma, sigma, 0.005)@} |
Unitless Question Design but Input with Units
Question Variables
Define the variables in SI unit values
F: 3*1000; /* 3 kN */
A: 4*1e-4; /* 4 cm^2 */
sigma: F/A; /* Pa */
Question Text
-
display of given values:
\( {@'F=F/1000@}\,\mathrm{kN} \)
-
place input field:
<p>\( \sigma= \) [input:S_sigma](/mkraska/meclib/wiki/input:S_sigma) [validation:S_sigma](/mkraska/meclib/wiki/validation:S_sigma) [feedback:sigma](/mkraska/meclib/wiki/feedback:sigma)</p>
Input
Changes of pre-sets:
Field | Value |
---|---|
Input type | Units (Einheiten) |
Model answer | variable times SI-unit: sigma*Pa |
Input box size | 8 |
Insert stars | Insert stars for spaces only |
Syntax hint | Number with unit (Zahl mit Einheit) |
Hint attribute | Placeholder |
Forbid float | No |
Show the validation | Yes, compact |
PRT
Field | Value |
---|---|
Feedback style | Compact |
Answer test | UnitsRelative |
SAns | S_sigma |
TAns | sigma*Pa (value times SI unit) |
Test options | 0.005 (requires 3 significant digits) |