From c5a8b2c72841ad0b58fb36870624737634778056 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 13 Oct 2018 03:10:03 +0200 Subject: HTMLize instructions and use jinja2 to render them Only fixed tasks for the kpov_2018 class for now. --- kpov_judge/web/kpov_judge/kpov_judge.py | 12 ++++++------ kpov_judge/web/kpov_judge/templates/class_tasks.html | 2 +- kpov_judge/web/kpov_judge/templates/task_greeting.html | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) (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 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///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:
    {% for t in tasks %} -
  • {{t}} +
  • {{t}} {% endfor %}
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 {
-{{instructions}} + +{% include instructions %}

Podrobna navodila (HOWTO) -- cgit v1.2.1