gift-to-moodlexml
Creating Moodle XML Questions from extended GIFT format
Features
- Parse GIFT files more robustly compared to moodle
- Supports full markdown syntax (incl. Code highlighting!)
- Points are automatically inferred OR can be set!
- Deducts -50% for single choice, -100% for T/F question
- Supports:
- True/False Question (will be converted to Multichoice to allow point deduction)
- Multichoice
- Single Choice
- Fill-the Blank
Install
pip install gift-to-moodlexml
Usage
Assume you have some (extended) GIFT file:
1$CATEGORY: OOP2/Intro
2
3[markdown]Java supports use of `varargs` (variable arguments) for parameter passing {T}
4
5[markdown] What pattern does this Code use?
6`Logger logger=Logger.getInstance();`
7{
8 ~ Factory
9 ~ Configurator
10 = Singleton
11 ~ Generics
12 ~ Builder
13 ~ Creator
14 ~ Observer
15}
Then you can parse it to an XML to upload to moodle:
1import gift_to_moodlexml
2from pathlib import Path
3questions_files= list(Path("./").glob("*.gift"))
4all_questions = []
5for q_file in questions_files:
6 with open(q_file, "r") as file:
7 content = file.read()
8 questions = content.split("\n\n")
9 questions = [q for q in questions]
10 question = questions[0]
11 all_questions.extend(questions)
12gift_to_moodlexml.generate_xml_from_questions(all_questions, output_file="quiz_package.xml")