summaryrefslogtreecommitdiff
path: root/kpov_judge/web
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-10-26 20:29:07 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-10-26 20:29:07 +0000
commit173d160b19811eb77fdd36c9c0eacf90b65a83f3 (patch)
tree39be79cb274af05b233a2154ea5f1bcbe762f246 /kpov_judge/web
parent4a191a4775f01f66bf7610c38f11517ec4c3a547 (diff)
Fixed web program after first exam
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@342 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/web')
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py33
-rw-r--r--kpov_judge/web/kpov_judge/templates/task.html2
-rw-r--r--kpov_judge/web/kpov_judge/templates/task_greeting.html2
3 files changed, 21 insertions, 16 deletions
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index 3242c9d..6302c3a 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -52,7 +52,7 @@ def root():
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})
+ params = db.task_params.find_one({'task_id': task_id, 'student_id': student_id})['params']
if params is None:
# params = {}
#else:
@@ -67,13 +67,14 @@ def results_post(task_id, results):
for param_name, param_meta in meta.iteritems():
if param_meta.get('w', False) and param_name in user_params:
params[param_name] = user_params[param_name]
- task_check_source = task_source(task_id)
try:
+ task_check_source = db.task_checkers.find_one({'task_id': task_id})['source']
task_check_code = compile(task_check_source, 'checker.py', 'exec')
exec(task_check_code)
- res, hints = task_check(results, params)
+ # raise Exception(str(params))
+ hints, res = task_check(results, params)
except Exception as e:
- hints = ["Checker crashed: " + str(e)]
+ hints = ["Checker died: " + str(e)]
res = 0
if isinstance(res, int) and res > 0:
res_status = 'OK'
@@ -96,13 +97,13 @@ def results_dict(task_id):
except Exception as e:
return {'Error': str(e)}
-@app.route('/tasks/<int:task_id>/results.json', methods=['GET', 'POST'])
+@app.route('/tasks/<task_id>/results.json', methods=['GET', 'POST'])
def results_json(task_id):
if flask.app.request.method == 'POST':
- return results_post(task_id, json.loads(flask.app.request.form['results']))
+ return json.dumps(results_post(task_id, json.loads(flask.app.request.form['results'])))
return json.dumps(results_dict(task_id))
-@app.route('/tasks/<int:task_id>/<lang>/results.html')
+@app.route('/tasks/<task_id>/<lang>/results.html')
def results_html(task_id, lang):
return render_template('results.html', results=results_dict(task_id))
@@ -121,7 +122,7 @@ def public_meta(db, task_id):
return shown
-@app.route('/tasks/<int:task_id>/task.py')
+@app.route('/tasks/<task_id>/task.py')
def task_source(task_id):
db = g.db
try:
@@ -130,7 +131,7 @@ def task_source(task_id):
return dummy_task
return task_str
-@app.route('/tasks/<int:task_id>/task.html')
+@app.route('/tasks/<task_id>/task.html')
def task_html(task_id):
return render_template('task.html', task=task_source(task_id))
@@ -166,21 +167,21 @@ def get_params(task_id, student_id, db):
params = params['params']
return params, meta
-@app.route('/tasks/<int:task_id>/')
+@app.route('/tasks/<task_id>/')
def task_lang_redirect(task_id):
return redirect(url_for('task_greeting', task_id=task_id, lang=app.config['DEFAULT_LANG']))
-@app.route('/tasks/<int:task_id>/<lang>/howto/')
+@app.route('/tasks/<task_id>/<lang>/howto/')
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/<int:task_id>/<lang>/images/<fname>')
+@app.route('/tasks/<task_id>/<lang>/images/<fname>')
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/<int:task_id>/<lang>/')
+@app.route('/tasks/<task_id>/<lang>/')
def task_greeting(task_id, lang):
student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody')
db = g.db
@@ -219,7 +220,7 @@ def task_greeting(task_id, lang):
openstackCreated = False
return render_template('task_greeting.html', computers=computer_list, lang=lang, openstack=openstackCreated, instructions=instructions)
-@app.route('/tasks/<int:task_id>/params.json', methods=['GET', 'POST'])
+@app.route('/tasks/<task_id>/params.json', methods=['GET', 'POST'])
def params_json(task_id):
student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody')
db = g.db
@@ -242,7 +243,7 @@ def params_json(task_id):
shown_params[name] = param
return json.dumps(shown_params)
-@app.route('/tasks/<int:task_id>/<lang>/params.html', methods=['GET', 'POST'])
+@app.route('/tasks/<task_id>/<lang>/params.html', methods=['GET', 'POST'])
def params_html(task_id, lang):
student_id = flask.app.request.environ.get('REMOTE_USER', 'Nobody')
db = g.db
@@ -263,7 +264,7 @@ def params_html(task_id, lang):
return render_template('params.html', params=shown_params, params_meta=meta)
-@app.route('/tasks/<int:task_id>/params_meta.json')
+@app.route('/tasks/<task_id>/params_meta.json')
def params_meta(task_id):
db = g.db
return json.dumps(public_meta(db, task_id))
diff --git a/kpov_judge/web/kpov_judge/templates/task.html b/kpov_judge/web/kpov_judge/templates/task.html
index 98147ab..ddad5d8 100644
--- a/kpov_judge/web/kpov_judge/templates/task.html
+++ b/kpov_judge/web/kpov_judge/templates/task.html
@@ -1,3 +1,5 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<h1>
diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html
index b1ede6c..f19f534 100644
--- a/kpov_judge/web/kpov_judge/templates/task_greeting.html
+++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html
@@ -1,3 +1,5 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<h1>