Introduction
Introductory computer science (CS1) courses are currently grappling with a scalability crisis. As enrollment numbers skyrocket, instructors face the challenge of teaching students with vastly diverse experience levels. A fundamental skill in learning to program is code tracing—the process of mentally or manually executing code line-by-line to predict its behavior. While tracing is a proven precursor to coding proficiency, manually creating a large, diverse bank of tracing questions is an exhausting task for educators.
This research investigates whether Large Language Models (LLMs), specifically GPT-4, can automate the creation of high-quality code-tracing questions. The study finds that GPT-4 can generate pedagogically sound questions that are often indistinguishable from those created by human experts, offering a scalable solution for personalized programming education.
Methodology
The researchers developed a multi-step pipeline to evaluate LLM capabilities in educational content generation.
The process involved:
- Prompt Engineering: Iteratively refining prompts to position the LLM as an "expert instructor." The study compared Zero-Shot prompting (no examples) against Few-Shot prompting (providing three example questions).
- Model Comparison: Evaluating both GPT-3.5-turbo and GPT-4.
- Automated Evaluation: Using BERTScore to measure semantic similarity and diversity against a human-authored baseline.
- Human Expert Evaluation: Four experienced computer science graduate students performed a blind review of 176 question pairs. They rated questions based on relevance to learning objectives, clarity, difficulty appropriateness, and relevance to the code snippet. They also attempted to identify whether the author was human or AI.
The dataset used for this evaluation consisted of 176 code snippets covering fundamental Java concepts like loops, recursion, and array manipulation, sourced from the CSAwesome curriculum and educational videos.
Key Insights: The "Few-Shot" Diversity Trap
A surprising finding was that zero-shot prompting outperformed few-shot prompting in terms of question diversity. While few-shot prompting often improves performance in other NLP tasks, here it caused the model to "over-fit" to the style of the provided examples, leading to repetitive, templated questions. In contrast, zero-shot prompting allowed GPT-4 to leverage its broader pedagogical knowledge, resulting in a wider variety of questions, such as those focusing on edge cases or code modifications.
Furthermore, GPT-4 demonstrated a sophisticated "Expert Turing Test" performance. Experts mistakenly identified 56% of GPT-4 questions as human-authored, suggesting that the model has successfully captured an authentic "pedagogical style."
Results and Quality Parity
The evaluation revealed that GPT-4 significantly outperformed GPT-3.5 in producing balanced and diverse questions. Most notably, the study found a high degree of quality parity between human-authored and AI-generated questions.
As shown in the table above, while human-authored questions maintained a slight lead in mean scores for clarity and relevance, the median scores for both groups were identical (5.0/5.0) across nearly all metrics. Statistical analysis (Mann-Whitney U tests) confirmed that there was no significant difference in how relevant the questions were to the provided code snippets, although humans still held a statistically significant edge in clarity and difficulty calibration.
Low lexical overlap (measured via BLEU and ROUGE) combined with moderate BERTScores indicated that GPT-4 was not merely rephrasing existing questions but was generating novel, semantically relevant content.
Limitations and Future Directions
While promising, the study notes several areas for future research:
- Student Impact: The evaluation was conducted by experts; future work should assess how actual learners interact with and benefit from LLM-generated questions.
- Personalization: Current generation is based on code snippets rather than individual student needs or common misconceptions.
- Language and Model Scope: The study focused on Java and the GPT family. Expanding to other languages (Python, C++) and code-specific models (like CodeT5+) is a logical next step.
In conclusion, LLMs represent a viable and scalable tool for generating high-quality educational content, marking a significant advancement toward automated, personalized programming education.
Summary updated