diff --git a/hektor.py b/hektor.py index 3827b7b5cf25ecc86e8b9d603252daa9f95804b5..37130d09379f3331e25288830cd5c27c83b75129 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 bc963dc0e398bfa001d4652c471033e2b1ad6f39..65c45f239fe1ddf4433e57ea760b7c12e2207be3 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