diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-10-27 16:50:24 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-10-27 16:50:24 +0000 |
commit | a30cb3c64da93b8667ad55213d850eadcbad7844 (patch) | |
tree | 6e690db5cbc6ce7a37f3645fbfbf4d2781eaa7c6 | |
parent | d02cd69a8391df327dbfb367d57b8927eeddc6fc (diff) |
Fixed encoding in pristopni_kolokvij
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@345 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rwxr-xr-x | kpov_judge/add_task.py | 6 | ||||
-rw-r--r-- | kpov_judge/tasks/mock_entrance_exam/task.py | 16 | ||||
-rwxr-xr-x | kpov_judge/web/kpov_judge/kpov_judge.py | 7 |
3 files changed, 21 insertions, 8 deletions
diff --git a/kpov_judge/add_task.py b/kpov_judge/add_task.py index bf2588c..dc7a608 100755 --- a/kpov_judge/add_task.py +++ b/kpov_judge/add_task.py @@ -81,8 +81,10 @@ if __name__ == '__main__': db.prepare_disks.update({'task_id': task_id}, {'$set': {'source': prepare_disks_source}}, upsert=True) db.gen_params.update({'task_id': task_id}, {'$set': {'source': gen_params_source}}, upsert=True) db.task_params_meta.update({'task_id': task_id}, {'$set': {'params': params_meta}}, upsert=True) - db.task_instructions.update({'task_id': task_id}, {'$set': - instructions}, upsert=True) + #instructions = dict([(k, v.encode('utf8')) for k, v in instructions.iteritems()]) + #print instructions + db.task_instructions.update({'task_id': task_id}, {'$set': instructions + }, upsert=True) for howto_dir in glob.glob(os.path.join(dirname, 'howtos/*')): howto_lang = os.path.basename(os.path.normpath(howto_dir)) if howto_lang not in {'images'}: diff --git a/kpov_judge/tasks/mock_entrance_exam/task.py b/kpov_judge/tasks/mock_entrance_exam/task.py index 998bd24..493366b 100644 --- a/kpov_judge/tasks/mock_entrance_exam/task.py +++ b/kpov_judge/tasks/mock_entrance_exam/task.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# # TODO: # - check if everything is filled in (computers, params, preparation) # - improve scoring @@ -5,7 +8,12 @@ # - switch to a real SSH/SFTP client to properly handle filenames instructions = { - 'si': u'''simpleArbiter povezan na Internet. Računajte, da se na student ob zagonu zažene program {net_prog_name}, + 'si': u''' +Postavite dva navidezna računalnika - SimpleArbiter in Student. +Oba naj bosta povezana na internet. Poleg tega mora biti +Student na naslovu {student_IP} dostopen s SimpleArbiter. + +Računajte, da se na Student ob zagonu zažene program {net_prog_name}, ki vam spreminja nastavitve mrežne kartice. V domačem imeniku uporabnika student obstaja program {P_c} v programskem jeziku C. @@ -14,9 +22,9 @@ Izvorna koda je namenoma pokvarjena tako, da so vanjo vrinjeni nepotrebni znaki. Pred prevajanjem jo morate popraviti. Napišite skripto ali program {P_script} v domačem imeniku uporabnika student, ki: -- požene {P_executable} z argumentom {arg_c} in mu na standardni vhod pripelje vrednost spremenljivke {env_c} -- vse, kar {P_c} izpiše na stderr, spravi v datoteko {out_stderr_c}. -- vse vrstice, ki jih {P_c} izpiše na stdout in vsebujejo zaporedje znakov "ma", zapiše v {out_stdout_c}. +- požene {P_executable} z argumentom "{arg_c}" in mu na standardni vhod pripelje vrednost spremenljivke {env_c} +- vse, kar {P_executable} izpiše na stderr, spravi v datoteko {out_stderr_c}. +- vse vrstice, ki jih {P_executable} izpiše na stdout in vsebujejo zaporedje znakov "ma", zapiše v {out_stdout_c}. Lastnik vseh ustvarjenih datotek mora biti uporabnik student. diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index 6302c3a..26d3b1d 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -190,21 +190,24 @@ def task_greeting(task_id, lang): instr_ok = True try: instructions = db.task_instructions.find({'task_id': task_id})[0] - instructions = instructions.get(lang, - app.config['DEFAULT_LANG']) + instructions = instructions.get(lang, instructions[app.config['DEFAULT_LANG']]) except Exception: try: instructions = instructions.values()[0] except Exception as e: instructions = str(e) instr_ok = False + instructions = instructions if instr_ok: try: public_params = {} for k, v in meta.iteritems(): 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 = db.student_computers.find({'task_id': task_id, 'student_id': student_id}) |