From 53fea983a90447865c429c2573bfb36cba179054 Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Wed, 1 Apr 2015 20:32:28 +0000 Subject: added hints to task results git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@296 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/web/kpov_judge/kpov_judge.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'kpov_judge/web') diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index ef7d542..b2636e2 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -56,6 +56,7 @@ def auth_greeting(): return "To je past!" + str(flask.app.request.__dict__) def results_post(task_id, results): + student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody') db = g.db params = db.task_params.find_one({'task_id': task_id, 'student_id': student_id}) if params is None: @@ -72,6 +73,7 @@ def results_post(task_id, results): if param_meta.get('w', False) and param_name in user_params: params[param_name] = user_params[param_name] task_check_source = db.task_checkers.find_one({'task_id':task_id}) + hints = [] if task_check_source is None: task_check_source = dummy_checker else: @@ -79,16 +81,17 @@ def results_post(task_id, results): try: task_check_code = compile(task_check_source, 'checker.py', 'exec') exec(task_check_code) - res = task_check(results, params) + res, hints = task_check(results, params) except Exception, e: - res = "Checker crashed: " + str(e) + hints += ["Checker crashed: " + str(e)] + res = 0 # flask.app.logger.error(str(e)) if (type(res) is int and res > 0): res_status = 'OK' else: res_status = 'NOT OK' - db.results.insert({'task_id': task_id, 'result': res, 'status': res_status,'student_id': student_id, 'response': results, 'time': datetime.datetime.now()}) - return {'result': res, 'status': res_status} + db.results.insert({'task_id': task_id, 'result': res, 'hints': hints, 'status': res_status,'student_id': student_id, 'response': results, 'time': datetime.datetime.now()}) + return {'result': res, 'hints': hints, 'status': res_status} def results_dict(task_id): student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody') -- cgit v1.2.1