From 3fd04fa811ccc4be2c8f949d06faef9b0325a393 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 6 Nov 2013 10:53:32 +0100 Subject: [PATCH] Sending exercise ids when submitting the contest form --- wtem/static/wtem/wtem.js | 10 +++++++--- wtem/templates/wtem/exercises/edumed_prawdafalsz.html | 2 +- .../templates/wtem/exercises/edumed_przyporzadkuj.html | 2 +- wtem/templates/wtem/exercises/edumed_uporzadkuj.html | 2 +- wtem/templates/wtem/exercises/edumed_wybor.html | 2 +- wtem/templates/wtem/exercises/file_upload.html | 2 +- wtem/templates/wtem/exercises/open.html | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/wtem/static/wtem/wtem.js b/wtem/static/wtem/wtem.js index 3f9bfad..5056b73 100644 --- a/wtem/static/wtem/wtem.js +++ b/wtem/static/wtem/wtem.js @@ -4,7 +4,7 @@ $(function() { $('#submit_answers').click(function(e) { //e.preventDefault(); - to_submit = []; + to_submit = {}; $('.exercise-wtem').each(function() { var el = $(this); @@ -21,16 +21,20 @@ $(function() { $('input[name=answers]').val(JSON.stringify(to_submit)); }); + var push_answer = function(el, answer) { + to_submit[el.attr('data-id')] = answer + }; + var handlers = { edumed: function(el) { var exercise = el.data('exercise'); if(exercise.get_answers) { - to_submit.push(exercise.get_answers()[0]); + push_answer(el, exercise.get_answers()[0]); } }, open: function(el) { - to_submit.push(el.find('textarea').val()); + push_answer(el, el.find('textarea').val()); } } diff --git a/wtem/templates/wtem/exercises/edumed_prawdafalsz.html b/wtem/templates/wtem/exercises/edumed_prawdafalsz.html index b5b7c3f..9ea5a5a 100644 --- a/wtem/templates/wtem/exercises/edumed_prawdafalsz.html +++ b/wtem/templates/wtem/exercises/edumed_prawdafalsz.html @@ -1,4 +1,4 @@ -
+

Zadanie {{no}}

diff --git a/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html b/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html index b5a1a3d..3fb9517 100644 --- a/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html +++ b/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html @@ -1,4 +1,4 @@ -
+

Zadanie {{no}}

diff --git a/wtem/templates/wtem/exercises/edumed_uporzadkuj.html b/wtem/templates/wtem/exercises/edumed_uporzadkuj.html index 082ae49..5da6053 100644 --- a/wtem/templates/wtem/exercises/edumed_uporzadkuj.html +++ b/wtem/templates/wtem/exercises/edumed_uporzadkuj.html @@ -1,4 +1,4 @@ -
+

Zadanie {{no}}

diff --git a/wtem/templates/wtem/exercises/edumed_wybor.html b/wtem/templates/wtem/exercises/edumed_wybor.html index 3fdb80a..031c718 100644 --- a/wtem/templates/wtem/exercises/edumed_wybor.html +++ b/wtem/templates/wtem/exercises/edumed_wybor.html @@ -1,4 +1,4 @@ -
+

Zadanie {{no}}

diff --git a/wtem/templates/wtem/exercises/file_upload.html b/wtem/templates/wtem/exercises/file_upload.html index df6f64b..e74e373 100644 --- a/wtem/templates/wtem/exercises/file_upload.html +++ b/wtem/templates/wtem/exercises/file_upload.html @@ -1,4 +1,4 @@ -
+

Zadanie {{no}}

diff --git a/wtem/templates/wtem/exercises/open.html b/wtem/templates/wtem/exercises/open.html index dbb3f53..4d2c782 100644 --- a/wtem/templates/wtem/exercises/open.html +++ b/wtem/templates/wtem/exercises/open.html @@ -1,4 +1,4 @@ -
+

Zadanie {{no}}

-- 2.20.1