Sending exercise ids when submitting the contest form
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 6 Nov 2013 09:53:32 +0000 (10:53 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 15 Jan 2014 10:18:54 +0000 (11:18 +0100)
wtem/static/wtem/wtem.js
wtem/templates/wtem/exercises/edumed_prawdafalsz.html
wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
wtem/templates/wtem/exercises/edumed_uporzadkuj.html
wtem/templates/wtem/exercises/edumed_wybor.html
wtem/templates/wtem/exercises/file_upload.html
wtem/templates/wtem/exercises/open.html

index 3f9bfad..5056b73 100644 (file)
@@ -4,7 +4,7 @@ $(function() {
 
     $('#submit_answers').click(function(e) {
         //e.preventDefault();
 
     $('#submit_answers').click(function(e) {
         //e.preventDefault();
-        to_submit = [];
+        to_submit = {};
 
         $('.exercise-wtem').each(function() {
             var el = $(this);
 
         $('.exercise-wtem').each(function() {
             var el = $(this);
@@ -21,16 +21,20 @@ $(function() {
         $('input[name=answers]').val(JSON.stringify(to_submit));
     });
 
         $('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) {
     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) {
             }
         },
 
         open: function(el) {
-            to_submit.push(el.find('textarea').val());
+            push_answer(el, el.find('textarea').val());
         }
     }
 
         }
     }
 
index b5b7c3f..9ea5a5a 100644 (file)
@@ -1,4 +1,4 @@
-<div class="exercise exercise-wtem prawdafalsz" data-type="prawdafalsz">
+<div class="exercise exercise-wtem prawdafalsz" data-type="prawdafalsz" data-id="{{exercise.id}}">
 
     <h3>Zadanie {{no}}</h3>
 
 
     <h3>Zadanie {{no}}</h3>
 
index b5a1a3d..3fb9517 100644 (file)
@@ -1,4 +1,4 @@
-<div class="exercise exercise-wtem przyporzadkuj" data-type="przyporzadkuj">
+<div class="exercise exercise-wtem przyporzadkuj" data-type="przyporzadkuj" data-id="{{exercise.id}}">
 
     <h3>Zadanie {{no}}</h3>
     
 
     <h3>Zadanie {{no}}</h3>
     
index 082ae49..5da6053 100644 (file)
@@ -1,4 +1,4 @@
-<div class="exercise exercise-wtem uporzadkuj" data-type="uporzadkuj">
+<div class="exercise exercise-wtem uporzadkuj" data-type="uporzadkuj" data-id="{{exercise.id}}">
 
     <h3>Zadanie {{no}}</h3>
 
 
     <h3>Zadanie {{no}}</h3>
 
index 3fdb80a..031c718 100644 (file)
@@ -1,4 +1,4 @@
-<div class="exercise exercise-wtem wybor" data-type="wybor">
+<div class="exercise exercise-wtem wybor" data-type="wybor" data-id="{{exercise.id}}">
 
     <h3>Zadanie {{no}}</h3>
 
 
     <h3>Zadanie {{no}}</h3>
 
index df6f64b..e74e373 100644 (file)
@@ -1,4 +1,4 @@
-<div class="exercise-wtem" data-type="file">
+<div class="exercise-wtem" data-type="file" data-id="{{exercise.id}}">
 
     <h3>Zadanie {{no}}</h3>
         
 
     <h3>Zadanie {{no}}</h3>
         
index dbb3f53..4d2c782 100644 (file)
@@ -1,4 +1,4 @@
-<div class="exercise-wtem" data-type="open">
+<div class="exercise-wtem" data-type="open" data-id="{{exercise.id}}">
 
     <h3>Zadanie {{no}}</h3>
         
 
     <h3>Zadanie {{no}}</h3>