summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-04-01 21:27:08 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-04-01 21:27:08 +0000
commit54c45f7e5e85a088eeb301fb3677f9c743cccbb5 (patch)
treefd3405ccd88a17b84308ea09b365bdd8d87b57cc
parent53fea983a90447865c429c2573bfb36cba179054 (diff)
Tested copy_rename_20_files_tail_env, added some hints.
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@297 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rwxr-xr-xkpov_judge/rm_task.py1
-rw-r--r--kpov_judge/tasks/copy_rename_20_files_tail_env/task.py43
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py2
3 files changed, 39 insertions, 7 deletions
diff --git a/kpov_judge/rm_task.py b/kpov_judge/rm_task.py
index 0083149..e724d68 100755
--- a/kpov_judge/rm_task.py
+++ b/kpov_judge/rm_task.py
@@ -29,6 +29,7 @@ if __name__ == '__main__':
db.tasks.remove({'task_id': task_id})
db.prepare_disks.remove({'task_id': task_id})
db.student_computers.remove({'task_id': task_id})
+ db.results.remove({'task_id': task_id})
db.gen_params.remove({'task_id': task_id})
db.task_params_meta.remove({'task_id': task_id})
db.task_params.remove({'task_id': task_id})
diff --git a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
index 856d311..44e9f87 100644
--- a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
+++ b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
@@ -107,7 +107,7 @@ params_meta = {
'wc_n_lines': {'descriptions': {'si': 'n vrstic v count.txt'}, 'w': False, 'public':False, 'type': 'integer', 'generated': True},
}
-def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string):
+def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string, curl_fname, wc_dirname):
import pxssh
import os
# TODO: (polz) this has to be changed! Get a move on!
@@ -171,10 +171,10 @@ def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_strin
conn.prompt()
results['cowsay'] = conn.before
results['curl_env'] = os.environ['images']
- conn.sendline('cat {wc_dirname}/count.txt')
+ conn.sendline('cat {}/count.txt'.format(wc_dirname))
conn.prompt()
results['wc_origfile'] = conn.before
- conn.sendline('cat {wc_dirname}/lines.txt')
+ conn.sendline('cat {}/lines.txt'.format(wc_dirname))
conn.prompt()
results['wc_lines'] = conn.before
conn.logout()
@@ -246,6 +246,10 @@ def task_check(results, params):
results['mv_ls_size'])
mv_ls_size = int(task2_re.group(1))
task2_ok = mv_ls_size < 15 and mv_ls_size > 2
+ if task2_ok:
+ score += 1
+ else:
+ hints += ["wrong rename size"]
pre_src = set([i.strip() for i in results['pre_mv_src'].split('\n')[3:-1]])
pre_dst = set([i.strip() for i in results['pre_mv_dst'].split('\n')[3:-1]])
task2_ok = task2_ok and pre_src == set(fnames)
@@ -255,9 +259,9 @@ def task_check(results, params):
task2_ok = task2_ok and post_dst == set(fnames)
task2_ok = task2_ok and len(post_src) < 2
if task2_ok:
- score += 2
+ score += 1
else:
- hints += ["wrong rename cmd"]
+ hints += ["wrong rename files"]
# mama_ukaz
#
task3_ok = True
@@ -296,6 +300,31 @@ def task_check(results, params):
#print( results['syslog_start_time'])
#print( results['syslog_result'])
#print( results['syslog_end_time'])
+ # syslog count
+ # TODO: check syslog
+ task4_ok = True
+ if task4_ok:
+ score += 1
+ else:
+ hints += ["wrong syslog count"]
+ #
+ task5_ok = True
+ if int(results['curl_env'].strip()) != int(params['curl_n_images']):
+ task5_ok = False
+ if task5_ok:
+ score += 2
+ else:
+ hints += ["wrong image count"]
+ task6_ok = True
+ wc_cat_str = 'cat {}/lines.txt'.format(params['wc_dirname'])
+ if not wc_cat_str == results['wc_lines'][:len(wc_cat_str)]:
+ task6_ok = False
+ if int(results['wc_lines'][len(wc_cat_str):].strip()) != int(params['wc_n_lines']):
+ task6_ok = False
+ if task6_ok:
+ score += 1
+ else:
+ hints += ["wrong line count"]
return score, hints
def prepare_disks(templates, params):
@@ -359,4 +388,6 @@ def prepare_disks(templates, params):
lx += ['a', 'b', 'c', 'repa', 'in', 'krompir',
'raus', 'e', 'patacis'] * r.randint(50, 150)
r.shuffle(lx)
- d.write("{}".format(params['wc_dirname']), "".join(lx))
+ d.mkdir(params['wc_dirname'])
+ d.chown(1000, 1000, params['wc_dirname'])
+ d.write("{}".format(os.path.join(params['wc_dirname'], 'count.txt')), "".join(lx))
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index b2636e2..67a0d1c 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -100,7 +100,7 @@ def results_dict(task_id):
entry = db.results.find_one(
{'$query': {'task_id': task_id, 'student_id': student_id},
'$orderby': {'status': -1}},
- {'result': 1, 'status': 1, '_id': 0})
+ {'result': 1, 'status': 1, 'hints': 1, '_id': 0})
if entry is None:
return {'result': 'Naloga ni bila nikdar ocenjena', 'status': 'NOT OK'}
return entry