isUnit

Overview

The isUnit method checks if an expression contains the expected units.

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, please see equivValue Combining Methods section.


  • Allow thousands separator

    When enabled, authors can specify what separators can be used by the students. From the Thousand Separator drop down menu you can select either dot, comma or space. Decimal Separator menu can be found below Thousand Separator.


  • Inverse result

    Enabling this means that the value specified in the Value field will not be accepted as the correct answer. It is a useful way of excluding very specific answers from validation.



Example

Basic isUnit example.

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

AnswerMarking
\(7ft\)true
\(5mi\)true
\(10in\)false
\(10cm\)false
Source
{
    "instant_feedback": true,
    "is_math": true,
    "stimulus": "Enter a value in miles or feet, but not in inches.",
    "type": "formulaV2",
    "ui_style": {
        "type": "block-on-focus-keyboard"
    },
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [
                {
                    "method": "isUnit",
                    "value": "mi,ft"
                }
            ]
        }
    }
}