New pl-units-input Element
Posted on 2024-07-23 by Eliot Robson
Thanks to Eliot Robson (UIUC), PrairieLearn now has
a new pl-units-input
element, based on preliminary work by
Morgan Arnold and
Boris Li (UBC).
This element can be used to create problems where students must input a quantity with an
accompanying unit. By default, input of the same dimensionality as the reference solution is
automatically converted and compared. For example, if the correct answer is 1 meter
,
submissions like 100 cm
or 1000 mm
are also accepted.
Below are submission panels for correct answers. For the second one, the comparison was performed independent of units and within the given tolerance (1cm).
In the following example, the student used an incompatible unit (cm^3
instead of
m
), resulting in an answer tagged as incorrect.
Additional comparison methods are available without this automated conversion, along with other customization options. The code that generates the above question is:
<pl-units-input answers-name="c_1" correct-answer="1m" atol="1cm"></pl-units-input>
For more information, see the pl-units-input documentation or the pl-units-input example question.