From 2038965dcb047e7154373b5da31e5d537892eeaa Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Tue, 7 Dec 2021 15:52:58 +0000 Subject: [PATCH] Bug fix and data persistence --- docker-compose.yml | 1 + ref-test/admin/templates/admin/result-detail.html | 14 ++++++++------ ref-test/quiz/views.py | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b0db7ae..6e9cb49 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,6 +28,7 @@ services: - 5000 volumes: - ./.security:/ref-test/.security + - ./ref-test/data:/ref-test/data restart: unless-stopped networks: - frontend diff --git a/ref-test/admin/templates/admin/result-detail.html b/ref-test/admin/templates/admin/result-detail.html index 88b99c3..c1f548f 100644 --- a/ref-test/admin/templates/admin/result-detail.html +++ b/ref-test/admin/templates/admin/result-detail.html @@ -44,12 +44,14 @@ {{ entry.user_code }} {% endif %} -
  • -
    -
    Start Time
    -
    - {{ entry.start_time.strftime('%d %b %Y %H:%M:%S') }} -
  • + {% if 'start_time' in entry %} +
  • +
    +
    Start Time
    +
    + {{ entry.start_time.strftime('%d %b %Y %H:%M:%S') }} +
  • + {% endif %}
  • Submission Time
    diff --git a/ref-test/quiz/views.py b/ref-test/quiz/views.py index 5f2e129..cbd3080 100644 --- a/ref-test/quiz/views.py +++ b/ref-test/quiz/views.py @@ -143,9 +143,10 @@ def submit_quiz(): if not entry: return jsonify('Unrecognised ID', 'error'), 400 status = 'submitted' - if entry['end_time']: - if datetime.utcnow() > entry['end_time'] + timedelta(minutes=2): - status = 'late' + if 'end_time' in entry: + if entry['end_time']: + if datetime.utcnow() > entry['end_time'] + timedelta(minutes=2): + status = 'late' test_code = entry['test_code'] test = db.tests.find_one({'test_code' : test_code}) dataset = test['dataset']