diff options
Diffstat (limited to 'kpov_judge')
-rwxr-xr-x | kpov_judge/web/kpov_judge/kpov_judge.py | 26 | ||||
-rw-r--r-- | kpov_judge/web/kpov_judge/static/style.css | 17 | ||||
-rw-r--r-- | kpov_judge/web/kpov_judge/templates/task_greeting.html | 31 |
3 files changed, 59 insertions, 15 deletions
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/<class_id>/<task_id>/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 %} <ul> {% for u in c['disk_urls'] %} - <li><a href={{disk_base_url+u['file']}}>{{u['name']}}</a> + <li><a href="{{disk_base_url+u['file']}}">{{u['name']}}</a> {% endfor %} </ul> {% else %} @@ -70,7 +70,7 @@ section > ul { <ul> {% for b in backing_images %} - <li><a href={{disk_base_url+b}}>{{b}}</a></li> + <li><a href="{{disk_base_url+b}}">{{b}}</a></li> {% endfor %} </ul> {% endif %} @@ -78,16 +78,27 @@ section > ul { </section> <section> -<h1>{{ _('Rezultati') }}</h1> +<h1>{{ _('Rezultat') }}</h1> <p> -{{ _('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 %} -<ul> -<li><a href='results.html'>{{ _('rezultate') }}</a> (<a href='../results.json'>json</a>)</li> -<li><a href='params.html'>{{ _('parametre') }}</a> (<a href='../params.json'>json</a>, <a href='../params_meta.json'>{{ _('opisi parametrov') }}</a>)</li> -<li><a href='../task.html'>{{ _('preverjalni program') }}</a> (<a href='../task.py'>source</a>)</li> -</ul> -</p> +<p> +<a href="../task.html">{{ _('Program za preverjanje.') }}</a> + +<h1>{{ _('Parametri') }}</h1> +<dl> +{% for p in params if p['value'] %} + <dt><em>{{ p['name'] }}</em>{% if p['description'] %} … <small>{{ p['description'] }}</small>{% endif %}</dt> + <dd><code>{{ p['value'] }}</code></dd> +{% endfor %} +</dl> +</section> {# <p> |