Package: eq-quizgen
Quiz GeneratorA tool for generating quizzes from a standard, text-based definition.
Quizzes can be taken from the standard definition and converted into:PDFsCanvas Quizzes (Uploaded to Canvas)GradeScope QuizzesBoth GradeScope-Compatible PDFs and Uploaded to GradeScopeHTML FormsSample quizzes that demonstrate all question types are availablein the CSE Cracks course.
Additionally, you can see examples of good questions by looking at thetest cases for this project.Documentation Table of Contents:Installation / RequirementsPythonKaTeX (NodeJS)Canvas UploadingGradeScope UploadingUsageParsing a Specific QuizOutputting a JSON QuizOutputting a TeX QuizOutputting an HTML QuizParsing a Specific QuestionParsing a Specific FileUploading a Quiz to CanvasUploading a Quiz to GradeScopeQuiz FormatQuestion PromptsQuiz DescriptionsQuestion TypesQuizGen Markdown SyntaxQuizGen Builtin TemplatesInstallation / RequirementsPythonThe project can be installed from PyPi with:pip install eq-quizgenStandard Python requirements are listed inpyproject.toml.
The project and Python dependencies can be installed from source with:pip3 install .KaTeX (NodeJS)To output equations in HTML documents (which includes Canvas),KaTeXis required.
KaTeX is distributed as a NodeJS package, and this project requires that KaTeX is accessible vianpx(which typically requires it to be installed vianpm).
Once NodeJS and NPM are installed, you can just install KaTeX normally:npm install katexCanvas UploadingTo upload quizzes to Canvas, you will need three things:The Canvas Base URLThe base URL for the Canvas instance you are using.Ex:https://canvas.ucsc.eduThe Canvas Course IDThe numeric ID for the course you want to upload the quiz under.You can find this by going to the main page for your course (or almost any page related to your course), and looking at the url.Ex: Forhttps://canvas.ucsc.edu/courses/12345, the course ID is12345.A Canvas Access TokenA token is specific for each user, and that user should the have ability to make quizzes for your specific course.To get a new token, go to your account settings ("Account" -> "Settings"), and under "Approved Integrations" click "+ New Access Token".GradeScope UploadingTo upload quizzes to GradeScope, you will need three things:A GradeScope Instructor AccountTechnically, any account capable of creating assignments should be sufficient.A GradeScope Account PasswordIf you normally log into GradeScope through an organization account (like via a university email), then you will just need to create a GradeScope password.
This can be done via thepassword reset page, which in this case will allow you to create a new password.A GradeScope Course IDUsageThis project has executable modules in thequizgen.clipackage.
All executable modules have their own help/usage accessible with the-h/--helpoption.Parsing a Specific QuizTo parse an entire specific quiz, you can use thequizgen.cli.parse-quizmodule.
This is useful if you want to check if a quiz properly parses.
The basic usage is as follows:python3 -m quizgen.cli.parse.quiz <path to quiz JSON file>This command will output the fully parsed quiz in for format controlled by the--formatoption,
and will exit with a non-zero status if the parse failed.
Parsing a quiz is particularly useful in CI to ensure that all course quizzes are properly maintained.The--keyflag can be used to generate an answer key instead of a normal quiz.
Not all formats support answer keys.Outputting a JSON QuizTo output a JSON quiz to a file calledquiz.json, you can use the following command:python3 -m quizgen.cli.parse.quiz <path to quiz JSON file> --format json > quiz.jsonA JSON representation of a parsed quiz (which is different from a standard quiz definition) can be useful for debugging.
If debugging, the--flatten-groupsflag can be useful (which will include all questions from all groups in the output quiz.Outputting a TeX QuizTo output a TeX quiz to a file calledquiz.tex, you can use the following command:python3 -m quizgen.cli.parse.quiz <path to quiz JSON file> --format tex > quiz.texYou can then compile or edit the TeX file as you see fit.Outputting an HTML QuizTo output a HTML quiz to a file calledquiz.html, you can use the following command:python3 -m quizgen.cli.parse.quiz <path to quiz JSON file> --format html > quiz.htmlAll question in an HTML quiz are grouped together into a single HTML form.Parsing a Specific QuestionTo parse a specific quiz question, you can use thequizgen.cli.parse.questionmodule.
This is useful if you want to check if a question properly parses.
The basic usage is as follows:python3 -m quizgen.cli.parse.question <path to question JSON file>This command will output the fully parsed question in the JSON format,
and will exit with a non-zero status if the parse failed.You can use the same--formatoptions used inquizgen.cli.parse.quizto change the output format of the question.
The question will be placed in a "dummy" quiz, so the output should be fully stand-alone.Parsing a Specific FileTo parse a specific file, you can use thequizgen.cli.parse.filemodule.
This is useful if you want to check if/how a specific document parses.
The basic usage is as follows:python3 -m quizgen.cli.parse.file <path to file> --format htmlThis command will output the fully parsed file in for format controlled by the--formatoption,
and will exit with a non-zero status if the parse failed.
This can be used to parse prompt markdown files.Uploading a Quiz to CanvasTo upload a quiz to Canvas, thequizgen.cli.canvas.uploadmodule can be used.
The basic usage is as follows:python3 -m quizgen.cli.canvas.upload <path to quiz JSON file> --course <canvas course id> --token <canvas access token>If an existing quiz with the same name is found, then nothing will be uploaded unless the--forceflag is given..Uploading a Quiz to GradeScopeTo upload a quiz to GradeScope, thequizgen.cli.gradescope.createmodule can be used.
The basic usage is as follows:python3 -m quizgen.cli.gradescope.gradescope <path to quiz JSON file> --course <course id> --user <username> --pass <password> --uploadSince GradeScope uses passwords instead of tokens, take extra caution about your password appearing in config files or command histories.Some additional options that may be useful:--force-- Use if you want to replace existing GradeScope assignments (otherwise existing assignments will be skipped).--outdir <dir>-- Choose where the output (TeX, PDF, etc) will be written to.--variants <X>-- Create X variants (alternate versions) if the quiz. X may be in [1, 26].You can also not use the--uploadflag to just create TeX/PDF versions of your quizzes that you can tweak and upload manually.Quiz FormatQuestion PromptsQuestion prompts can be provided in two ways:In a "prompt" field in thequestion.json.In a file adjacent to thequestion.jsonfile calledprompt.md.Putting the prompt directly in the JSON can be convenient for questions with short or simple prompts.
But for larger prompts that may involve things like tables and images,
having a whole file just for the prompt is generally recommended.WARNING: Remember that in JSON backslashes will need to be escaped.
So prompts written in JSON will need to escape backslashes
(which then in-turn may be used to escape characters in QuizGen markdown).For example, in markdown you may have a prompt like:This is a cool\-ish question.In JSON this would need to be:"prompt": "This is a cool\\-ish question."Quiz DescriptionsLike question prompts, quiz descriptions can either be specified in the quiz's JSON file,
or in an adjacent file with the same base filename as the quiz's JSON file but with themdextension.For example, the description could be in themy_quiz.jsonfile:"description": "Look at my awesome quiz\\!"Or, it can be in themy_quiz.mdfile in the same directory asmy_quiz.json:Look at my awesome quiz\!