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/add_task.py | 6 +- kpov_judge/tasks/set_motd/howtos/images/first.PNG | Bin 3793 -> 0 bytes kpov_judge/tasks/set_motd/howtos/images/first.png | Bin 0 -> 3793 bytes kpov_judge/tasks/set_motd/howtos/images/second.PNG | Bin 25542 -> 0 bytes kpov_judge/tasks/set_motd/howtos/images/second.png | Bin 0 -> 25542 bytes kpov_judge/tasks/set_motd/howtos/si/index.html | 96 ++++++++++----------- kpov_judge/tasks/set_motd/task.py | 8 +- kpov_judge/web/kpov_judge/kpov_judge.py | 14 ++- .../web/kpov_judge/templates/task_greeting.html | 3 + 9 files changed, 70 insertions(+), 57 deletions(-) delete mode 100644 kpov_judge/tasks/set_motd/howtos/images/first.PNG create mode 100644 kpov_judge/tasks/set_motd/howtos/images/first.png delete mode 100644 kpov_judge/tasks/set_motd/howtos/images/second.PNG create mode 100644 kpov_judge/tasks/set_motd/howtos/images/second.png 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 deleted file mode 100644 index d3797d7..0000000 Binary files a/kpov_judge/tasks/set_motd/howtos/images/first.PNG and /dev/null differ diff --git a/kpov_judge/tasks/set_motd/howtos/images/first.png b/kpov_judge/tasks/set_motd/howtos/images/first.png new file mode 100644 index 0000000..d3797d7 Binary files /dev/null and b/kpov_judge/tasks/set_motd/howtos/images/first.png differ diff --git a/kpov_judge/tasks/set_motd/howtos/images/second.PNG b/kpov_judge/tasks/set_motd/howtos/images/second.PNG deleted file mode 100644 index 61bea73..0000000 Binary files a/kpov_judge/tasks/set_motd/howtos/images/second.PNG and /dev/null differ diff --git a/kpov_judge/tasks/set_motd/howtos/images/second.png b/kpov_judge/tasks/set_motd/howtos/images/second.png new file mode 100644 index 0000000..61bea73 Binary files /dev/null and b/kpov_judge/tasks/set_motd/howtos/images/second.png differ 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 @@ - - -

Naloga na hitro

-

- -

Navodila

- - -

How To

-
    -
  1. Prijavi se v računalnik
  2. -
  3. S poljubnim urejevalnikom besedila odpri /etc/motd
  4. -
  5. Nastavite MOTD na vaš dodeljen String
  6. + + +

    Naloga na hitro

    +

    + +

    Navodila

    + + +

    How To

    +
      +
    1. Prijavi se v raÄŤunalnik
    2. +
    3. S poljubnim urejevalnikom besedila odpri /etc/motd
    4. +
    5. Nastavite MOTD na vaš dodeljen String
    \ 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///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