diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9e97696345f95b4fb35fceebdc140e682e52bf91 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/* +output/* diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bcefd2bdad997d919702e9257f7ae5bd7622d34b --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +*Add a good description / documenation \ No newline at end of file diff --git a/generator.py b/generator.py new file mode 100644 index 0000000000000000000000000000000000000000..0948e36fb9d18d371bb06c37d4d2bee2ab772765 --- /dev/null +++ b/generator.py @@ -0,0 +1,29 @@ +import os +import re + + +def create_autoilias_script(type, title, author, question, solution, + points=9999, answer=None, gapLength=None, number=1): + with open("templates/generic.class.php", "r", encoding='utf-8') as script: + script = script.read() + + if not gapLength: + gapComment = "" + gapLength = int(gapLength) + else: + gapComment = "//" + gapLength = "" + + script = script.format( + type=type, title=title, author=author, number=number, points=points, + gapComment=gapComment, gapLength=gapLength, question=question, + solution=solution, + ) + + with open("output/" + title.replace(' ', "_") + ".class.php", 'w', encoding='utf-8') as output: + print(script, file=output) + +for script in filter(lambda dat: re.search('\d+_\w+\.py', dat), os.listdir('./src')): + with open('./src/' + script) as script_f: + exec(script_f.read()) + create_autoilias_script(**meta) \ No newline at end of file diff --git a/02_chomsky_grammar.py b/src/02_chomsky_grammar.py similarity index 78% rename from 02_chomsky_grammar.py rename to src/02_chomsky_grammar.py index f1085a28c7c7ea0b05b21b0a2d2bacf1326feb44..bc2eb47af5820cf1d45150e67ef66fbd306df8ad 100644 --- a/02_chomsky_grammar.py +++ b/src/02_chomsky_grammar.py @@ -41,8 +41,8 @@ def parse(grammer): P, T, N = parse(delta) -print(('\n'.join(map(str, P)))) -print() +# print(('\n'.join(map(str, P)))) +# print() letters_to_kill = {p.left for p in P if not p.right} new_P = set() | P @@ -56,23 +56,33 @@ for p in P: new_P |= {rule(p.left, r.format(*prod).replace("0", ""))} P = {p for p in new_P if p.right} -print(('\n'.join(map(str, P)))) -print() +# print(('\n'.join(map(str, P)))) +# print() for t in T: P |= {rule("T_" + t, t)} -print(T) +# print(T) new_P = set() | P for p in P: p.right = ["T_" + p if p in T else p for p in p.right] P = new_P -print(('\n'.join(map(str, P)))) -print() +# print(('\n'.join(map(str, P)))) +# print() new_P = set() | P for p in P: if len(p.right) > 2: pass + +### END OF SCRIPT ############################################################## +meta = { + "type" : "GAP", + "title" : "Grammatik in Chomsky Normalform umwandeln", + "author" : "Jan Maximilian Michal", + "gapLength" : 10, + "question" : "Empty", + "solution" : "TODO", +} \ No newline at end of file diff --git a/04_minimize_dea.py b/src/04_minimize_dea.py similarity index 93% rename from 04_minimize_dea.py rename to src/04_minimize_dea.py index c7122797ae7e75605496f385f0165b59d2a0e281..5bc579c4fc73de019c68b81d2f2e2579bf6cdc4a 100644 --- a/04_minimize_dea.py +++ b/src/04_minimize_dea.py @@ -1,4 +1,3 @@ -from DFA import * from itertools import product from graphviz import Digraph @@ -141,6 +140,14 @@ F = ["s2"] F2 = ["s0", "s3", "s4", "s6"] A = Automaton(states2, "ab", delta2, "s0", F2) -A.minimize() -print(A.generate_ilias()) + +### END OF SCRIPT ############################################################## +meta = { + "type" : "GAP", + "title" : "Minimieren eines deterministischen Automaten", + "author" : "Jan Maximilian Michal", + "gapLength" : 10, + "question" : A.generate_ilias(), + "solution" : "TODO", +} \ No newline at end of file diff --git a/05_nea_to_dea.py b/src/05_nea_to_dea.py similarity index 81% rename from 05_nea_to_dea.py rename to src/05_nea_to_dea.py index 51f22c1661e2ac9fe78bf9a332383295decbec09..3378d92989f89d110fcfb72aca084588a6a53c62 100644 --- a/05_nea_to_dea.py +++ b/src/05_nea_to_dea.py @@ -1,8 +1,6 @@ from collections import deque from functools import reduce from graphviz import Digraph -# from pprint import pprint as print - class NEA: @@ -54,7 +52,7 @@ class NEA: f.view() # return str(f.pipe(), encoding='utf-8') - def generate_ilias(self): + def _generate_ilias(self): table = self.to_dea() aufgabe = ''' Aufgabentext\n\n''' @@ -69,14 +67,17 @@ class NEA: aufgabe += tr.format(''.join(td.format(','.join(sorted(s))) for s in row)) aufgabe += '</table>' - print(aufgabe.replace('"', r'\"')) + yield(aufgabe.replace('"', r'\"')) - print("{:>25}{:>25}{:>25}".format("delta", "a", "b")) + yield("{:>25}{:>25}{:>25}".format("delta", "a", "b")) for row in table: - print("{:>25}{:>25}{:>25}".format(*map(', '.join, (sorted(s) for s in row)))) + yield("{:>25}{:>25}{:>25}".format(*map(', '.join, (sorted(s) for s in row)))) + def generate_ilias(self): + return ''.join(self._generate_ilias()) +# Define one Automaton def delta(state, char): return { ('s0', 'a'): {'s0', 's1'}, @@ -95,7 +96,15 @@ def delta(state, char): states = ["s{}".format(i) for i in range(4)] F = ["s3"] +# create N = NEA(states, "ab", delta, 's0', F) -N.to_dea() -# N.graph_output() -N.generate_ilias() \ No newline at end of file + +### END OF SCRIPT ############################################################## +meta = { + "type" : "GAP", + "title" : "NEA to DEA", + "author" : "Jan Maximilian Michal", + "gapLength" : 10, + "question" : N.generate_ilias(), + "solution" : "TODO", +} diff --git a/__init__.py b/src/__init__.py similarity index 100% rename from __init__.py rename to src/__init__.py diff --git a/templates/free.class.php b/templates/free.class.php new file mode 100755 index 0000000000000000000000000000000000000000..5c058b0fb6633eb87071783d361824fa8ca035bd --- /dev/null +++ b/templates/free.class.php @@ -0,0 +1,17 @@ +<?php + class autoILIASscript{ + function autoILIASscript(){ + $this->qType = "FREE"; + $this->qTitle = "Freitext Frage"; + $this->qAuthor = "Vorname Name"; + $this->qNumber = 100; + $this->qPoints = 10; + } + + function exe(){ + $question = "Fragentext..."; + $ml = "Musterlösung..."; + return array("q" => $question, "m" => $ml); + } + } +?> diff --git a/templates/gap.class.php b/templates/gap.class.php new file mode 100755 index 0000000000000000000000000000000000000000..7dcdb7d3cc8f4bef938ab20a120e1873a6cfa622 --- /dev/null +++ b/templates/gap.class.php @@ -0,0 +1,18 @@ +<?php + class autoILIASscript{{ + function autoILIASscript(){{ + $this->qType = "{type}"; + $this->qTitle = "{title}"; + $this->qAuthor = "{author}"; + $this->qNumber = {number}; + $this->qPoints = {points}; + {isComment}$this->gapLength = {gapLength}; + }} + + function exe(){{ + $question = "{question}"; + $ml = "{solution}"; + return array("q" => $question, "m" => $ml); + }} + }} +?> diff --git a/templates/generic.class.php b/templates/generic.class.php new file mode 100755 index 0000000000000000000000000000000000000000..7b23e929c7f13de633edd20c70d1e02be64efe3c --- /dev/null +++ b/templates/generic.class.php @@ -0,0 +1,18 @@ +<?php + class autoILIASscript{{ + function autoILIASscript(){{ + $this->qType = "{type}"; + $this->qTitle = "{title}"; + $this->qAuthor = "{author}"; + $this->qNumber = {number}; + $this->qPoints = {points}; + {gapComment}$this->gapLength = {gapLength}; + }} + + function exe(){{ + $question = "{question}"; + $ml = "{solution}"; + return array("q" => $question, "m" => $ml); + }} + }} +?> diff --git a/templates/multi.class.php b/templates/multi.class.php new file mode 100755 index 0000000000000000000000000000000000000000..21b8d08c4174035dcc42df3a1a756a14dfbaa8cb --- /dev/null +++ b/templates/multi.class.php @@ -0,0 +1,29 @@ +<?php + + class autoILIASscript{ + + function autoILIASscript(){ + + $this->qType = "MULTI"; + $this->qTitle = "Mehrfach Auswahl Frage"; + $this->qAuthor = "Vorname Name"; + $this->qNumber = 100; + $this->qPoints = 10; // Gesamtpunktzahl = |Antwortmoeglichkeiten| * $this->qPoints + + } + + function exe(){ + + $question = "Fragentext..."; + + $answer = array(array("A", true), array("B", false), array("C", true)); + + $ml = "Musterlösung..."; + + return array("q" => $question, "a" => $answer, "m" => $ml); + + } + + } + +?> \ No newline at end of file diff --git a/templates/numeric.class.php b/templates/numeric.class.php new file mode 100755 index 0000000000000000000000000000000000000000..8751992454fbeeb7fd7e64654e23c4cb7fbfdcf9 --- /dev/null +++ b/templates/numeric.class.php @@ -0,0 +1,30 @@ +<?php + + class autoILIASscript{ + + function autoILIASscript(){ + + $this->qType = "NUMERIC"; + $this->qTitle = "Numerische Frage"; + $this->qAuthor = "Vorname Name"; + $this->qNumber = 100; + $this->qPoints = 10; + //$this->numericFormatstring = ""; + + } + + function exe(){ + + $question = "Fragentext..."; + + $answer = 42; + + $ml = "Musterlösung..."; + + return array("q" => $question, "a" => $answer, "m" => $ml); + + } + + } + +?> \ No newline at end of file diff --git a/templates/order.class.php b/templates/order.class.php new file mode 100755 index 0000000000000000000000000000000000000000..7c00c66da3d7c5df297936bd5fcff8c78a40496f --- /dev/null +++ b/templates/order.class.php @@ -0,0 +1,30 @@ +<?php + + class autoILIASscript{ + + function autoILIASscript(){ + + $this->qType = "ORDER"; + $this->qTitle = "Anordnungs Frage"; + $this->qAuthor = "Vorname Name"; + $this->qNumber = 100; + $this->qPoints = 10; + + } + + function exe(){ + + // <span style=\"font-size: x-small;\"><b>Hinweis: </b>GgF. müssen die Terme in der richtigen Reihenfolge durchnummeriert werden.</span> + $question = "Fragentext..."; + + $answer = array("A", "B", "C", "D"); + + $ml = "Musterlösung..."; + + return array("q" => $question, "a" => $answer, "m" => $ml); + + } + + } + +?> \ No newline at end of file diff --git a/templates/select.class.php b/templates/select.class.php new file mode 100755 index 0000000000000000000000000000000000000000..2b95cf399a7acf24188a88945de6efc0e2a17712 --- /dev/null +++ b/templates/select.class.php @@ -0,0 +1,27 @@ +<?php + + class autoILIASscript{ + + function autoILIASscript(){ + + $this->qType = "SELECT"; + $this->qTitle = "Auswahllücken Frage"; + $this->qAuthor = "Vorname Name"; + $this->qNumber = 100; + $this->qPoints = 10; + + } + + function exe(){ + + $question = "Fragentext mit Lücken zum Auswählen [select][i(2P)]richtig[/i][i(0P)]falsch[/i][/select]..."; + + $ml = "Musterlösung..."; + + return array("q" => $question, "m" => $ml); + + } + + } + +?> \ No newline at end of file diff --git a/templates/single.class.php b/templates/single.class.php new file mode 100755 index 0000000000000000000000000000000000000000..cb440d15a82d291eb5b99cc04ad96c12d9723a0f --- /dev/null +++ b/templates/single.class.php @@ -0,0 +1,29 @@ +<?php + + class autoILIASscript{ + + function autoILIASscript(){ + + $this->qType = "SINGLE"; + $this->qTitle = "Auswahl Frage"; + $this->qAuthor = "Vorname Name"; + $this->qNumber = 100; + $this->qPoints = 10; + + } + + function exe(){ + + $question = "Fragentext..."; + + $answer = array(array("A", false), array("B", false), array("C", true)); + + $ml = "Musterlösung..."; + + return array("q" => $question, "a" => $answer, "m" => $ml); + + } + + } + +?> \ No newline at end of file