diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-10-13 03:10:03 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-10-13 03:17:06 +0200 |
commit | c5a8b2c72841ad0b58fb36870624737634778056 (patch) | |
tree | 01259a4a3338777031ae730366ea0193f86db222 /kpov_judge/web | |
parent | 1cbc2f75ac1adf5ee70971052c819cdca1a0948c (diff) |
HTMLize instructions and use jinja2 to render them
Only fixed tasks for the kpov_2018 class for now.
Diffstat (limited to 'kpov_judge/web')
-rwxr-xr-x | kpov_judge/web/kpov_judge/kpov_judge.py | 12 | ||||
-rw-r--r-- | kpov_judge/web/kpov_judge/templates/class_tasks.html | 2 | ||||
-rw-r--r-- | kpov_judge/web/kpov_judge/templates/task_greeting.html | 3 |
3 files changed, 9 insertions, 8 deletions
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index 5aa0606..4dfed7b 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -235,10 +235,6 @@ def task_greeting(class_id, task_id, lang): for k, v in meta.items(): if v.get('public', False): public_params[k] = params.get(k, "???") - # instructions = instructions.format(**public_params).decode('utf8') - instructions = instructions.format(**public_params) - - # instructions = instructions.format(**public_params).encode('utf8') 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})) @@ -258,11 +254,15 @@ def task_greeting(class_id, task_id, lang): openstackCreated = False 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, + task_id=task_id, computers=computer_list, backing_images=sorted(backing_images), - lang=lang, + lang='sl' if lang == 'si' else lang, # TODO s/si/sl in all tasks (and maybe elsewhere) openstack=openstackCreated, - instructions=instructions) + instructions=jinja2.Template(instructions), + **public_params, + ) @app.route('/tasks/<class_id>/<task_id>/params.json', methods=['GET', 'POST']) diff --git a/kpov_judge/web/kpov_judge/templates/class_tasks.html b/kpov_judge/web/kpov_judge/templates/class_tasks.html index 5a29ae7..050874b 100644 --- a/kpov_judge/web/kpov_judge/templates/class_tasks.html +++ b/kpov_judge/web/kpov_judge/templates/class_tasks.html @@ -11,6 +11,6 @@ Trenutno so na voljo naloge: <ul> {% for t in tasks %} -<li><a href="{{url_for('task_lang_redirect', class_id=clas.class_id, task_id=t)}}">{{t}}</a> + <li><a href="{{url_for('task_lang_redirect', class_id=clas.class_id, task_id=t)}}">{{t}}</a> {% endfor %} </ul> diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html index 20da231..5a59fe0 100644 --- a/kpov_judge/web/kpov_judge/templates/task_greeting.html +++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html @@ -33,7 +33,8 @@ section > ul { <section> <a href="setup.png"><img src="setup.png" class="setup"></a> -{{instructions}} + +{% include instructions %} <p> <a href="howto/">Podrobna navodila (HOWTO)</a> |