diff options
Diffstat (limited to 'kpov_judge/web')
-rwxr-xr-x | kpov_judge/web/kpov_judge/kpov_judge.py | 11 |
1 files changed, 7 insertions, 4 deletions
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') |