We present CODE-GEN, a human-in-the-Loop, retrieval-augmented generation (RAG)-based agentic AI system for generating context-aligned multiple-choice questions to develop student code reasoning and comprehension abilities. CODE-GEN employs an agentic AI architecture in which a Generator agent produces multiple-choice coding comprehension questions aligned with course-specific learning objectives, while a Validator agent independently assesses content quality across seven pedagogical dimensions. Both agents are augmented with specialized tools that enhance computational accuracy and verify code outputs. To evaluate the effectiveness of CODE-GEN, we conducted an evaluation study involving six human subject-matter experts (SMEs) who judged 288 AI-generated questions. The SMEs produced a total of 2,016 human-AI rating pairs, indicating agreement or disagreement with the assessments of Validator, along with 131 instances of qualitative feedback. Analyses of SME judgments show strong system performance, with human-validated success rates ranging from 79.9% to 98.6% across the seven pedagogical dimensions. The analysis of qualitative feedback reveals that CODE-GEN achieves high reliability on dimensions well suited to computational verification and explicit criteria matching, including question clarity, code validity, concept alignment, and correct answer validity. In contrast, human expertise remains essential for dimensions requiring deeper instructional judgment, such as designing pedagogically meaningful distractors and providing high-quality feedback that reinforces understanding. These findings inform the strategic allocation of human and AI effort in AI-assisted educational content generation.
Figures & tables
Figure 1: CODE-GEN end-to-end system workflow.
Evaluation Dimension
Description
Classification Output
Rationale Output
Question Stem Clarity
Assesses whether the question stem is clearly worded and appropriately structured (containing code or purely conceptual)
Yes/No
Explanation of why the question stem is or is not clear
Code Validity
Verifies that the generated Python code is syntactically correct and appropriately demonstrates the target concept
Yes/No
Explanation of why the code is or is not valid and concept-appropriate
Concept Alignment
Evaluates whether the generated question assesses the learning objective specified in the provided context
Yes/No
Explanation of why the question does or does not align with the specified learning objective
Correct Answer Validity
Verifies whether the option marked as correct is indeed valid
Yes/No
Explanation of why the marked correct answer is or is not valid
Distractor Quality
Assesses whether incorrect options are plausible, pedagogically meaningful, and target common student misconceptions
Good/Poor
Explanation of why the distractor quality is good or poor
Correct Answer Feedback Quality
Evaluates whether the feedback clearly explains why the answer is correct and reinforces the underlying concept
Good/Poor
Explanation of why the correct answer feedback quality is good or poor
Table 1: Evaluation dimensions and Validator assessment outputs.
Figure 2: CODE-GEN web user interface.
Question Stem Clarity
Code Validity
Concept Alignment
Correct Answer Validity
Distractor Quality
Correct Answer Feedback Quality
Distractor Feedback Quality
Mean (%)
98.1
95.3
98.4
94.7
82.5
95.3
89.5
SD (%)
3.3
3.5
3.8
6.2
7.3
3.8
7.4
Table 2: Mean and Standard Deviation (SD) of SME–Validator agreement rates.
University of Alabama, Tuscaloosa, Alabama, USA · Brown University, Providence, Rhode Island, USA · Meharry Medical College, Nashville, Tennessee, USA +1