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