stringMatch

Overview

The stringMatch method is used for literal string comparison. This compares the value set by authors in validation against a student's response, and evaluates if the two values are the same. stringMatch is a simple comparison method, and 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

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



Examples

Example 1 - Ignore Leading and Trailing Spaces + Treat Multiple Spaces as One

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
\(1\)true
   1   [multiple spaces included]true
\(1.\)false
\(1.0\)false
Source
{
    "instant_feedback": true,
    "is_math": true,
    "stimulus": "What is the valency of H<sub>2</sub>?",
    "type": "chemistry",
    "ui_style": {
        "type": "block-on-focus-keyboard"
    },
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [
                {
                    "method": "stringMatch",
                    "value": "1",
                    "options": {
                        "ignoreOrder": false,
                        "inverseResult": false
                    }
                }
            ]
        }
    }
}


Example 2

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

AnswerMarking
\(6\)true
\(6.0\)false
   6   [multiple spaces included]false
Source
{
    "instant_feedback": true,
    "is_math": true,
    "stimulus": "What is atomic number of carbon?",
    "type": "chemistry",
    "ui_style": {
        "type": "block-on-focus-keyboard"
    },
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [
                {
                    "method": "stringMatch",
                    "value": "6",
                    "options": {
                        "ignoreOrder": false,
                        "inverseResult": false,
                        "treatMultipleSpacesAsOne": false,
                        "ignoreLeadingAndTrailingSpaces": false
                    }
                }
            ]
        }
    }
}