Take Grading Back to the Future: Utilize Regular Expressions to Grade Quizzes

May 10, 2024

This article examines the topic of Regular Expressions, a programming language that can machine grade free-response questions in D2L Brightspace Quizzes.

Image
Illustration of going back to the future car like by utilizing regular expressions

Imagine, it’s summer 1985. The film Back to the Future just hit theaters, sparking a buzz about futuristic technologies and stylish flying cars. Fast forward to the present, and we find ourselves living in a very real sci-fi world, discussing the impacts of Generative AI and gleefully sharing our experiences with self-driving cars.

Against this backdrop, we invite you to travel back to the future of computer programming languages as we break down the topic of Regular Expressions—a powerful tool often overlooked in its capacity to generate machine-grade free-response questions in D2L Brightspace Quizzes. 

In this article, we introduce Regular Expressions, discuss their setup in Brightspace, and provide tips for effective usage. So what do you say, ready to take it up to 88?

Introduction to Regular Expressions

Regular Expressions (RegEx) are algorithms. As a concept, RegEx has been around since the 1950s, but gained significant traction in the late twentieth century with the rise of personal computing technologies. 

Using a combination of metacharacters – characters that carry special meanings – and alphanumeric characters – characters that carry literal meanings – RegEx identifies matching patterns. Its algorithms can be simple or complex and may include groupings to define subpatterns and/or anchors, which mark word boundaries. Let’s analyze some examples.

  • The Regular Expression cat|dog, composed of the metacharacter pipe (vertical line) and two words cat and dog (alphanumeric characters), matches either one of the two words in the text string, e.g., cat or dog, but not both words. 
  • Adding the modifier (?i) to the beginning of the expression, (?i)cat|dog – tells the engine to ignore letter case and to match CAt or doG, for example.
  • Bracketing the pattern with anchors ^ (caret) and $ (dollar sign) – (?i)^cat$ – tells the expression to match the string exactly, with no extra characters or spaces. In this example, only the single word cat (case insensitive) would match. 

Knowledge of a few basic RegEx commands is all it takes to get started. However, if the idea of wrestling with programming syntax has you echoing Marty McFly’s iconic line, “This is heavy,” know that resources are plentiful – some even generate custom RegEx for you.

Setup in Brightspace

The option to use Regular Expressions is offered in the Brightspace Quizzes tool for arithmetic, fill-in-the-blanks, short answer, and multi-short answer question types. 

To insert a Regular Expression, select Regular Expression from the dropdown menu adjacent to the field where you typically enter the correct answer. Type or paste the RegEx into the answer field. If a student’s answer matches the pattern, D2L will mark it correct; non-matching patterns will be marked incorrect.

We recommend testing your Regular Expressions using an online tool such as regex101.com. For Brightspace compatibility, choose the language .NET 7.0 (C#) (Brown, 2022). After debugging, set up a Brightspace Quiz and insert the RegEx into the answer choice. Preview the Quiz to ensure that the question also scores accurately within the Learning Management System. 

Effective Usage

It’s important to recognize that Regular Expressions, like plutonium, must be handled with care. We do not advocate their use in all evaluation scenarios, but in certain contexts, RegEx may help to alleviate grading pain points. Consider the following:

  • High-Enrollment Courses: RegEx may offer significant time savings for high-enrollment courses that prioritize recall question types (free response) over recognition question types (multiple choice). 
  • Fixed Answer Choices: Fixed answer choices leave little room for discrepancies in student responses. Alternatively, using Regular Expressions can offer remarkable flexibility to accommodate nuances and variations in the ways that students might respond.
  • Multiple Correct Answers: When a response might have multiple correct answers, use an alternate match sequence – a|b|c – to designate more than one answer as correct. This strategy works best when answers are a single word or a short phrase derived from discipline-specific vocabulary.
  • Spelling and Syntax: When a correct response might have alternate spellings (or anticipated incorrect spellings) or variations in grammatical syntax, use a wildcard token such as – . – (equivalent options available) to provide leeway for minor discrepancies. 
  • Capitalization or Diacritical Marks: In some contexts, the use of diacritical marks or capitalization matters since it can change meaning and pronunciation. Use a character set to specify diacritics or letter case. For example, (?i)^habl[ó|O]$ matches habló (case insensitive) or hablO (case insensitive except for the capital letter O).
  • No Right or Wrong: Occasionally, there is the need to accept literally any response – for example, an icebreaker question. In such cases, a wildcat token and quantifier – .* – may be used together to accept all answers. Add a numeric quantifier, for example  – .{20} – to tell the expression to match only responses of 20 characters or more.

As a final point, remember that no system is foolproof. While Regular Expressions have the potential to supercharge your grading process like a figurative flux capacitor, know that occasional spot-checking will be needed.

With that, we hope you’ve found this journey back to the future of programming languages insightful. Questions or comments about Regular Expressions may be directed to the Instructional Technology Team

Resources 

References

Brown, B. (2022, September 12). Smart Short Answer or Fill-Blank Questions for Desire2Learn Brightspace. Faculty Web Pages. https://facultyweb.kennesaw.edu/rbrow211/help/index.php