fnp
/
edumed.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d5c4f92
)
Serializing answers to form field
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 31 Oct 2013 12:51:32 +0000
(13:51 +0100)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 15 Jan 2014 10:18:53 +0000
(11:18 +0100)
wtem/static/wtem/wtem.js
patch
|
blob
|
history
wtem/templates/wtem/exercises/edumed_prawdafalsz.html
patch
|
blob
|
history
wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
patch
|
blob
|
history
wtem/templates/wtem/exercises/edumed_uporzadkuj.html
patch
|
blob
|
history
wtem/templates/wtem/exercises/edumed_wybor.html
patch
|
blob
|
history
wtem/templates/wtem/exercises/file_upload.html
patch
|
blob
|
history
wtem/templates/wtem/exercises/open.html
patch
|
blob
|
history
wtem/templates/wtem/main.html
patch
|
blob
|
history
diff --git
a/wtem/static/wtem/wtem.js
b/wtem/static/wtem/wtem.js
index
f7dccdc
..
209108f
100644
(file)
--- a/
wtem/static/wtem/wtem.js
+++ b/
wtem/static/wtem/wtem.js
@@
-1,15
+1,37
@@
$(function() {
$(function() {
+ var to_submit;
+
$('#submit_answers').click(function(e) {
e.preventDefault();
$('#submit_answers').click(function(e) {
e.preventDefault();
- var to_submit = [];
- $('.exercise').each(function() {
- var exercise = $(this).data('exercise');
- if(exercise.get_answers) {
- to_submit.push(exercise.get_answers()[0]);
+ to_submit = [];
+
+ $('.exercise-wtem').each(function() {
+ var el = $(this);
+ if(el.hasClass('exercise')) {
+ handlers.edumed(el);
+ } else {
+ var type = el.attr('data-type');
+ if(handlers[type]) {
+ handlers[type](el);
+ }
}
});
console.log(JSON.stringify(to_submit));
}
});
console.log(JSON.stringify(to_submit));
+ $('input[name=wtem_answers]').val(JSON.stringify(to_submit));
});
});
+ var handlers = {
+ edumed: function(el) {
+ var exercise = el.data('exercise');
+ if(exercise.get_answers) {
+ to_submit.push(exercise.get_answers()[0]);
+ }
+ },
+
+ open: function(el) {
+ to_submit.push(el.find('textarea').val());
+ }
+ }
+
});
\ No newline at end of file
});
\ No newline at end of file
diff --git
a/wtem/templates/wtem/exercises/edumed_prawdafalsz.html
b/wtem/templates/wtem/exercises/edumed_prawdafalsz.html
index
a55724a
..
b5b7c3f
100644
(file)
--- a/
wtem/templates/wtem/exercises/edumed_prawdafalsz.html
+++ b/
wtem/templates/wtem/exercises/edumed_prawdafalsz.html
@@
-1,4
+1,4
@@
-<div class="exercise prawdafalsz" data-type="prawdafalsz">
+<div class="exercise
exercise-wtem
prawdafalsz" data-type="prawdafalsz">
<h3>Zadanie {{no}}</h3>
<h3>Zadanie {{no}}</h3>
diff --git
a/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
b/wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
index
c56dec0
..
b5a1a3d
100644
(file)
--- a/
wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
+++ b/
wtem/templates/wtem/exercises/edumed_przyporzadkuj.html
@@
-1,4
+1,4
@@
-<div class="exercise przyporzadkuj" data-type="przyporzadkuj">
+<div class="exercise
exercise-wtem
przyporzadkuj" data-type="przyporzadkuj">
<h3>Zadanie {{no}}</h3>
<h3>Zadanie {{no}}</h3>
diff --git
a/wtem/templates/wtem/exercises/edumed_uporzadkuj.html
b/wtem/templates/wtem/exercises/edumed_uporzadkuj.html
index
1f2068d
..
082ae49
100644
(file)
--- a/
wtem/templates/wtem/exercises/edumed_uporzadkuj.html
+++ b/
wtem/templates/wtem/exercises/edumed_uporzadkuj.html
@@
-1,4
+1,4
@@
-<div class="exercise uporzadkuj" data-type="uporzadkuj">
+<div class="exercise
exercise-wtem
uporzadkuj" data-type="uporzadkuj">
<h3>Zadanie {{no}}</h3>
<h3>Zadanie {{no}}</h3>
diff --git
a/wtem/templates/wtem/exercises/edumed_wybor.html
b/wtem/templates/wtem/exercises/edumed_wybor.html
index
0fe9600
..
3fdb80a
100644
(file)
--- a/
wtem/templates/wtem/exercises/edumed_wybor.html
+++ b/
wtem/templates/wtem/exercises/edumed_wybor.html
@@
-1,4
+1,4
@@
-<div class="exercise wybor" data-type="wybor">
+<div class="exercise
exercise-wtem
wybor" data-type="wybor">
<h3>Zadanie {{no}}</h3>
<h3>Zadanie {{no}}</h3>
diff --git
a/wtem/templates/wtem/exercises/file_upload.html
b/wtem/templates/wtem/exercises/file_upload.html
index
44b78e6
..
e4be9a1
100644
(file)
--- a/
wtem/templates/wtem/exercises/file_upload.html
+++ b/
wtem/templates/wtem/exercises/file_upload.html
@@
-1,4
+1,4
@@
-<div>
+<div
class="exercise-wtem" data-type="file"
>
<h3>Zadanie {{no}}</h3>
<h3>Zadanie {{no}}</h3>
diff --git
a/wtem/templates/wtem/exercises/open.html
b/wtem/templates/wtem/exercises/open.html
index
3e08265
..
dbb3f53
100644
(file)
--- a/
wtem/templates/wtem/exercises/open.html
+++ b/
wtem/templates/wtem/exercises/open.html
@@
-1,4
+1,4
@@
-<div>
+<div
class="exercise-wtem" data-type="open"
>
<h3>Zadanie {{no}}</h3>
<h3>Zadanie {{no}}</h3>
diff --git
a/wtem/templates/wtem/main.html
b/wtem/templates/wtem/main.html
index
e7ce29a
..
4536cfb
100644
(file)
--- a/
wtem/templates/wtem/main.html
+++ b/
wtem/templates/wtem/main.html
@@
-19,6
+19,7
@@
<hr/>
<hr/>
+<input type="hidden" name="wtem_answers" value=""/>
<button style="display: block; margin: auto;" id="submit_answers">Wyślij moje odpowiedzi</button>
</form>
<button style="display: block; margin: auto;" id="submit_answers">Wyślij moje odpowiedzi</button>
</form>