This repository has code to extract, generate and create question banks and exams.
- Conda: Ensure you have Conda installed. If not, you can install it by following the official instructions here.
First clone the repository
git clone https://github.com/aamodvarma/question-generator cd question-generator To setup the conda environment run,
conda env create -f environment.yml Run the following to activate the environment,
conda activate question-generator To use the scripts in here you need an OpenAI access key. Once you get your access key run,
export OPENAI_API_KEY="your_api_key_here" There are three main things you can do,
- Extract Questions
- Generate Question
- Make Documents
You can extract questions from different sources, mainly from openstax and different exams.
extract.py has two arguments,
type: The type of our source. This could be eitheropenstaxorexam.subject: This is the different subjects that are supported. Currently we support,linear,multianddiffeq.
To extract questions from openstax for linear you can run,
python3 ./extract.py --type openstax --subject linear Batch generation is used to generate questions according to your needs. Currently two main types of generation is supported, fill in the blanks and question bank.
batch_generator.py takes in two arguments,
file: Location to the file with the extracted questions.type: Type of generation, eitherfillordefinitions
For instance to generate Linear Algebra Exams you can run the following command,
python3 ./batch_generator.py --file ./data/LinearFill.json --type fill Once the new questions are generated they are stored in the ./generated_files/ directory. Now we can use these to generate Latex files for these questions.
make_documents.py takes in two arguments,
type: Type of document to generate. This could be eitherbookorexamfile: Location to the file with the generated questions.
To generate a Linear Algebra exam from the previously generated linear fill in the blanks you can run,
python3 ./make_documents.py --file ./generated_files/{generated_file}.json --type exam