Skip to content
Snippets Groups Projects
Commit 421a5078 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Fixed importer

parent 34012314
No related branches found
No related tags found
1 merge request!161Fixed importer
Pipeline #93815 passed
import json import json
import os import os
import readline import readline
import util
from util.messages import warn from util.messages import warn
from core.models import ExamType, Feedback, Submission, SubmissionType, Test from core.models import ExamType, Feedback, Submission, SubmissionType, Test
...@@ -35,15 +34,11 @@ valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} ...@@ -35,15 +34,11 @@ valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False}
ORIGIN_ORDER = { ORIGIN_ORDER = {
Feedback.WAS_EMPTY, Feedback.WAS_EMPTY,
Feedback.DID_NOT_COMPILE, Feedback.DID_NOT_COMPILE,
Feedback.COULD_NOT_LINK,
Feedback.FAILED_UNIT_TESTS,
} }
TEST_ORDER = ( TEST_ORDER = (
util.processing.EmptyTest.__name__, 'EmptyTest',
util.processing.CompileTest.__name__, 'CompileTest',
util.processing.LinkTest.__name__,
util.processing.UnitTestTest.__name__,
) )
FEEDBACK_MAPPER = dict(zip(TEST_ORDER, ORIGIN_ORDER)) FEEDBACK_MAPPER = dict(zip(TEST_ORDER, ORIGIN_ORDER))
...@@ -129,7 +124,7 @@ def load_hektor_json(): ...@@ -129,7 +124,7 @@ def load_hektor_json():
exam, _ = ExamType.objects.get_or_create(**exam_data['module']) exam, _ = ExamType.objects.get_or_create(**exam_data['module'])
for submission_type in exam['submission_types']: for submission_type in exam_data['submission_types']:
SubmissionType.objects.get_or_create(**submission_type) SubmissionType.objects.get_or_create(**submission_type)
for student in exam_data['students']: for student in exam_data['students']:
...@@ -183,12 +178,9 @@ def add_tests(submission_obj, tests): ...@@ -183,12 +178,9 @@ def add_tests(submission_obj, tests):
def add_feedback_if_test_recommends_it(test_obj): def add_feedback_if_test_recommends_it(test_obj):
available_tests = util.processing.Test.available_tests() # TODO rework this brittle code
if (test_obj.label == 'EMPTY' or test_obj.label == 'COMPILATION_FAILED') \
if test_obj.label == available_tests[test_obj.name].label_failure \ and not hasattr(test_obj.submission, 'feedback'):
and not hasattr(test_obj.submission, 'feedback') \
and (test_obj.name == util.processing.EmptyTest.__name__ or
test_obj.name == util.processing.CompileTest.__name__):
return Feedback.objects.update_or_create( return Feedback.objects.update_or_create(
of_submission=test_obj.submission, of_submission=test_obj.submission,
defaults={ defaults={
......
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