TL;DR
This paper evaluates the use of GPT-4 to automatically generate contextually personalized programming exercises (themed around topics like video games, pets, or board games) for students in an introductory coding course. Through a combination of expert rubrics and student surveys, the authors show that generative AI can successfully deliver clear, highly engaging, and context-appropriate practice problems, though precisely calibrating exercise difficulty remains a notable hurdle.
What Problem Does This Paper Address?
Learning to program requires extensive hands-on practice, but introductory computer science (CS1) students frequently battle high levels of stress, frustration, and boredom. Educational psychology tells us that context personalization—tailoring problem narratives to a student's personal interests or cultural background—can spark situational interest and boost engagement.
However, manually writing hundreds of unique, themed programming problems for diverse student cohorts is an exhausting, time-consuming task for educators. This paper explores whether Large Language Models (LLMs) can step in to automate this workflow, providing a practically infinite pool of personalized practice material without overloading course staff.
Methods
The researchers designed a structured prompt engineering pipeline using GPT-4 to pre-generate programming exercises for an introductory course taught in the Dart language.
-
Prompt Engineering & Tuning: The authors experimented with the model's temperature parameter to find a balance between structural consistency and creative variation. They settled on a temperature of 0.5; higher settings (like 1.5) caused the model to hallucinate nonsensical, emoji-filled outputs, while lower settings caused it to ignore the requested themes entirely.
Figure 1: A screenshot of nonsensical output containing emojis. -
Curated Themes & Concepts: Exercises were generated across three core chapters: user input/output, variables/arithmetic, and conditionals. The prompts instructed the model to weave in specific sub-topics from 16 overarching themes (e.g., food, nature destinations, cartoons).
- Platform Integration: Instead of generating exercises live on-demand, the authors pre-generated a pool of 283 valid exercises to protect against API outages and filter out broken code. These were integrated into an online textbook platform where students could explicitly choose their preferred theme, concept, and difficulty level before launching an embedded IDE.
- Dual Evaluation: The quality of the exercises was rigorously evaluated using both an expert rubric completed by the five authors (measuring clarity, theme/concept matching, difficulty calibration, and personalization depth) and voluntary post-exercise student surveys.
Datasets
The study did not rely on standard machine learning datasets for training. Instead, the primary artifact evaluated is the newly generated pool of 283 unique Dart programming exercises. These exercises span three chapters of introductory programming concepts and are distributed across 16 distinct interest-based themes.
Key Insights and Ideas
- Students Actively Choose Personalization: When given the option to pick a specific theme or receive a random one, students chose a specific theme between 58% and 78% of the time. This strong preference demonstrates that learners actively appreciate having agency over the narrative context of their assignments.
- The Power of "Shallow" Personalization: The expert review revealed that 64% of the generated exercises featured only "shallow" personalization (e.g., simply changing the framing text or variable names to mention a topic like "Ariana Grande album sales" without deeply altering the logic). Despite this, students rated the exercises as highly engaging, suggesting that even superficial context tuning provides meaningful motivational benefits.
- LLMs Struggle to Calibrate Difficulty: GPT-4 frequently failed to match the requested difficulty level. Nearly 40% of the exercises were classified by experts as "too easy" for their target designation, and the model occasionally leaked advanced concepts (like conditional logic) into early introductory chapters.
Key Results
- High Text Clarity and Theme Alignment: The expert evaluation rated 96.5% of the generated exercises as completely clear, and 96.1% successfully matched their selected theme.
- Prompt Sensitivity and Faulty Code: The generation process highlighted how fragile LLM prompts can be. In Chapter 3, an accidental extra space in the few-shot example prompt caused the model to generate faulty test code in 92.7% of its initial attempts, requiring manual correction before deployment.
- Overwhelmingly Positive Student Sentiment: Student feedback was remarkably high. Over half of the participating students "strongly agreed" with every positive statement regarding the tool, confirming that they found the AI-generated exercises both engaging and highly useful for their learning.
Limitations and Future Work
- Selection and Attrition Bias: The user study took place in an elective, self-paced online course characterized by high natural student attrition. The remaining active participants who filled out the surveys were likely highly motivated and potentially more enthusiastic about AI tools than average students.
- Static Pre-generation: Because the exercises were pre-generated to ensure code safety, the system did not offer a truly infinite, real-time personalized experience.
- Language Barrier: The course itself was conducted in Finnish, but the AI-generated exercises were delivered in English because LLMs perform significantly better at code generation when prompted in English.
For future iterations, the authors plan to transition to a true on-demand generation system capable of handling arbitrary, user-typed themes safely. They also intend to study how adding gamification elements impacts long-term student retention.
Summary updated