Skip to content
Snippets Groups Projects
Commit 8c02ebb2 authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

allow custom points for multi and single

parent 32fa1e87
No related branches found
No related tags found
No related merge requests found
......@@ -16,12 +16,15 @@ implemented.
`pip install mistune`
## TODO
### TODO
* Add a good description / documentation.
* Add more functionality (gap, alignment, etc.)
* Make parsers more robust.
* reverse ILIAS authentication mechanism for automated upload.
* Create whole test object with questions for direct import. Create two
versions (one for internal use and one for the test.)
* move moints from meta to parser
### Notes
......@@ -34,7 +37,7 @@ data and assumes unknown properties)
3. The XML structure for one or multiple questions, readable by Ilias.
4. An Ilias object packed as .zip file, ready for upload.
#### LaTeX Support
### LaTeX Support
Hallgrim supports the native latex approach by ILIAS. To typeset a formula just
out in backets like this `[[\\sum_{i=1}^n i = \\frac{n(n+1)}{2}]]`. Special
......
......@@ -2,6 +2,7 @@ import xml.etree.ElementTree as et
from hallgrim.IliasXMLCreator.multi import *
class SingleChoiceQuestion(MultipleChoiceQuestion):
""" is just a subclass of multi with the exception of this method.
Some other minor differences exists but they are handled in the
......
import re
import mistune
import copy
from hallgrim.messages import *
try:
from mistune import Renderer, InlineGrammar, InlineLexer, Markdown
from mistune import Renderer, InlineLexer, Markdown
except ImportError as err:
print("Please install mistune to make use of markdown parsing.")
print("\t pip install mistune")
......@@ -60,8 +60,13 @@ def choice_parser(raw_choices, points):
array of arbitrary size """
lines = raw_choices.strip().split('\n')
parse = [re.match('\[(X| )\] (.*)', line).groups() for line in lines]
final = [(markdown(text), True if mark == 'X' else False, points)
for mark, text in parse]
if type(points) is not list:
points = [points for _ in parse]
elif len(parse) != len(points):
abort("Length of point list does not match number of choices.")
final = [(markdown(text), True if mark == 'X' else False, point)
for (mark, text), point in zip(parse, points)]
return final
markdown = get_custom_markdown()
......@@ -2,7 +2,7 @@ meta = {
'author': 'Jan Maximilian Michal',
'title': 'Sortieren nach Punkten (I1-ID: nipe84411eh0)',
'type': 'multiple choice',
'points': 0.5, # per correct choice
'points': [0.5, 5, 4, 4, 2, 1], # per correct choice
}
task = """
......
......@@ -2,7 +2,7 @@ meta = {
'author': 'Jan Maximilian Michal',
'title': 'Sortieren nach Punkten (I1-ID: nipe84411eh0)',
'type': 'single choice',
'points': 4, # for correct answer
'points': 4, # for correct answer
}
task = """ Hier der Anfang der Datei `punkte.csv`, die Komma-getrennte Angaben
......@@ -30,10 +30,12 @@ choices = """
"""
feedback = """
```
[ ] sort --reverse --k 5 --numeric-sort punkte.csv falsch (u.a.: ungültiges Argument --k)
[ ] sort --r --field-separator=, -k 5 --n punkte.csv falsch (u.a.: bei kurzem Argument -k darf kein = stehen)
[ ] sort -r -t="," -k 5 --n punkte.csv falsch (siehe oben)
[X] sort --reverse -t "," -k 5 -n punkte.csv richtig
[ ] sort -r --field-separator "," -k 4 -numeric punkte.csv falsch (u.a.: Punkte stehen in Spalte 5)
[ ] sort -r --field-separator "," -k 4 punkte.csv falsch (u.a.: keine numerische Sortierung)
"""
\ No newline at end of file
```
"""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment