diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-14 15:37:41 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-14 15:37:41 +0000 |
commit | 4eea296e6e63cb4671a7cc19f00cb85319899015 (patch) | |
tree | 0a9f50ab76a51fc55a9cd00697bab75a1a87224a | |
parent | c0999c1cb5041cfa1295e79e7e22415383839b54 (diff) |
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
-rwxr-xr-x | kpov_judge/add_task.py | 6 | ||||
-rw-r--r-- | kpov_judge/tasks/set_motd/howtos/images/first.png (renamed from kpov_judge/tasks/set_motd/howtos/images/first.PNG) | bin | 3793 -> 3793 bytes | |||
-rw-r--r-- | kpov_judge/tasks/set_motd/howtos/images/second.png (renamed from kpov_judge/tasks/set_motd/howtos/images/second.PNG) | bin | 25542 -> 25542 bytes | |||
-rw-r--r-- | kpov_judge/tasks/set_motd/howtos/si/index.html | 96 | ||||
-rw-r--r-- | kpov_judge/tasks/set_motd/task.py | 8 | ||||
-rwxr-xr-x | kpov_judge/web/kpov_judge/kpov_judge.py | 14 | ||||
-rw-r--r-- | kpov_judge/web/kpov_judge/templates/task_greeting.html | 3 |
7 files changed, 70 insertions, 57 deletions
diff --git a/kpov_judge/add_task.py b/kpov_judge/add_task.py index ea7aec6..bf2588c 100755 --- a/kpov_judge/add_task.py +++ b/kpov_judge/add_task.py @@ -8,7 +8,6 @@ import sys import inspect import kpov_random_helpers import settings -import guestfs import glob import os @@ -89,9 +88,10 @@ if __name__ == '__main__': if howto_lang not in {'images'}: with open(os.path.join(howto_dir, 'index.html')) as f: db.howtos.update({'task_id': task_id, 'lang': howto_lang}, - {'$set': {'text': f.read()}}) + {'$set': {'text': f.read()}}, upsert=True) else: for img in glob.glob(os.path.join(howto_dir, '*')): + fname = os.path.basename(img) with open(img) as f: db.howto_images.update({'task_id': task_id, 'fname': fname}, - {'$set': {'data': Binary(f.read())}}) + {'$set': {'data': Binary(f.read())}}, upsert=True) diff --git a/kpov_judge/tasks/set_motd/howtos/images/first.PNG b/kpov_judge/tasks/set_motd/howtos/images/first.png Binary files differindex d3797d7..d3797d7 100644 --- a/kpov_judge/tasks/set_motd/howtos/images/first.PNG +++ b/kpov_judge/tasks/set_motd/howtos/images/first.png diff --git a/kpov_judge/tasks/set_motd/howtos/images/second.PNG b/kpov_judge/tasks/set_motd/howtos/images/second.png Binary files differindex 61bea73..61bea73 100644 --- a/kpov_judge/tasks/set_motd/howtos/images/second.PNG +++ b/kpov_judge/tasks/set_motd/howtos/images/second.png diff --git a/kpov_judge/tasks/set_motd/howtos/si/index.html b/kpov_judge/tasks/set_motd/howtos/si/index.html index 8c6a9a0..bbead62 100644 --- a/kpov_judge/tasks/set_motd/howtos/si/index.html +++ b/kpov_judge/tasks/set_motd/howtos/si/index.html @@ -1,49 +1,49 @@ -<!--
-Ustvari dva navidezna računalnika - imenujmo ju Test in Student. Za računalnik Test uporabite
-sliko diska, poimenovano Test. Na računalniku Test dobite kratek niz. Poskrbite, da se bo ta
-kratki niz pojavil v sporočilu, ki se ob prijavi izpiše na računalniku Student. Temu sporočilu v
-angleščini rečemo "message of the day" - MOTD.
-
-Poskrbite, da se bo ob prijavi uporabnika (v Message Of The Day, MOTD) prek ssh izpisal nek niz.
-Računalnik nastavite tako, da bo dostopen s testnega računalnika (Test).
-
-Uporabniško ime in niz dobite kot parametre ob zagonu run_test.py. Pri nizu pazite, saj utegne biti dovolj dolg, da brez premikanja kurzorja ne bo takoj viden.
-
-IP navideznega računalnika ter geslo nastavite sami.
-
-Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike uporabnisko_ime@ime_racunalnika:~$ .
-Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v navodilih.
-
-Create two virtual machines - named Test and Student. For the 'Test' use disc image named Test.
-You receive short string on machine 'Test'. Make sure that this string appears in the message which is displayed
-after you login to machine 'Student'. This is so called 'message of the day'MOTD.
-
-Make sure that when the user logins via ssh some string is displayed. Set the machine, so that you can reach it from test computer (Test)
-
-You get username and string as parameters when you run run_test.py. Pay attention to the string length, it might not be visible
-right away without moving the cursor.
-
-Set up IP and password of virtual machine yourself.
-
-Grading system expects, that at the end of login, a command line similar to uporabnisko_ime@ime_racunalnika:~$ appears.
-Make sure that this line shows up after the string you got in the instructions.
--->
-
-<h2>Naloga na hitro</h2>
-<p></p>
-
-<h2>Navodila</h2>
-<ul>
- <li>Ustvari dva navidezna računalnika - imenujmo ju Test in Student. Za računalnik Test uporabite sliko diska, poimenovano Test. Na računalniku Test dobite kratek niz. Poskrbite, da se bo ta kratki niz pojavil v sporočilu, ki se ob prijavi izpiše na računalniku Student. Temu sporočilu v angleščini rečemo "message of the day" - MOTD.</li>
- <li>Poskrbite, da se bo ob prijavi uporabnika (v Message Of The Day, MOTD) prek ssh izpisal nek niz. Računalnik nastavite tako, da bo dostopen s testnega računalnika (Test).</li>
- <li>Uporabniško ime in niz dobite kot parametre ob zagonu run_test.py. Pri nizu pazite, saj utegne biti dovolj dolg, da brez premikanja kurzorja ne bo takoj viden.</li>
- <li>IP navideznega računalnika ter geslo nastavite sami.</li>
- <li>Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike uporabnisko_ime@ime_racunalnika:~$ . Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v navodilih.</li>
-</ul>
-
-<h2>How To</h2>
-<ol>
- <li>Prijavi se v računalnik <br /> <img src="../images/first.png"></li>
- <li>S poljubnim urejevalnikom besedila odpri <b>/etc/motd</b> <br /> <img src="../images/second.png"></li>
- <li>Nastavite MOTD na vaš dodeljen String</li>
+<!-- +Ustvari dva navidezna računalnika - imenujmo ju Test in Student. Za računalnik Test uporabite +sliko diska, poimenovano Test. Na računalniku Test dobite kratek niz. Poskrbite, da se bo ta +kratki niz pojavil v sporočilu, ki se ob prijavi izpiše na računalniku Student. Temu sporočilu v +angleščini rečemo "message of the day" - MOTD. + +Poskrbite, da se bo ob prijavi uporabnika (v Message Of The Day, MOTD) prek ssh izpisal nek niz. +Računalnik nastavite tako, da bo dostopen s testnega računalnika (Test). + +Uporabniško ime in niz dobite kot parametre ob zagonu run_test.py. Pri nizu pazite, saj utegne biti dovolj dolg, da brez premikanja kurzorja ne bo takoj viden. + +IP navideznega računalnika ter geslo nastavite sami. + +Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike uporabnisko_ime@ime_racunalnika:~$ . +Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v navodilih. + +Create two virtual machines - named Test and Student. For the 'Test' use disc image named Test. +You receive short string on machine 'Test'. Make sure that this string appears in the message which is displayed +after you login to machine 'Student'. This is so called 'message of the day'MOTD. + +Make sure that when the user logins via ssh some string is displayed. Set the machine, so that you can reach it from test computer (Test) + +You get username and string as parameters when you run run_test.py. Pay attention to the string length, it might not be visible +right away without moving the cursor. + +Set up IP and password of virtual machine yourself. + +Grading system expects, that at the end of login, a command line similar to uporabnisko_ime@ime_racunalnika:~$ appears. +Make sure that this line shows up after the string you got in the instructions. +--> + +<h2>Naloga na hitro</h2> +<p></p> + +<h2>Navodila</h2> +<ul> + <li>Ustvari dva navidezna računalnika - imenujmo ju Test in Student. Za računalnik Test uporabite sliko diska, poimenovano Test. Na računalniku Test dobite kratek niz. Poskrbite, da se bo ta kratki niz pojavil v sporočilu, ki se ob prijavi izpiše na računalniku Student. Temu sporočilu v angleščini rečemo "message of the day" - MOTD.</li> + <li>Poskrbite, da se bo ob prijavi uporabnika (v Message Of The Day, MOTD) prek ssh izpisal nek niz. Računalnik nastavite tako, da bo dostopen s testnega računalnika (Test).</li> + <li>Uporabniško ime in niz dobite kot parametre ob zagonu run_test.py. Pri nizu pazite, saj utegne biti dovolj dolg, da brez premikanja kurzorja ne bo takoj viden.</li> + <li>IP navideznega računalnika ter geslo nastavite sami.</li> + <li>Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike uporabnisko_ime@ime_racunalnika:~$ . Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v navodilih.</li> +</ul> + +<h2>How To</h2> +<ol> + <li>Prijavi se v računalnik <br /> <img src="../images/first.png"></li> + <li>S poljubnim urejevalnikom besedila odpri <b>/etc/motd</b> <br /> <img src="../images/second.png"></li> + <li>Nastavite MOTD na vaš dodeljen String</li> </ol>
\ No newline at end of file diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py index 99d9ec5..b60830c 100644 --- a/kpov_judge/tasks/set_motd/task.py +++ b/kpov_judge/tasks/set_motd/task.py @@ -1,5 +1,3 @@ - - #!/usr/bin/env python # -*- coding: utf-8 -*- @@ -23,8 +21,8 @@ Uporabniško ime in niz dobite kot parametre ob zagonu run_test.py. Pri nizu paz IP navideznega računalnika ter geslo nastavite sami. Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike uporabnisko_ime@ime_racunalnika:~$ . Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v navodilih. - - + """, + 'en':u""" Create two virtual machines - named Test and Student. For the 'Test' use disc image named Test. You receive short string on machine 'Test'. Make sure that this string appears in the message which is displayed after you login to machine 'Student'. This is so called 'message of the day'MOTD. Make sure that when the user logins via ssh some string is displayed. Set the machine, so that you can reach it from test computer (Test) @@ -66,7 +64,7 @@ params_meta = { 'peer_ip': {'descriptions': {'si': u'IP računalnika'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False}, 'peer_user': {'descriptions': {'si': 'ime uporabnika'}, 'w': False, 'public': True, 'type': 'username', 'generated': True}, 'peer_passwd': {'descriptions': {'si': 'geslo uporabnika'}, 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False}, - 'niz': {'w': False, 'public': True, 'type': 'short_text', 'generated': True}, + 'niz': {'descriptions':{'si': u'niz, ki naj se v motd pokaže'}, 'w': False, 'public': True, 'type': 'short_text', 'generated': True}, } def task(peer_ip, peer_user, peer_passwd, niz): 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/<task_id>/<lang>/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/<task_id>/<lang>/images/<fname>', 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/<task_id>/<lang>/', 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}} </pre> <p> +<p> +<a href='howto/'>Podrobna navodila (HOWTO)</a> +</p> <h2>Računalniki v vaji</h2> {% for c in computers %} <h3>{{c['name']}}</h3> |