From 3b6eac530c8f3164b6e943fac9645ca09c454d10 Mon Sep 17 00:00:00 2001
From: janmax <j.michal@stud.uni-goettingen.de>
Date: Thu, 15 Mar 2018 18:48:04 +0100
Subject: [PATCH] Readable code now disabled by default.

---
 hektor.py  | 15 +++++++++++++--
 lib/qti.py |  6 +++---
 setup.py   |  2 +-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/hektor.py b/hektor.py
index 3827b7b..37130d0 100644
--- a/hektor.py
+++ b/hektor.py
@@ -97,7 +97,6 @@ def setup_argparse():
     parser.add_argument(
         '-r', '--readable-code',
         action='store_true',
-        default=True,
         help='make student code readable by inserting artificial line breaks')
 
     args = parser.parse_args()
@@ -166,10 +165,22 @@ def do_verify(structured_data: Dict[str, Any]) -> Dict[str, Any]:
         assert 'students' in structured_data, 'No students found'
         assert 'tasks' in structured_data, 'No tasks found'
 
+    def assert_task(task):
+        assert 'type' in task, 'Task has no type'
+        assert 'title' in task, 'Task must have a title'
+
     try:
         base_assert()
         students = structured_data['students']
-        number_of_submissions = len(structured_data['tasks'])
+        tasks = structured_data['tasks']
+        number_of_submissions = len(tasks)
+
+        for task in tasks:
+            try:
+                assert_task(task)
+            except AssertionError as err:
+                raise err
+
         for student in students:
 
             try:
diff --git a/lib/qti.py b/lib/qti.py
index bc963dc..65c45f2 100644
--- a/lib/qti.py
+++ b/lib/qti.py
@@ -69,10 +69,10 @@ def process_results(tree, qti=(), **kwargs):
     id2user = {user['active_id']: user for user in users}
     for user in users:
         user['submissions'] = []
-    for question in questions:
-        solutions = process_solutions(tree, question)
+    for question_key, question in questions.items():
+        solutions = process_solutions(tree, question_key)
         for user_id, solution in solutions.items():
-            id2user[user_id]['submissions'].append({'type': question,
+            id2user[user_id]['submissions'].append({'type': question['title'],
                                                     'code': solution,
                                                     'tests': {}})
     return users
diff --git a/setup.py b/setup.py
index 8fdbb95..52bee20 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup
 
 setup(
     name='hektor',
-    version='0.3.1',
+    version='0.3.2',
     description='A QTI-XML/XLS to JSON converter for humans',
     author='Jan Maximilian Michal',
     author_email='mail@janmax.org',
-- 
GitLab