5 $('form').submit(function(e) {
9 $('.exercise-wtem').each(function() {
11 if(el.hasClass('exercise')) {
14 var type = el.attr('data-type');
20 $('input[name=answers]').val(JSON.stringify(to_submit));
23 var push_answer = function(el, answer) {
24 to_submit[el.attr('data-id')] = answer
28 edumed: function(el) {
29 var exercise = el.data('exercise'),
32 if(exercise.get_answers) {
33 to_push.closed_part = exercise.get_answers()[0];
35 open_part = el.find('.open_part')
36 if(open_part.length) {
37 to_push.open_part = open_part.find('textarea').val();
40 push_answer(el, to_push);
44 var textareas = el.find('textarea'),
46 if(textareas.length === 1) {
47 to_push = el.find('textarea').val();
50 textareas.each(function() {
51 var textarea = $(this);
52 to_push.push({'id': textarea.attr('data-field-id'), 'text': textarea.val()});
55 push_answer(el, to_push);
59 var sms_handler = function() {
60 var textarea = $(this),
61 label_suffix = textarea.parent().find('.label_suffix'),
62 left = 140 - textarea.val().length;
63 to_insert = '(pozostaĆo: ' + left + ')';
65 to_insert = '<span style="color:red">' + to_insert + '</span>';
67 label_suffix.html(to_insert);
70 $('#wtem_sms').change(sms_handler).keyup(sms_handler);