From eeb0f7db3c28e900d73f32851f5fd7a183fc8d02 Mon Sep 17 00:00:00 2001 From: janmax <j.michal@stud.uni-goettingen.de> Date: Sun, 4 Feb 2018 01:36:03 +0100 Subject: [PATCH] Decoded and pretty-printed code --- hektor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hektor.py b/hektor.py index 67e848c..63d8a29 100644 --- a/hektor.py +++ b/hektor.py @@ -1,4 +1,5 @@ import argparse +import base64 import json import re import sys @@ -15,7 +16,8 @@ tasks_path = ('./assessment/section') users = './tst_active/row' solutions = './tst_solutions/row[@question_fi="%s"]' -lecturer_xpath = './MetaData/Lifecycle/Contribute[@Role="Author"]/Entity/text()' +lecturer_xpath = './MetaData/Lifecycle/Contribute[@Role="Author"]/Entity/text()' + def eat_qti(tree, only_of_type=('assSourceCode',), **kwargs): tasks = tree.xpath(tasks_path)[0] @@ -39,8 +41,12 @@ def eat_users(results_tree): for row in results_tree.xpath(users)} +def convert_code(text): + return base64.b64decode(text).decode('utf-8').split('\n') + + def eat_solutions(results_tree, task_id): - return {row.attrib['active_fi']: row.attrib['value1'] + return {row.attrib['active_fi']: convert_code(row.attrib['value1']) for row in results_tree.xpath(solutions % task_id)} -- GitLab