NOTE: this is a modified version of something I used to generate content for a project I was doing a few months ago. I had to remove a lot of things like the exact prompts I used and the naming conventions so it needs a lot more updating to work for more general use cases.
This repository contains scripts and templates for generating course lessons and exporting them into Word documents for a course named {{ course_name }} which is a {{ course_level }} course in the {{ course_track }}. The scripts utilize generative AI prompts combined with lesson material to create structured outputs for modules.
This is the main directory for lesson-related files.
-
input/: Contains all the lesson material for each module.- Each module folder (e.g.,
module1,module2, etc.) includes markdown files for assignments, discussions, quizzes, voting exercises, and portfolio-related lessons.
- Each module folder (e.g.,
-
output/: Stores generated content for lessons. Each module folder contains the generated markdown or JSON outputs.- The
word_docs/subfolder contains Word document exports for each module.
- The
This folder contains specific prompt templates for each lesson type:
assignment/: Prompts for generating assignments.discussion/: Prompts for discussions.project/: Prompts for project-based lessons.quiz/: Prompts for quizzes.
course_generator/
│
├── course_lessons/
│ ├── input/ # Input lesson material
│ │ ├── module1/ # module-specific markdown files
│ │ └── module2/
│ ├── output/ # Generated outputs
│ │ ├── module1/ # Markdown or JSON files
│ │ ├── module2/
│ │ └── word_docs/ # Word documents for modules
│ └── prompts/ # Prompts for generating specific lesson types
│
├── app.py # Main lesson generation script
├── export_to_word.py # Exports generated lessons into Word documents
├── parse_json.py # Utilities for parsing JSON
├── pyproject.toml # Poetry configuration
├── poetry.lock # Poetry dependency lock file
└── README.md # Project documentation
app.py: Main script for generating lessons. Combines input lesson material with prompts to create outputs in theoutput/folder.export_to_word.py: Converts lesson outputs into formatted Word documents for each module.parse_json.py: Utility for parsing JSON into markdown or other formats..env: Stores environment variables like API keys.poetry.lock,pyproject.toml: Poetry configuration files for dependency management.
The scripts require Python 3.12+ and the dependencies listed in pyproject.toml. Use Poetry for dependency management.
-
Clone the Repository:
git clone <repository-url> cd course_generator
-
Set Up a Virtual Environment: Using Poetry:
poetry install poetry shell
Using pip (optional, if Poetry isn't available):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` pip install -r requirements.txt # This file is not included but can be manually generated from pyproject.toml
-
Set Environment Variables: Create a
.envfile with the necessary variables, such as the OpenAI API key.Example
.envfile:OPENAI_API_KEY=your_openai_api_key
Run app.py to generate lessons for all modules based on the prompts and lesson materials in course_lessons/input/.
python app.pyThis will process all markdown files in input/ and output the generated lessons to course_lessons/output/.
Run export_to_word.py to create Word documents for each module.
python export_to_word.pyThis will create .docx files for each module in course_lessons/output/word_docs/.
- Make sure your API key is correctly set up in the
.envfile before running the scripts. - Review the
course_lessons/output/directory for generated files. - Use
word_docs/for finalized Word documents ready for distribution.