From e17416d594642c5e9eaf905f37cef10021071ab1 Mon Sep 17 00:00:00 2001
From: Timotej Lazar
Date: Sat, 13 Oct 2018 19:15:56 +0200
Subject: Show results and parameters on task page
---
kpov_judge/web/kpov_judge/kpov_judge.py | 26 ++++++++++++++----
kpov_judge/web/kpov_judge/static/style.css | 17 ++++++++++++
.../web/kpov_judge/templates/task_greeting.html | 31 +++++++++++++++-------
3 files changed, 59 insertions(+), 15 deletions(-)
(limited to 'kpov_judge')
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index 2febf9a..c0bf885 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -13,7 +13,7 @@ import kpov_util
import pymongo
import flask
from flask import Flask, g, session, redirect, url_for, abort, render_template, flash, app, request, Response
-from flask.ext.babel import Babel, gettext, ngettext
+from flask.ext.babel import Babel, gettext, ngettext, format_datetime, _
import jinja2
app = Flask(__name__)
@@ -245,10 +245,14 @@ def task_greeting(class_id, task_id, lang):
instr_ok = False
if instr_ok:
try:
- public_params = {}
+ public_params = []
for k, v in meta.items():
if v.get('public', False):
- public_params[k] = params.get(k, "???")
+ public_params += [{
+ 'name': k,
+ 'value': params.get(k),
+ 'description': v.get('descriptions', {}).get(lang)
+ }]
except Exception as e:
instructions = str(e)
computer_list = list(db.student_computers.find({'class_id': class_id, 'task_id': task_id, 'student_id': student_id}))
@@ -266,6 +270,17 @@ def task_greeting(class_id, task_id, lang):
openstackCreated = True
else:
openstackCreated = False
+
+ try:
+ result = db.results.find_one(
+ {'$query': {'class_id': class_id, 'task_id': task_id, 'student_id': student_id},
+ '$orderby': collections.OrderedDict([('result', -1), ('time', 1)])},
+ {'result': 1, 'status': 1, 'hints': 1, 'time': True, '_id': 0})
+ result['time'] = format_datetime(result['time'])
+ print(result)
+ except Exception:
+ result = None
+
return render_template('task_greeting.html',
disk_base_url='/'.join([app.config['STUDENT_DISK_URL'], student_id, class_id, task_id, '']),
class_id=class_id,
@@ -275,8 +290,9 @@ def task_greeting(class_id, task_id, lang):
lang='sl' if lang == 'si' else lang, # TODO s/si/sl in all tasks (and maybe elsewhere)
openstack=openstackCreated,
instructions=jinja2.Template(instructions),
- **public_params,
- )
+ params=public_params,
+ result=result,
+ **{p['name']: p['value'] for p in public_params})
@app.route('/tasks///params.json', methods=['GET', 'POST'])
diff --git a/kpov_judge/web/kpov_judge/static/style.css b/kpov_judge/web/kpov_judge/static/style.css
index ade0909..69ac87c 100644
--- a/kpov_judge/web/kpov_judge/static/style.css
+++ b/kpov_judge/web/kpov_judge/static/style.css
@@ -8,6 +8,22 @@ body {
padding: 1em 2em;
}
+code {
+ background-color: #d6d6d6;
+ font-size: 1.2em;
+ padding: 0 0.25em;
+}
+
+dl {
+ margin-top: 0.5em;
+}
+dt {
+ margin-top: 0.5em;
+}
+dd {
+ margin-left: 1em;
+}
+
h1 {
margin-bottom: 0.5em;
}
@@ -22,6 +38,7 @@ p {
pre {
margin-left: 1em;
+ overflow: auto;
}
.tooltip { /* hide and position tooltip */
diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html
index 086d6b1..1825726 100644
--- a/kpov_judge/web/kpov_judge/templates/task_greeting.html
+++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html
@@ -53,7 +53,7 @@ section > ul {
{% if 'disk_urls' in c %}
{% else %}
@@ -70,7 +70,7 @@ section > ul {
{% for b in backing_images %}
- - {{b}}
+ - {{b}}
{% endfor %}
{% endif %}
@@ -78,16 +78,27 @@ section > ul {
-{{ _('Rezultati') }}
+{{ _('Rezultat') }}
-{{ _('Ogledate si lahko:') }}
+{% if result is none %}
+{{ _('Naloga nima še nobenega poskusa.') }}
+{% elif result['result'] == 10 %}
+{{ _('Naloga je uspešno opravljena dne %(time)s.', time=result['time']) }}
+{% else %}
+{{ _('Naloga še ni opravljena, najvišji rezultat je %(score)s.', score=result['result']) }}
+{% endif %}
-
-
+
+{{ _('Program za preverjanje.') }}
+
+
{{ _('Parametri') }}
+
+{% for p in params if p['value'] %}
+ - {{ p['name'] }}{% if p['description'] %} … {{ p['description'] }}{% endif %}
+ {{ p['value'] }}
+{% endfor %}
+
+
{#
--
cgit v1.2.1