5 $('form').submit(function(e) {
10 $('.exercise-wtem').each(function() {
12 if(el.hasClass('exercise')) {
15 var type = el.attr('data-type');
21 $('input[name=answers]').val(JSON.stringify(to_submit));
24 var push_answer = function(el, answer) {
25 to_submit[el.attr('data-id')] = answer
29 edumed: function(el) {
30 var exercise = el.data('exercise'),
33 if(exercise.get_answers) {
34 to_push.closed_part = exercise.get_answers()[0];
36 open_part = el.find('.open_part')
37 if(open_part.length) {
38 to_push.open_part = open_part.find('textarea').val();
41 push_answer(el, to_push);
45 var textareas = el.find('textarea'),
47 if(textareas.length === 1) {
48 to_push = el.find('textarea').val();
51 textareas.each(function() {
52 var textarea = $(this);
53 to_push.push({'id': textarea.attr('data-field-id'), 'text': textarea.val()});
56 push_answer(el, to_push);
60 var sms_handler = function() {
61 var textarea = $(this),
62 label_suffix = textarea.parent().find('.label_suffix'),
63 left = 140 - textarea.val().length;
64 to_insert = '(pozostaĆo: ' + left + ')';
66 to_insert = '<span style="color:red">' + to_insert + '</span>';
68 label_suffix.html(to_insert);
71 $('#wtem_sms').change(sms_handler).keyup(sms_handler);
73 var spinner = $('.wtem_spinner');