From 4eea296e6e63cb4671a7cc19f00cb85319899015 Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Wed, 14 Jan 2015 15:37:41 +0000 Subject: Adding howtos now works git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@190 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/web/kpov_judge/kpov_judge.py | 14 +++++++++++++- kpov_judge/web/kpov_judge/templates/task_greeting.html | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'kpov_judge/web') diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index 6b1f144..0499b11 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -8,6 +8,7 @@ import random import settings import datetime import kpov_random_helpers +import traceback app = Flask(__name__) app.config.from_object(settings) @@ -169,7 +170,8 @@ def get_params(task_id, student_id, db): {'$set': computer}, upsert=True) except Exception, e: meta = {'crash':{'public': True}} - params = {'crash': "Parameter creator crashed or missing:" + str(e)} + params = {'crash': "Parameter creator crashed or missing:\n{}".format( + traceback.format_exc())} else: params = params['params'] return params, meta @@ -179,6 +181,16 @@ def task_lang_redirect(task_id): return redirect(url_for('task_greeting', task_id = task_id, lang=app.config['DEFAULT_LANG'])) +@app.route('/tasks///howto/', methods = ['GET']) +def task_howto(task_id, lang): + db = g.db + return db.howtos.find({'task_id': task_id, 'lang':lang})[0].get('text', '') + +@app.route('/tasks///images/', methods = ['GET']) +def task_image(task_id, lang, fname): + db = g.db + return db.howto_images.find({'task_id': task_id, 'fname':fname})[0].get('data', '') + @app.route('/tasks///', methods = ['GET']) def task_greeting(task_id, lang): student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody') diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html index bceb18c..b1ede6c 100644 --- a/kpov_judge/web/kpov_judge/templates/task_greeting.html +++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html @@ -8,6 +8,9 @@ {{instructions}}

+

+Podrobna navodila (HOWTO) +

Računalniki v vaji

{% for c in computers %}

{{c['name']}}

-- cgit v1.2.1