Google forms and regular expressions for response validation

I was kind of shocked with the proliferation of teachers now using Google Classroom to conduct classes, that the documentation for the Quiz sections of the Classwork assignments is quite insufficient (or presumes you’re an IT geek like me, and can just figure out what programming is available to you.)

The example situation is given by this Blog entry related to Google Classroom and students’ answers being marked Incorrect because on Short Text responses, every answer is matched as a “literal” string – that is, upper and lowercase letters MATTER (a lot!)

Link to:
Student’s answers were marked wrongly in a short answer quiz by Google Forms.

The odd thing is while Google provided a solution for simple e-mail address validation, and various numerical responses, it’s been horrible at dealing with text answers.

The answer is in the 3rd category of Response Validation: Regular Expressions. RegEx’s are commonly used in programming languages and OS shells (like Linux, Unix, HPUX, etc.) since when scripting various commands, we often need to parse parameters and do things with various input like file directory listings, and long lists of things separated by some arbitrary character (like a comma or a vertical bar character.)

Thus here in my example, dealing with a student who was marked with Incorrect answers simply because they didn’t provide the exact case required by the 3 answer versions entered by the instructor (e.g. “Any Dog”, “any dog”, “ANY DOG”) – and the student typed “Any dog” and got it marked Incorrect.

One more typical way to prevent this is specifying in the Quiz preamble the exact format responses you want as an instructor for the short answers. For example, “Please enter all short answers in lowercase letters only, with no leading or trailing space or tab characters.”

But a more practical way is exercising that Regular Expression engine that’s built into Google Forms.

My example question wanting a response from the student like “inner core” (preferably providing a graphic picture of the planet’s layers and just labeling them A/B/C/D/E would have been simpler, but maybe I’m testing vocabulary at this point.)

Selecting the Response Validation type “Regular expression” and using “Matches” the pattern: “^[A-Z]” is interepreted as meaning, “if the Short answer text contains any uppercase letters from A to Z” then display the warning text “Please use all lowercase answers only!” – and do not accept the answer, as submitted.

Regular Expressions can get really complicated, but if you think of them as basically describing what’s in a string of text and matching it as either TRUE or FALSE (and preferably keeping your Answer expectations limited unless you happen to be teaching a course in OS-level scripting, in which case, go ahead and get as complicated as you’d like…) I think you’ll find your student’s will be gently guided into providing the answers in the form you were thinking of when you prepared the Quiz.

And isn’t that what this was all about in the first place?

Here’s a link to a more thorough (and lengthy, and complicated) discussion of the power of Google Forms using Regular Expressions:


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.