ecuartasm commited on
Commit
0c6f454
Β·
1 Parent(s): 0b17ac5
Files changed (1) hide show
  1. README.md +181 -187
README.md CHANGED
@@ -1,232 +1,226 @@
1
  # AI Course Assessment Generator
2
 
3
- This application generates learning objectives and multiple-choice questions for AI course materials based on uploaded content files. It uses OpenAI's language models to create high-quality educational assessments that adhere to specified quality standards.
 
 
4
 
5
  ## Features
6
 
7
- - Upload course materials in various formats (.vtt, .srt, .ipynb)
8
- - Generate customizable number of learning objectives
9
- - Create multiple-choice questions based on learning objectives
10
- - Evaluate question quality using an LLM judge
11
- - Save assessments to JSON format
12
- - Track source references for each learning objective and question
13
 
14
- ## Setup
15
 
16
- 1. Clone this repository
17
- 2. Install the required dependencies:
18
- ```
19
- pip install -r requirements.txt
20
- ```
21
- 3. Create a `.env` file in the project root with your OpenAI API key:
22
- ```
23
- OPENAI_API_KEY=your_api_key_here
24
- ```
25
-
26
- ## Usage
27
-
28
- 1. Run the application:
29
- ```
30
- python app.py
31
- ```
32
- 2. Open the Gradio interface in your web browser (typically at http://127.0.0.1:7860)
33
- 3. Upload your course materials (.vtt, .srt, .ipynb files)
34
- 4. Specify the number of learning objectives to generate
35
- 5. Select the OpenAI model to use
36
- 6. Generate learning objectives
37
- 7. Review and provide feedback on the generated objectives
38
- 8. Generate multiple-choice questions based on the approved objectives
39
- 9. Review the generated questions and their quality assessments
40
- 10. The final assessment will be saved as `assessment.json` in the project directory
41
-
42
- ## Project Structure
43
-
44
- - `app.py`: Entry point for the application
45
-
46
- ### Modules
47
-
48
- - `models/`: Pydantic data models
49
- - `__init__.py`: Exports all models
50
- - `learning_objectives.py`: Learning objective data models
51
- - `questions.py`: Question and option data models
52
- - `assessment.py`: Assessment data models
53
-
54
- - `ui/`: User interface components
55
- - `__init__.py`: Package initialization
56
- - `app.py`: Gradio UI implementation
57
- - `content_processor.py`: Processes uploaded files and extracts content
58
- - `objective_handlers.py`: Handlers for learning objective generation
59
- - `question_handlers.py`: Handlers for question generation
60
- - `feedback_handlers.py`: Handlers for feedback and regeneration
61
- - `formatting.py`: Formatting utilities for UI display
62
- - `state.py`: State management for the UI
63
-
64
- - `quiz_generator/`: Quiz generation components
65
- - `__init__.py`: Package initialization
66
- - `generator.py`: Main QuizGenerator class
67
- - `assessment.py`: Assessment generation logic
68
- - `question_generation.py`: Question generation logic
69
- - `question_improvement.py`: Question quality improvement logic
70
- - `question_ranking.py`: Question ranking and grouping logic
71
- - `feedback_questions.py`: Feedback-based question generation
72
-
73
- - `learning_objective_generator/`: Learning objective generation components
74
- - `__init__.py`: Package initialization
75
- - `generator.py`: Main generator class
76
- - `base_generation.py`: Base generation logic
77
- - `enhancement.py`: Enhancement logic
78
- - `grouping_and_ranking.py`: Grouping and ranking logic
79
-
80
- - `prompts/`: Prompt templates and components
81
- - `questions.py`: Question generation prompts
82
- - `incorrect_answers.py`: Incorrect answer generation prompts
83
- - `learning_objectives.py`: Learning objective generation prompts
84
-
85
- - `obsolete/`: Deprecated files (not used in current implementation)
86
-
87
- - `specs.md`: Project specifications
88
- - `project_flow.md`: Detailed description of the project architecture and workflow
89
 
90
- ## Requirements
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- - Python 3.8+
93
- - Gradio 4.19.2+
94
- - Pydantic 2.8.0+
95
- - OpenAI 1.52.0+
96
- - nbformat 5.9.2+
97
- - instructor 1.7.9+
98
- - python-dotenv 1.0.0+
99
 
100
- Install dependencies using uv (recommended):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  ```
102
- uv venv -p 3.12
103
- source .venv/bin/activate # On Windows use: .venv\Scripts\activate
104
- uv pip install -r requirements.txt
 
 
 
 
 
 
 
 
 
 
105
  ```
106
 
107
- ## Notes
108
-
109
- - The application uses XML-style source tags to track which file each piece of content comes from
110
- - Questions are evaluated against quality standards to ensure they meet educational requirements
111
- - Each question includes feedback for both correct and incorrect answers
112
 
113
- ## Prompt Structure
114
 
115
- The application's prompt system in `prompts.py` has been refactored into modular components for better maintainability:
116
 
117
- - `GENERAL_QUALITY_STANDARDS`: Overall quality standards for all generated content
118
- - `QUESTION_SPECIFIC_QUALITY_STANDARDS`: Standards specific to question generation
119
- - `CORRECT_ANSWER_SPECIFIC_QUALITY_STANDARDS`: Standards for correct answer options
120
- - `INCORRECT_ANSWER_SPECIFIC_QUALITY_STANDARDS`: Standards for creating plausible incorrect answers
121
- - `EXAMPLE_QUESTIONS`: A collection of high-quality example questions for model guidance
122
- - `MULTIPLE_CHOICE_STANDARDS`: Standards specific to multiple-choice question format
123
- - `BLOOMS_TAXONOMY_LEVELS`: Educational taxonomy for different levels of learning
124
- - `ANSWER_FEEDBACK_QUALITY_STANDARDS`: Standards for providing helpful feedback
125
- - `LEARNING_OBJECTIVES_PROMPT`: Template for generating learning objectives
126
- - `LEARNING_OBJECTIVE_EXAMPLES`: Examples of well-formulated learning objectives
127
 
128
- These components are imported and combined in `quiz_generator.py` to create comprehensive prompts for different generation tasks. This modular approach makes it easier to:
129
 
130
- 1. Update individual aspects of the prompt without affecting others
131
- 2. Reuse common standards across different generation tasks
132
- 3. Maintain consistent quality across all generated content
 
 
 
133
 
134
- ## Detailed Project Flow
 
 
 
135
 
136
- ### Overview
137
 
138
- This section provides a more detailed look at how the various components of the system work together to generate educational assessments.
 
 
 
139
 
140
- ### Core Components
141
 
142
- 1. **Content Processing**: Handles ingestion of course materials from different file formats
143
- 2. **Learning Objective Generation**: Creates learning objectives from the processed content
144
- 3. **Question Generation**: Produces multiple-choice questions for each learning objective
145
- 4. **Quality Assessment**: Evaluates the generated questions for quality
146
- 5. **UI Interface**: Provides a Gradio-based web interface for user interaction
147
 
148
- ### Application Entry Point (`app.py`)
 
 
149
 
150
- - Serves as the entry point for the application
151
- - Loads environment variables (including OpenAI API key)
152
- - Creates and launches the Gradio UI
153
 
154
- ### User Interface (`ui/` module)
155
 
156
- - Creates the Gradio interface for user interaction
157
- - Organizes functionality into tabs:
158
- - File upload and learning objective generation
159
- - Question generation
160
- - Preview and export
161
 
162
- - Key components:
163
- - `app.py`: Creates the Gradio interface and defines the UI layout
164
- - `objective_handlers.py`: Handles learning objective generation and regeneration
165
- - `question_handlers.py`: Handles question generation and regeneration
166
- - `feedback_handlers.py`: Handles user feedback and custom question generation
167
- - `formatting.py`: Formats quiz data for UI display
168
- - `state.py`: Manages state between UI components
169
 
170
- ### Content Processing (`ui/content_processor.py`)
171
 
172
- - `ContentProcessor` class processes different file types:
173
- - `.vtt` and `.srt` subtitle files
174
- - `.ipynb` Jupyter notebook files
175
- - For each file, adds XML source tags to track the origin of content
176
- - Returns structured content for further processing
177
 
178
- ### Quiz Generation (`quiz_generator/` module)
179
 
180
- - `QuizGenerator` class is the central component that:
181
- - Generates learning objectives from processed content
182
- - Creates multiple-choice questions for each objective
183
- - Judges question quality
184
- - Saves assessments to JSON
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
- #### Learning Objective Generation
187
 
188
- 1. Takes processed file contents as input
189
- 2. Combines content and creates a prompt (utilizing modular components from `prompts.py`)
190
- 3. Uses OpenAI's API with instructor to generate learning objectives
191
- 4. Returns structured `LearningObjective` objects
192
 
193
- #### Question Generation
194
 
195
- 1. For each learning objective:
196
- - Retrieves relevant content from source files
197
- - Creates a prompt by combining modular components from `prompts.py`
198
- - Generates a multiple-choice question with feedback for each option
199
- - Returns a structured `MultipleChoiceQuestion` object
 
 
 
 
 
200
 
201
- ### Data Models (`models/` module)
202
 
203
- Defines the data structures used throughout the application:
204
- - `LearningObjective`: Represents a learning objective with ID, text, and source references
205
- - `MultipleChoiceOption`: Represents an answer option with text, correctness flag, and feedback
206
- - `MultipleChoiceQuestion`: Represents a complete question with options, linked to learning objectives
207
- - `RankedMultipleChoiceQuestion`: Extends MultipleChoiceQuestion with ranking information
208
- - `GroupedMultipleChoiceQuestion`: Extends RankedMultipleChoiceQuestion with grouping information
209
- - `Assessment`: Collection of learning objectives and questions
 
210
 
211
- ### Prompt Component Integration
212
 
213
- The modular prompt components in the `prompts/` directory are imported into the quiz generation modules and assembled into complete prompts as needed:
214
 
215
- 1. **Learning Objective Generation**:
216
- - Components like `LEARNING_OBJECTIVES_PROMPT`, `LEARNING_OBJECTIVE_EXAMPLES`, and `BLOOMS_TAXONOMY_LEVELS` are combined with course content
217
- - This creates a comprehensive prompt that guides the LLM in generating relevant and well-structured learning objectives
218
 
219
- 2. **Question Generation**:
220
- - Components like `GENERAL_QUALITY_STANDARDS`, `MULTIPLE_CHOICE_STANDARDS`, `QUESTION_SPECIFIC_QUALITY_STANDARDS`, etc. are combined
221
- - Along with the learning objective and course content, these form a detailed prompt that ensures high-quality question generation
222
 
223
- ### Workflow Summary
224
 
225
- 1. User uploads content files (notebooks, subtitles) through the UI
226
- 2. System processes files and extracts content with source references
227
- 3. LLM generates learning objectives based on content
228
- 4. User reviews and approves learning objectives
229
- 5. System generates multiple-choice questions for each approved objective
230
- 6. Questions are presented to the user for review and export
231
 
232
- This modular approach makes it easier to maintain, update, and experiment with different prompt components without disrupting the overall system. Any changes to the components in `prompts.py` will affect how learning objectives and questions are generated, potentially changing the style, format, and quality of the output.
 
 
 
 
 
 
 
 
 
1
  # AI Course Assessment Generator
2
 
3
+ An AI-powered tool that creates learning objectives and multiple-choice quiz questions from course materials. Supports both **automatic generation** from uploaded content and **manual entry** of learning objectives, producing fully enriched outputs with correct and incorrect answer suggestions ready for quiz generation.
4
+
5
+ ---
6
 
7
  ## Features
8
 
9
+ ### Tab 1 β€” Generate Learning Objectives
 
 
 
 
 
10
 
11
+ **Two modes of operation:**
12
 
13
+ - **Generate from course materials** β€” Upload course files and let the AI extract and generate learning objectives automatically through a multi-run, multi-stage pipeline.
14
+ - **Use my own learning objectives** β€” Enter your own learning objectives in a text field (one per line). The app searches the uploaded course materials for relevant source references, generates a correct answer for each objective, and produces incorrect answer options β€” the same full pipeline as automatic generation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ **Shared capabilities (both modes):**
17
+ - Configurable AI model and temperature for both generation and incorrect answer suggestion steps
18
+ - All output in the same JSON format, ready to feed directly into Tab 2
19
+ - "Generate all" button runs the full end-to-end pipeline (learning objectives β†’ quiz questions) in a single click, in either mode
20
+
21
+ ### Tab 2 β€” Generate Questions
22
+
23
+ - Takes the learning objectives JSON produced in Tab 1 as input
24
+ - Generates multiple-choice questions with 4 options, per-option feedback, and source references
25
+ - Configurable number of questions and generation runs
26
+ - Automatic ranking and grouping of generated questions by quality
27
+ - Outputs: ranked best-in-group questions, all grouped questions, and a human-readable formatted quiz
28
+
29
+ ### Tab 3 β€” Propose / Edit Question
30
+
31
+ - Load the formatted quiz from Tab 2 or upload a `.md` / `.yml` quiz file
32
+ - Review and edit questions one at a time with Previous / Accept & Next navigation
33
+ - Download the final edited quiz
34
+
35
+ ---
36
+
37
+ ## Generation Pipeline (Learning Objectives)
38
 
39
+ ### Automatic generation mode
 
 
 
 
 
 
40
 
41
+ 1. **Content extraction** β€” Uploads are parsed (`.vtt`, `.srt`, `.ipynb`, `.md`) and wrapped with XML source tags for full traceability
42
+ 2. **Multi-run base generation** β€” Multiple independent runs produce candidate objectives (Bloom's taxonomy aware, one action verb, multiple-choice assessable)
43
+ 3. **Correct answer generation** β€” A concise correct answer (~20 words) is generated for each objective from the course content
44
+ 4. **Grouping & ranking** β€” Similar objectives are clustered; the best representative in each group is selected
45
+ 5. **Incorrect answer generation** β€” Three plausible distractors are generated for each best-in-group objective, matching the correct answer in length, style, and complexity
46
+ 6. **Iterative improvement** β€” Each distractor is evaluated and regenerated until it meets quality standards
47
+
48
+ ### User-provided objectives mode
49
+
50
+ 1. **Objective parsing** β€” Text is split by newlines; common leading labels are stripped automatically:
51
+ - Numbered: `1.`, `2)`, `3:`
52
+ - Lettered: `a.`, `b)`, `c:`
53
+ - Plain (no label)
54
+ 2. **Source finding** β€” For each objective, the LLM searches the uploaded course materials to identify the most relevant source file(s)
55
+ 3. **Correct answer generation** β€” Same function as the automatic flow, grounded in the course content
56
+ 4. **Incorrect answer generation** β€” Same three-distractor generation as automatic flow
57
+ 5. **Iterative improvement** β€” Same quality improvement loop
58
+ 6. All objectives are treated as best-in-group (the user has already curated them), so no grouping/filtering step is applied
59
+
60
+ **Example accepted input formats:**
61
  ```
62
+ Identify key upstream and downstream collaborators for data engineers
63
+ Identify the stages of the data engineering lifecycle
64
+ Articulate a mental framework for building data engineering solutions
65
+ ```
66
+ ```
67
+ 1. Identify key upstream and downstream collaborators for data engineers
68
+ 2. Identify the stages of the data engineering lifecycle
69
+ 3. Articulate a mental framework for building data engineering solutions
70
+ ```
71
+ ```
72
+ a. Identify key upstream and downstream collaborators for data engineers
73
+ b. Identify the stages of the data engineering lifecycle
74
+ c. Articulate a mental framework for building data engineering solutions
75
  ```
76
 
77
+ ---
 
 
 
 
78
 
79
+ ## Setup
80
 
81
+ ### Prerequisites
82
 
83
+ - Python 3.12 (recommended) or 3.8+
84
+ - An OpenAI API key
 
 
 
 
 
 
 
 
85
 
86
+ ### Installation
87
 
88
+ **Using uv (recommended):**
89
+ ```bash
90
+ uv venv -p 3.12
91
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
92
+ uv pip install -r requirements.txt
93
+ ```
94
 
95
+ **Using pip:**
96
+ ```bash
97
+ pip install -r requirements.txt
98
+ ```
99
 
100
+ ### Environment variables
101
 
102
+ Create a `.env` file in the project root:
103
+ ```
104
+ OPENAI_API_KEY=your_api_key_here
105
+ ```
106
 
107
+ ---
108
 
109
+ ## Running the app
 
 
 
 
110
 
111
+ ```bash
112
+ python app.py
113
+ ```
114
 
115
+ Opens the Gradio interface at [http://127.0.0.1:7860](http://127.0.0.1:7860).
 
 
116
 
117
+ ---
118
 
119
+ ## Supported file formats
 
 
 
 
120
 
121
+ | Format | Description |
122
+ |--------|-------------|
123
+ | `.vtt` | WebVTT subtitle files (timestamps stripped) |
124
+ | `.srt` | SRT subtitle files (timestamps stripped) |
125
+ | `.ipynb` | Jupyter notebooks (markdown and code cells extracted) |
126
+ | `.md` | Markdown files |
 
127
 
128
+ All content is wrapped with XML source tags (`<source file="filename">…</source>`) so every generated objective and question can be traced back to its origin file.
129
 
130
+ ---
 
 
 
 
131
 
132
+ ## Project structure
133
 
134
+ ```
135
+ quiz_generator_ECM/
136
+ β”‚
137
+ β”œβ”€β”€ app.py # Entry point β€” loads .env and launches Gradio
138
+ β”‚
139
+ β”œβ”€β”€ models/ # Pydantic data models
140
+ β”‚ β”œβ”€β”€ learning_objectives.py # BaseLearningObjective β†’ LearningObjective β†’ Grouped*
141
+ β”‚ β”œβ”€β”€ questions.py # MultipleChoiceQuestion β†’ Ranked* β†’ Grouped*
142
+ β”‚ β”œβ”€β”€ assessment.py # Assessment (objectives + questions)
143
+ β”‚ └── config.py # Model list and temperature availability map
144
+ β”‚
145
+ β”œβ”€β”€ prompts/ # Reusable prompt components
146
+ β”‚ β”œβ”€β”€ learning_objectives.py # Bloom's taxonomy, quality standards, examples
147
+ β”‚ β”œβ”€β”€ incorrect_answers.py # Distractor guidelines and examples
148
+ β”‚ β”œβ”€β”€ questions.py # Question and answer quality standards
149
+ β”‚ └── all_quality_standards.py # General quality standards
150
+ β”‚
151
+ β”œβ”€β”€ learning_objective_generator/ # Learning objective pipeline
152
+ β”‚ β”œβ”€β”€ generator.py # LearningObjectiveGenerator orchestrator
153
+ β”‚ β”œβ”€β”€ base_generation.py # Base generation, correct answers, source finding
154
+ β”‚ β”œβ”€β”€ enhancement.py # Incorrect answer generation
155
+ β”‚ β”œβ”€β”€ grouping_and_ranking.py # Similarity grouping and best-in-group selection
156
+ β”‚ └── suggestion_improvement.py # Iterative distractor quality improvement
157
+ β”‚
158
+ β”œβ”€β”€ quiz_generator/ # Question generation pipeline
159
+ β”‚ β”œβ”€β”€ generator.py # QuizGenerator orchestrator
160
+ β”‚ β”œβ”€β”€ question_generation.py # Multiple-choice question generation
161
+ β”‚ β”œβ”€β”€ question_improvement.py # Question quality assessment and improvement
162
+ β”‚ β”œβ”€β”€ question_ranking.py # Ranking and grouping of questions
163
+ β”‚ β”œβ”€β”€ feedback_questions.py # Feedback-based question regeneration
164
+ β”‚ └── assessment.py # Assessment compilation and export
165
+ β”‚
166
+ └── ui/ # Gradio interface and handlers
167
+ β”œβ”€β”€ app.py # UI layout, mode toggle, event wiring
168
+ β”œβ”€β”€ objective_handlers.py # Handlers for both objective modes + Generate all
169
+ β”œβ”€β”€ question_handlers.py # Question generation handler
170
+ β”œβ”€β”€ content_processor.py # File parsing and XML source tagging
171
+ β”œβ”€β”€ edit_handlers.py # Question editing flow (Tab 3)
172
+ β”œβ”€β”€ formatting.py # Quiz formatting for UI display
173
+ β”œβ”€β”€ state.py # Global state (file contents, objectives)
174
+ └── run_manager.py # Run tracking and output saving
175
+ ```
176
 
177
+ ---
178
 
179
+ ## Data models
 
 
 
180
 
181
+ Learning objectives progress through these stages:
182
 
183
+ ```
184
+ BaseLearningObjectiveWithoutCorrectAnswer
185
+ └─ id, learning_objective, source_reference
186
+ ↓
187
+ BaseLearningObjective
188
+ └─ + correct_answer
189
+ ↓
190
+ LearningObjective (output of Tab 1, input to Tab 2)
191
+ └─ + incorrect_answer_options, in_group, group_members, best_in_group
192
+ ```
193
 
194
+ Questions follow an equivalent progression:
195
 
196
+ ```
197
+ MultipleChoiceQuestion
198
+ └─ id, question_text, options (text + is_correct + feedback),
199
+ learning_objective_id, correct_answer, source_reference
200
+ ↓
201
+ RankedMultipleChoiceQuestion
202
+ └─ + rank, ranking_reasoning, in_group, group_members, best_in_group
203
+ ```
204
 
205
+ ---
206
 
207
+ ## Model configuration
208
 
209
+ Default model: `gpt-5.2`
210
+ Default temperature: `1.0` (ignored for models that do not support it, such as `o1`, `o3-mini`, `gpt-5`, `gpt-5.1`, `gpt-5.2`)
 
211
 
212
+ You can set different models for the main generation step and the incorrect answer suggestion step, which is useful for using a more creative model for distractors.
 
 
213
 
214
+ ---
215
 
216
+ ## Requirements
 
 
 
 
 
217
 
218
+ | Package | Version |
219
+ |---------|---------|
220
+ | Python | 3.8+ (3.12 recommended) |
221
+ | gradio | 4.19.2+ |
222
+ | pydantic | 2.8.0+ |
223
+ | openai | 1.52.0+ |
224
+ | nbformat | 5.9.2+ |
225
+ | instructor | 1.7.9+ |
226
+ | python-dotenv | 1.0.0+ |