From a049a776734424d1857b7c9b828744e18e978b0e Mon Sep 17 00:00:00 2001 From: Jan Maximilian Michal <j.michal@stud.uni-goettingen.de> Date: Mon, 7 Nov 2016 15:59:10 +0000 Subject: [PATCH] fixed minor issue, updated README and added one script --- README.md | 11 ++++--- hallgrim/IliasXMLCreator/gap.py | 3 +- hallgrim/IliasXMLCreator/xmlBuildingBlocks.py | 2 +- .../gap/1478024104__9310__qti_82996.xml | 2 +- scripts/info1_02_klausur.py | 30 +++++++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 scripts/info1_02_klausur.py diff --git a/README.md b/README.md index c865f07..798c577 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ ## Usage -Invoke the script with `python3 gen.py -h` in order to see usage. Very limited -until now. +Invoke the script with `python3 grim.py -h` in order to see usage. Currently +many features are not yet implemented. Single and Multiple Chice questions +can be generated also in parametrized form. Example scripts can be found in `scripts/`. @@ -11,11 +12,13 @@ A first version of the tool that relied on autoilias is still in the repository (see `generator.py`). It will be removed as soon as the necessary features are implemented. +### Dependencies + +`pip install mistune` + ## TODO * Add a good description / documentation. -* Add instruction to produce multiple (parametrized) instances of a single -question. * Add more functionality (gap, alignment, etc.) * Make parsers more robust. * reverse ILIAS authentication mechanism for automated upload. diff --git a/hallgrim/IliasXMLCreator/gap.py b/hallgrim/IliasXMLCreator/gap.py index 6e794cb..fbe51a9 100644 --- a/hallgrim/IliasXMLCreator/gap.py +++ b/hallgrim/IliasXMLCreator/gap.py @@ -78,7 +78,8 @@ class GapQuestion: outcomes = et.Element('outcomes') outcomes.append(simple_elemet('decvar')) root.append(outcomes) - for i, (_, correct, points) in enumerate(self.questions): + is_gap = lambda t: type(t) = tuple + for i, (_, correct, points) in enumerate(filter(is_gap, self.gap_list)): root.append(respcondition(points if correct else 0, i, True)) root.append(respcondition(points if not correct else 0, i, False)) return root diff --git a/hallgrim/IliasXMLCreator/xmlBuildingBlocks.py b/hallgrim/IliasXMLCreator/xmlBuildingBlocks.py index 3fa2aa0..428f184 100644 --- a/hallgrim/IliasXMLCreator/xmlBuildingBlocks.py +++ b/hallgrim/IliasXMLCreator/xmlBuildingBlocks.py @@ -99,7 +99,7 @@ def response_str(ident, columns): response_str.append(render_fib) return response_str -def response_choice(ident, answers) +def response_choice(ident, answers): response_str = et.Element('response_str', attrib={'ident': indent, 'rcardinality': 'Single'}) render_choice = et.Element('render_choice', attrib={'shuffle': 'Yes'}) for i, answer in enumerate(answers): diff --git a/hallgrim/ilias_templates/gap/1478024104__9310__qti_82996.xml b/hallgrim/ilias_templates/gap/1478024104__9310__qti_82996.xml index 447d6b3..3d1db36 100644 --- a/hallgrim/ilias_templates/gap/1478024104__9310__qti_82996.xml +++ b/hallgrim/ilias_templates/gap/1478024104__9310__qti_82996.xml @@ -10,7 +10,7 @@ <qtimetadata> <qtimetadatafield> <fieldlabel>ILIAS_VERSION</fieldlabel> - <fieldentry>5.1.8 2016-08-03</fieldentry> + <fieldentry>5.1.8 2016-08-03</fieldentry> </qtimetadatafield> <qtimetadatafield> <fieldlabel>QUESTIONTYPE</fieldlabel> diff --git a/scripts/info1_02_klausur.py b/scripts/info1_02_klausur.py new file mode 100644 index 0000000..3ebc25c --- /dev/null +++ b/scripts/info1_02_klausur.py @@ -0,0 +1,30 @@ +meta = { + 'author': 'Carsten Damm', + 'title': 'Vermischtes zu elementaren Daten (I1-ID: e638zfi0qtg0)', + 'type': 'multiple choice', + 'points': 0.5, # per correct choice +} + +task = """ Markieren Sie alle zutreffenden Aussagen: """ + +choices = """ +[ ] `int x = Integer.MAX_VALUE; x++;` verursacht eine OverflowException. +[ ] Steuerzeichen werden vom Steuerwerk interpretiert. +[X] `if (b > 0 && a/b < 2)` ... ist besser als `if (a/b < 2 && b > 0)` ... +[ ] Umlaute im Quelltext verursachen Compilezeitfehler. +[X] `"h\u00F6chstens 6 Zeichen"` ist ein Literal. +[ ] `Integer.MAX_VALUE++;` verursacht einen Ganzzahlüberlauf. +[ ] UTF-8 ordnet jedem Zeichen eine Folge von 8 Bytes zu. +[X] Ganzzahl-Arithmetik ist schneller als Gleitkomma-Arithmetik. +""" + +feedback = """ +Die folgenden Aussagen sind korrekt: + +* `if (b > 0 && a/b < 2)` ... ist besser als `if (a/b < 2 && b > 0)` ... + * *Begründung:* `a/b < 2` ist aufwändiger zu berechnen als `b > 0`. Bei einer Prüfung des Wahrheitswerts einer Konjunktion muss der zweite Term nicht betrachtet werden, wenn der erste falsch ist. +* `"h\u00F6chstens 6 Zeichen"` ist ein Literal. + * *Begründung:* Da der String eine konstanten Wert darstellt ist er als Literal zu bezeichnen. +* Ganzzahl-Arithmetik ist schneller als Gleitkomma-Arithmetik. + * *Begründung:* Floating Point Arithmetik ist wesentlich aufwändiger als Integer Arithmetik (siehe zum Vergleich: Zweitkomplement und IEE-754) +""" \ No newline at end of file -- GitLab