Skip to content

fb_unit

mkraska edited this page Apr 16, 2023 · 40 revisions

Feedback function for units input.

This function performs the following checks with units (see fb_vars and fb_number for other functions):

  • Do the units match? This is redundant to the UnitsRelative answer test.
  • Is the value off by exactly an integer power of 10? This indicates correct mantissa and problems with unit conversion. Mantissa Check
  • Is the sign correct? Check of Sign
  • If tol is 0 or the deviation is less than tol: display % deviation with one decimal place.
  • If teacher's answer is zero and student's answer is not: Absolute value of the response is too big.
  • If student's answer is zero and teacher's answer is not: Absolute value of the response is too small.
  • Otherwise display % deviation with one significant digit (e.g. at least 0.01% or 0.3% or 30% deviation)

You can try the function interactively in our Demo Moodle Course (see quiz fb_unit() interactive tryout).

fb_unit(sans, tans, tol) Returns the text to be displayed for feedback.

fb_unitOK(sans, tans, tol) Returns the test result (true or false).

  • sans student's answer,
  • tans teacher's answer,
  • tol relative tolerance for the mantissa. Set it to zero to avoid the tests and just display the deviation.

Question variables

German version:

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_value.mac");

English version:

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_value_EN.mac");

PRT

  • Set simp to false. This enables input like 0*kg to keep the unit factor for feedback.
  • Use a UnitRelative answer test with suppressed feedback (unit mismatch is handled by the feedback function).

Put this to the feedback text of the false branch of the first node.

{@fb_unit(sans, tans, tol)@}

In the true branch of the first node, use this to suppress the tests and just display the deviation:

{@fb_unit(sans, tans, 0)@}

You could pre-calculate the value in the feedback variables, but that doesn not reliably avoid empty checks (with no feedback)

Tryout Space

In order to try code snippets in jsfiddle,

  1. copy the code from the wiki page to the clipboard
  2. follow the link for the JSXGraph version you want to try
  3. Replace the code in the HTML section (contents of <p hidden id="init">) with the content of the clipboard
Clone this wiki locally