summaryrefslogtreecommitdiff
path: root/kpov_judge/web
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-11 17:22:30 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-11 17:22:30 +0200
commitfb9fc7185ad66ed7a2cc7549ba7d65ad932d0d5d (patch)
treef067f1849ed1b7802c1d84b0eedee1dc9b08a049 /kpov_judge/web
parent03c2305e4acafb159c732612e3631e2553ff5ff1 (diff)
Use backing files in created disk images
Diffstat (limited to 'kpov_judge/web')
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py14
-rw-r--r--kpov_judge/web/kpov_judge/templates/task_greeting.html27
2 files changed, 33 insertions, 8 deletions
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index b832007..2231db0 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -250,7 +250,11 @@ def task_greeting(class_id, task_id, lang):
# instructions = instructions.format(**public_params).encode('utf8')
except Exception as e:
instructions = str(e)
- computer_list = db.student_computers.find({'class_id': class_id, 'task_id': task_id, 'student_id': student_id})
+ computer_list = list(db.student_computers.find({'class_id': class_id, 'task_id': task_id, 'student_id': student_id}))
+ backing_images = set()
+ for computer in computer_list:
+ for disk_url in computer.get('disk_urls', []):
+ backing_images |= set(disk_url['backing'])
if request.args.get('narediStack', 'false') == 'true':
#db.student_tasks.update({'task_id': task_id, 'student_id': student_id}, {'$set': {'create_openstack': True}}, upsert = True)
openstackCreated = False # Spremeni na True, ko odkomentiras zgornjo vrstico.
@@ -261,7 +265,13 @@ def task_greeting(class_id, task_id, lang):
openstackCreated = True
else:
openstackCreated = False
- return render_template('task_greeting.html', computers=computer_list, lang=lang, openstack=openstackCreated, instructions=instructions)
+ return render_template('task_greeting.html',
+ disk_base_url='/'.join([app.config['STUDENT_DISK_URL'], student_id, class_id, task_id, '']),
+ computers=computer_list,
+ backing_images=sorted(backing_images),
+ lang=lang,
+ openstack=openstackCreated,
+ instructions=instructions)
@app.route('/tasks/<class_id>/<task_id>/params.json', methods=['GET', 'POST'])
diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html
index 188145c..422f14b 100644
--- a/kpov_judge/web/kpov_judge/templates/task_greeting.html
+++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html
@@ -2,9 +2,7 @@
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
-<h1>
-{{task_id}}
-</h1>
+<h1>{{task_id}}</h1>
<h2>Navodila</h2>
<pre>
{{instructions}}
@@ -14,24 +12,40 @@
<a href='howto/'>Podrobna navodila (HOWTO)</a>
</p>
+<section class="images">
<h2>Računalniki v vaji</h2>
+<section>
{% for c in computers %}
<h3>{{c['name']}}</h3>
{% if 'disk_urls' in c %}
<ul>
{% for u in c['disk_urls'] %}
- <li><a href={{u['url']}}>{{u['name']}}</a></li>
+ <li><a href={{disk_base_url+u['file']}}>{{u['name']}}</a></li>
{% endfor %}
</ul>
{% else %}
Slike navideznih diskov so v izdelavi in bodo kmalu na voljo.
{% endif %}
{% endfor %}
-</p>
+
<p>
-<img src="setup.png"/>
+<img src="setup.png">
</p>
+</section>
+
+<section>
+{% if backing_images %}
+<h3>Osnovne slike</h3>
+<ul>
+{% for b in backing_images %}
+ <li><a href={{disk_base_url+b}}>{{b}}</a></li>
+{% endfor %}
+</ul>
+{% endif %}
+</section>
+</section>
+
<p>
Lahko si ogledate surove:
<ul>
@@ -40,6 +54,7 @@ Lahko si ogledate surove:
<li><a href='../task.html'>preverjalni program</a> (<a href='../task.py'>source</a>)</li>
</ul>
</p>
+
<p>
{% if openstack %}
Openstack projekt za to vajo je že ustvarjen ali v izdelavi (funkcionalnost še ne deluje).