Short answer question with a number range that doesn't just have whole numbers

Sue.S.4
Sue.S.4 Posts: 78 🧭

This is a similar query to one I have posted, but even with the short answer strings I copied over, answers are still being marked incorrect. So I might extend my query (and include the initial one) now I have more information:

How do we input an answer in a short answer question which permits any number between a range - eg any number between 1000-1400. We have [1000-1400].

I also have a number range between 5-12.

Questions are being marked wrong, because students may put one of two things:

A decimal number - eg 9.5…. or they also put the unit of measurement (micro millimetres … in a few different spellings).

The quiz has already run now, but it would be good to fix in the Master site for future delivery.

Thanks in advance.

Answers

  • Isidora.R.173
    Isidora.R.173 Posts: 15
    edited June 9

    Hi Sue,

    I hope you are having a great start to your week! Thank you for reaching out to Community with your question regarding how to set up short answer questions that accept numeric ranges, including decimal values, rather than just whole numbers.

    As you may know, answers in Short Answer Questions are evaluated using one of the following comparison methods:

    • Text
    • Case-Sensitive Text
    • Regular Expression

    To accommodate a range of numeric answers—such as 5 to 12—you will need to use the Regular Expression option. Regular expressions are sequences of characters that define a search pattern, allowing the system to recognize multiple valid inputs, including decimals where applicable.

    For example, if you want to accept whole numbers from 5 to 12, you could use [5-9]|1[0-2].

    However, to include decimal values such as 9.5, your regular expression must allow optional decimal points and digits. Ex: ^(5(.\d+)?|6(.\d+)?|7(.\d+)?|8(.\d+)?|9(.\d+)?|10(.\d+)?|11(.\d+)?|12(.0*)?)$ This expression matches whole numbers from 5 to 12, as well as decimals like 5.1, 9.5, and 12.0, but excludes values above 12.

    For a numeric range of 1000–1400 (including decimals), you might use something like:

    • ^(1000|100[1-9]|10[1-9][0-9]|11[0-9][0-9]|12[0-9][0-9]|13[0-9][0-9]|1400)(.\d+)?$

    If you find that the system is marking some answers as incorrect, it may be necessary to review and revise your regular expression to ensure that it correctly includes the entire required range. Note: [1000-1400] is interpreted as "match a single character that is 1, 0, -, 4, or 0" (duplicates ignored), not numbers from 1000 to 1400.

    For additional guidance on crafting regular expressions, you might find this cheat sheet helpful: Regular Expressions Cheat Sheet

    Please let us know if you have any further questions, and we would be happy to provide clarification.

    Isidora