From: Aleksander Ɓukasz Date: Wed, 6 Nov 2013 09:53:32 +0000 (+0100) Subject: Sending exercise ids when submitting the contest form X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/3fd04fa811ccc4be2c8f949d06faef9b0325a393 Sending exercise ids when submitting the contest form --- 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}}