stringMatch

Overview

The stringMatch method is used for literal string comparison. This compares the value set by authors in validation against the student's response, and evaluates whether they are the same or not. stringMatch is a simple comparison method: it does not take the syntax and data type set in the validation area into account.


  • Ignore leading and trailing spaces

    Ignores spaces before and after a value, i.e. " \(a\) " will be treated as "\(a\)".


  • Treat multiple spaces as one

    Multiple spaces will be ignored and treated as one, i.e "\(a\)   \(b\)" is the same as "\(a\) \(b\)".


  • 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.
    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 correct responses.



Examples

Example 1

The student's response should match the exact value set in validation. Ignore Leading and Trailing Spaces and Treat Multiple Spaces as One are enabled.

AnswerMarking
3, 5, 8true
3,5,8true
3,   5,   8true
3 5 8 false
3, 5, 8,false

Source
{
    "instant_feedback": true,
    "is_math": true,
    "response_container": {
        "template": "",
        "width": "60px"
    },
    "stimulus": "Complete the Fibonacci sequence.",
    "template": "0, 1, 2, {{response}}, 13, 21, 34...",
    "type": "clozeformula",
    "ui_style": {
        "response_font_scale": "normal",
        "type": "block-on-focus-keyboard"
    },
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [
                [
                    {
                        "method": "stringMatch",
                        "value": "3, 5, 8",
                        "options": {
                            "inverseResult": false,
                            "decimalPlaces": 10
                        }
                    }
                ]
            ]
        }
    }
}


Example 2

In this example, Ignore Leading and Trailing Spaces and Treat Multiple Spaces as One are disabled. Only "÷" will be accepted as correct response.

AnswerMarking
÷true
:false
/false
   ÷   [multiple spaces included]false
Source
{
    "instant_feedback": true,
    "is_math": true,
    "stimulus": "Complete the equation.",
    "template": "500 {{response}} 100 = 5",
    "type": "clozeformula",
    "ui_style": {
        "response_font_scale": "normal",
        "type": "block-on-focus-keyboard"
    },
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [
                [
                    {
                        "method": "stringMatch",
                        "value": "\\div",
                        "options": {
                            "inverseResult": false,
                            "decimalPlaces": 10,
                            "ignoreLeadingAndTrailingSpaces": false
                        }
                    }
                ]
            ]
        }
    }
}