Cited by 497Teaching and Learning ProgrammingArtificial Intelligence in EducationSoftware Engineering Research

Automatic Generation of Programming Exercises and Code Explanations Using Large Language Models

Open access
Sarsa, Sami, Denny, Paul, Hellas, Arto, Leinonen, Juho·2022·Proceedings of the 2022 ACM Conference on International Computing Education Research - Volume 1

Abstract

This article explores the natural language generation capabilities of large language models with application to the production of two types of learning resources common in programming courses. Using OpenAI Codex as the large language model, we create programming exercises (including sample solutions and test cases) and code explanations, assessing these qualitatively and quantitatively. Our results suggest that the majority of the automatically generated content is both novel and sensible, and in some cases ready to use as is. When creating exercises we find that it is remarkably easy to influence both the programming concepts and the contextual themes they contain, simply by supplying keywords as input to the model. Our analysis suggests that there is significant value in massive generative machine learning models as a tool for instructors, although there remains a need for some oversight to ensure the quality of the generated content before it is delivered to students. We further discuss the implications of OpenAI Codex and similar tools for introductory programming education and highlight future research streams that have the potential to improve the quality of the educational experience for both teachers and students alike.

The claims and statistics of this paper haven’t been checked yet.

Run the check — free, no account needed. It reads the open-access text and checks the sources it cites.

A few free checks a day · papers already verified open instantly · results are public

Integrity signals

Registry

Crossref · 10.1145/3501385.3543957

Cites

94 of 94 references verified0 citation errors · 0 not checkable

Statistics

Claims the paper makes

The claims and statistics of this paper haven’t been checked yet.

Run the check — free, no account needed. It reads the open-access text and checks the sources it cites.

A few free checks a day · papers already verified open instantly · results are public

Claims other papers make about this one

Each is checked against this paper’s own text: does it say what the citing paper says it does?

  • The OpenAI Codex model can provide a variety of programming tasks together with the correct solution, automated tests to verify the student's solutions, and additional code explanations.

    “Using few-shot learning, [40] showed that the OpenAI Codex model is able to provide a variety of programming tasks together with the correct solution, automated tests to verify the student's solutions, and additional code explanations.”

    From ChatGPT for good? On opportunities and challenges of large language models for education (2023) · cites this paper as [40]

    Section 3.2.2 describes using examples to prompt Codex to generate exercises with sample solutions and automated tests, and the conclusion reports promising code explanations. But the paper does not establish that the solutions are consistently correct or that the generated tests reliably verify students’ solutions: Section 4.1 reports matching sample solutions for 76.7% of assessed exercises, and its test analysis found that only 51 of 165 generated solutions passed their generated tests. (LLM, conf=0.88)

    Experimental — accuracy not yet measured
  • Recent studies in learning programming found the correctness of Codex to be around 70%-80%, meaning about 20-30% of Copilot suggestions would be incorrect.

    “recent studies in the context of learning programming have found the correctness of Codex (the LLM that powers Copilot) to be around 70%-80% [34, 75], meaning that in about 20-30% of cases, the suggestion by Copilot would be incorrect.”

    From “It’s Weird That it Knows What I Want”: Usability and Interactions with Copilot for Novice Programmers (2024) · cites this paper as [75]

    Section 4.1 Programming Exercises (page unavailable) reports that 76.7% of the evaluated Codex-generated exercises had a sample solution matching the exercise description, which supports a roughly 70–80% figure for that specific measure. Section 2.4 identifies Codex as powering Copilot, but the study did not measure the correctness of Copilot suggestions; its exercise result cannot establish that 20–30% of those suggestions are incorrect. (LLM, conf=0.86)

    Experimental — accuracy not yet measured
  • For introductory programming courses, Codex could generate sensible and novel exercises for students along with an appropriate sample solution around three out of four times.

    “Additionally, for introductory programming courses, the state-of-the-art LLMs, Codex, could generate sensible and novel exercises for students along with an appropriate sample solution (around three out of four times)”

    From Practical and ethical challenges of large language models in education: A systematic scoping review (2024) · cites this paper as Sarsa et al., 2022

    Section 4.1 reports that, among 120 evaluated exercises, 75.0% were sensible, 81.8% were novel, and 76.7% had a matching sample solution. The Conclusion says a majority met these criteria, but the copy does not report that around three out of four exercises met all three criteria together; the cited percentages measure them separately. (LLM, conf=0.83)

    Experimental — accuracy not yet measured
  • LLMs have demonstrated remarkable effectiveness in generating novel language artifacts such as course readings, code explanations, model solutions, feedback, and responses to help requests.

    “This has been inspired by many other instances where LLMs have already demonstrated remarkable effectiveness in generating novel language artifacts. These include course readings [22], code explanations [23, 28, 29, 41], model solutions [9, 35, 42], feedback [34], or responses to help requests [18, 26, 46, 47].”
  • These LLMs can write functionally correct code, with capabilities in solving introductory programming tasks and algorithmic challenges.

    “These LLMs can write functionally correct code, with studies showing capabilities in solving introductory programming tasks [17, 18] and algorithmic challenges [19])”

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

The self-check needs the paper’s full text.

Cites

Flagged first, then by citations

Research works printed but not linked: 5

  1. [9]9. Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language Models are Few-Shot Learners. In Advances in neural information processing systems. 1877-1901.
  2. [15]15. Paul Denny, Andrew Luxton-Reilly, Ewan Tempero, and Jacob Hendrickx. 2011. Codewrite: supporting student-driven practice of java. In Proceedings of the 42nd ACM technical symposium on Computer science education. 471-476.
  3. [32]32. John Hattie and Helen Timperley. 2007. The power of feedback. Review of educational research 77, 1 (2007), 81-112.
  4. [41]41. Juho Kim. 2015. Learnersourcing: improving learning with collective learner activity. Ph. D. Dissertation. Massachusetts Institute of Technology.
  5. [94]94. Lisa Yan, Annie Hu, and Chris Piech. 2019. Pensieve: Feedback on Coding Process for Novices. In Proceedings of the 50th ACM Technical Symposium on Computer Science Education (Minneapolis, MN, USA) (SIGCSE '19). Association for Computing Machinery, New York, NY, USA, 253-259.

Cited by

Sorted by citations

Authors
Sarsa, S., Denny, P., Hellas, A., & Leinonen, J.
Affiliations
  • Aalto University (FI)
  • University of Auckland (NZ)
Venue
Proceedings of the 2022 ACM Conference on International Computing Education Research - Volume 1
Publisher
ACM
Published
2022-08-03
Pages
27-43
OpenAlex
W4283705032
Cited by
497
References
94
Citations by year
2026: 85 · 2025: 151 · 2024: 170 · 2023: 88 · 2022: 3
FWCI
134.39
Type
conference paper
Language
en
Open access
Locations
  • ACM Conference on International Computing Education Research (ICER) (publishedVersion)
  • arXiv (Cornell University) (submittedVersion)
  • Aaltodoc (Aalto University) (submittedVersion, other-oa)
  • arXiv (Cornell University)
Topics
  • Physical Sciences › Computer Science › Computer Science Applications › Teaching and Learning Programming
  • Physical Sciences › Computer Science › Information Systems › Artificial Intelligence in Education
  • Physical Sciences › Computer Science › Information Systems › Software Engineering Research
Keywords
code explanation, large language models, OpenAI Codex, natural language generation, programming education, introductory programming, test case generation, sample solutions, instructor tools

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review