From 6c50be49c62e5c8cdbfd34478e2a704b2682f1b1 Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Thu, 11 Aug 2022 10:23:40 +0100 Subject: [PATCH] Bugfix: default time for exam creation --- ref-test/app/admin/views.py | 4 +++- ref-test/app/forms/admin.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ref-test/app/admin/views.py b/ref-test/app/admin/views.py index f35b028..e1d655e 100644 --- a/ref-test/app/admin/views.py +++ b/ref-test/app/admin/views.py @@ -9,7 +9,7 @@ from flask import abort, Blueprint, jsonify, render_template, redirect, request, from flask.helpers import flash, url_for from flask_login import current_user, login_required -from datetime import date, datetime +from datetime import date, datetime, timedelta from json import loads from os import path import secrets @@ -258,6 +258,8 @@ def _tests(filter:str=None): if filter not in ['create','active','scheduled','expired','all']: return redirect(url_for('admin._tests', filter='active')) if filter == 'create': form = CreateTest() + form.start_date = datetime.now() + form.expiry_date = date.today() + timedelta(days=1) form.time_limit.choices = get_time_options() form.dataset.choices = get_dataset_choices() form.time_limit.default='none' diff --git a/ref-test/app/forms/admin.py b/ref-test/app/forms/admin.py index 19db3d3..ff85b8e 100644 --- a/ref-test/app/forms/admin.py +++ b/ref-test/app/forms/admin.py @@ -51,8 +51,8 @@ class UpdateAccount(FlaskForm): password_reenter = PasswordField('Re-Enter New Password', validators=[EqualTo('password', message='Passwords do not match.')]) class CreateTest(FlaskForm): - start_date = DateTimeLocalField('Start Date', format='%Y-%m-%dT%H:%M', validators=[InputRequired()], default = datetime.now() ) - expiry_date = DateTimeLocalField('Expiry Date', format='%Y-%m-%dT%H:%M', validators=[InputRequired()], default = date.today() + timedelta(days=1) ) + start_date = DateTimeLocalField('Start Date', format='%Y-%m-%dT%H:%M', validators=[InputRequired()] ) + expiry_date = DateTimeLocalField('Expiry Date', format='%Y-%m-%dT%H:%M', validators=[InputRequired()] ) time_limit = SelectField('Time Limit') dataset = SelectField('Question Dataset')