Metadata-Version: 2.3
Name: gift-to-moodlexml
Version: 0.1.1
Summary: Extended GIFT format to Moodle XML question parser
License: MIT
Author: Benedikt Kantz
Author-email: benedikt@kantz.at
Requires-Python: >=3.14
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Dist: lxml (>=6.0.2,<7.0.0)
Requires-Dist: markdown (>=3.10.2,<4.0.0)
Requires-Dist: pyparsing (>=3.3.2,<4.0.0)
Description-Content-Type: text/markdown

# 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:

```md
$CATEGORY: OOP2/Intro

[markdown]Java supports use of `varargs` (variable arguments) for parameter passing {T}

[markdown] What pattern does this Code use?
```java
public class Logger {
    private static Logger instance;
    private String filename;
    private Logger() {}
    public static Logger getInstance() {
        if (instance == null) {
            instance = new Config();
        }
        return instance;
    }
    public String getFilename() {
        return filename;
    }
    public void setFilename(String filename) {
        this.filename = filename;
    }
}
```
{
    ~ Factory
    ~ Configurator
    = Singleton
    ~ Generics
    ~ Builder
    ~ Creator
    ~ Observer
}
```
Then you can parse it to an XML to upload to moodle:

```python
import gift_to_moodlexml
from pathlib import Path
questions_files= list(Path("./").glob("*.gift"))
all_questions = []
for q_file in questions_files:
    with open(q_file, "r") as file:
        content = file.read()
        questions = content.split("\n\n")
        questions = [q for q in questions]
        question = questions[0]
        all_questions.extend(questions)
gift_to_moodlexml.generate_xml_from_questions(all_questions, output_file="quiz_package.xml")
```
