isUnit

Overview

The isUnit method is used for unit comparison, and checks if the expression has the expected units in it. You can find a list of supported S.I. and US Customary Units here.

isUnit is commonly used in conjunction with equivValue. For worked examples of combining isUnit with equivValue, see equivValue Combining Methods section.


  • Inverse result

    This will invert the response specified in validation. This means that any response will be correct except for the one set by the author.
    Use case: Students are asked to enter something symbolically equivalent to \((x+2)^2\), however you don't want them to enter the same expression and score points for this response. In this case, enabling Inverse Result will exclude \((x+2)^2\) from the correct responses.



Example

Basic isUnit example.

In this case, any response given in the specified units will be correct.

AnswerMarking
\(5g\)true
\(55mg\)true
\(1kg\)false
\(5oz\)false
Source
{
    "instant_feedback": true,
    "is_math": true,
    "stimulus": "Enter a value in g or mg, but not in kg.",
    "type": "chemistry",
    "ui_style": {
        "type": "block-on-focus-keyboard"
    },
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [
                {
                    "method": "isUnit",
                    "value": "g,mg"
                }
            ]
        }
    }
}