AUTOMATED GENERATION OF PYTHON PROGRAMMING MULTIPLE CHOICE QUESTIONS USING REFLECTION AND METAPROGRAMMING
J. Otero, N. Costa
Multiple-choice questions (MCQs), widely used in educational testing and classroom assessments, consist of the question itself (the stem) and a series of options, including one correct answer (the key) and several distractors. In the context of computer programming teaching, they can be used to evaluate students' understanding of syntax, semantics, and programming concepts, as well as their ability to predict code outcomes and identify errors. They are also a tool to consolidate students' knowledge through practice. However, creating high-quality MCQs can be a time-consuming and challenging task. Among the drawbacks of MCQs is the possibility of guessing the correct answer, which can be mitigated by designing distractors that are plausible and reflect common student errors and misconceptions. This article presents an innovative approach to generating MCQs for Python programming teaching using Python's reflection and metaprogramming capabilities. Reflection in programming is the ability of a program to inspect, analyze, and modify its own structure and behavior at runtime. Metaprogramming, on the other hand, is coding computer programs that write or manipulate other programs (or themselves) as their data. The method involves using reflection with short Python programs to obtain programmatically the correct answers for MCQs about the state of those programs: variables values, output, errors and so on. Then we modify them using metaprogramming techniques to generate distractors. Modifications are intended to mimic wrong students code interpretations involving operators, keywords, control structures, indentation and so on. The generated questions focus on key aspects of Python programming, including the final values of variables after execution is finished, the evolution of variables within loops, and various types of errors. This approach provides a dynamic and efficient way to create diverse and challenging MCQs, enhancing the learning experience for Python programming students.
Keywords: Educational Testing, Multiple-Choice Questions, Reflection in Programming, Metaprogramming.