${response.responseJSON.error}
@@ -122,7 +127,7 @@ function error_response(response) {
`);
} else if (response.responseJSON.error instanceof Array) {
for (var i = 0; i < response.responseJSON.error.length; i ++) {
- alert.html(`
+ $alert.html(`
${response.responseJSON.error[i]}
@@ -131,6 +136,8 @@ function error_response(response) {
`);
}
}
+
+ $alert.focus()
}
// Dismiss Cookie Alert
@@ -152,13 +159,12 @@ $('#dismiss-cookie-alert').click(function(event){
})
event.preventDefault();
-
})
-// Script for Resutlt Actions
+// Script for Result Actions
$('.result-action-buttons').click(function(event){
- var _id = $(this).data('_id')
+ var _id = $(this).data('_id');
if ($(this).data('result-action') == 'generate') {
$.ajax({
@@ -192,4 +198,32 @@ $('.result-action-buttons').click(function(event){
},
});
}
+
+ event.preventDefault();
+});
+
+// Script for Deleting Time Adjustment
+$('.adjustment-delete').click(function(event){
+
+ var _id = $(this).data('_id');
+ var location = window.location.href;
+ location.replace('#', '')
+
+ console.log(location)
+
+ console.log(_id)
+ $.ajax({
+ url: location + 'delete-adjustment/',
+ type: 'POST',
+ data: JSON.stringify({'_id': _id}),
+ contentType: 'application/json',
+ success: function(response) {
+ window.location.reload();
+ },
+ error: function(response){
+ error_response(response);
+ },
+ });
+
+ event.preventDefault();
});
\ No newline at end of file
diff --git a/ref-test/admin/templates/admin/components/client-alerts.html b/ref-test/admin/templates/admin/components/client-alerts.html
index fd82166..48a43e2 100644
--- a/ref-test/admin/templates/admin/components/client-alerts.html
+++ b/ref-test/admin/templates/admin/components/client-alerts.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/ref-test/admin/templates/admin/test.html b/ref-test/admin/templates/admin/test.html
new file mode 100644
index 0000000..6636cbc
--- /dev/null
+++ b/ref-test/admin/templates/admin/test.html
@@ -0,0 +1,180 @@
+{% extends "admin/components/base.html" %}
+{% block title %} SKA Referee Test | Edit Exam {% endblock %}
+{% block content %}
+
Edit Exam
+
+
+
+
+
+ -
+
+
Exam Code
+
+
+ {{ '—'.join([test.test_code[:4], test.test_code[4:8], test.test_code[8:]]) }}
+
+
+ -
+
+
Dataset
+
+ {{ test.dataset }}
+
+ -
+
+
Created By
+
+ {{ test.creator }}
+
+ -
+
+
Date Created
+
+ {{ test.date_created.strftime('%d %b %Y') }}
+
+ -
+
+
Expiry Date
+
+ {{ test.start_date.strftime('%d %b %Y') }}
+
+ -
+
+
Expiry Date
+
+ {{ test.expiry_date.strftime('%d %b %Y') }}
+
+ -
+
+
Time Limit
+
+ {% if test.time_limit == None -%}
+ None
+ {% elif test.time_limit == 60 -%}
+ 1 hour
+ {% elif test.time_limit == 90 -%}
+ 1 hour 30 min
+ {% elif test.time_limit == 120 -%}
+ 2 hours
+ {% else -%}
+ {{ test.time_limit }}
+ {% endif %}
+
+
+ {% if 'entries' in test and test.entries|length > 0 %}
+
+ {% endif %}
+ {% if 'time_adjustments' in test and test.time_adjustments|length > 0 %}
+
+
+
+
+
+
+
+
+ User Code
+ |
+
+ Adjustment (Minutes)
+ |
+
+ Delete
+ |
+
+
+
+ {% for entry in test.time_adjustments %}
+
+
+ {{ entry.user_code }}
+ |
+
+ {{ entry.time_adjustment }}
+ |
+
+
+
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+ {% endif %}
+ {% if not test.time_limit == None %}
+
+ {% endif %}
+
+
+
+ {% include "admin/components/client-alerts.html" %}
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/ref-test/admin/templates/admin/tests.html b/ref-test/admin/templates/admin/tests.html
index 3937496..210e4b8 100644
--- a/ref-test/admin/templates/admin/tests.html
+++ b/ref-test/admin/templates/admin/tests.html
@@ -60,17 +60,19 @@
diff --git a/ref-test/admin/views.py b/ref-test/admin/views.py
index bd89f17..86bdf17 100644
--- a/ref-test/admin/views.py
+++ b/ref-test/admin/views.py
@@ -407,10 +407,26 @@ def delete_test():
@views.route('/test/<_id>/', methods=['GET','POST'])
@admin_account_required
@login_required
-def view_test(_id, filter=''):
- test = db.tests.find_one({'_id':_id})
- if not test:
- return abort(404)
+def view_test(_id):
+ from .models.forms import AddTimeAdjustment
+ form = AddTimeAdjustment()
+ test = decrypt_find_one(db.tests, {'_id': _id})
+ if request.method == 'GET':
+ if not test:
+ return abort(404)
+ return render_template('/admin/test.html', test = test, form = form)
+ if request.method == 'POST':
+ if form.validate_on_submit():
+ time = request.form.get('time')
+ return Test(_id=_id).add_time_adjustment(time)
+ return jsonify({'error': form.time.errors }), 400
+
+@views.route('/test/<_id>/delete-adjustment/', methods = ['POST'])
+@admin_account_required
+@login_required
+def delete_adjustment(_id):
+ adjustment_id = request.get_json()['_id']
+ return Test(_id=_id).remove_time_adjustment(adjustment_id)
@views.route('/results/')
@admin_account_required
|