X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/8ae014fa8f6e9e9555f28dc9e09ce0c81e58bc85..28e55ad9db74291ea3ca8380fb2bf96280336f55:/wtem/static/wtem/edumed.js diff --git a/wtem/static/wtem/edumed.js b/wtem/static/wtem/edumed.js index f828dec..940ca54 100644 --- a/wtem/static/wtem/edumed.js +++ b/wtem/static/wtem/edumed.js @@ -95,6 +95,16 @@ }); }; + Exercise.prototype.get_answers = function() { + var answers, + _this = this; + answers = []; + $('.question', this.element).each(function(i, question) { + return answers.push(_this.get_answer(question)); + }); + return answers; + }; + Exercise.prototype.get_value_list = function(elem, data_key, numbers) { var vl; vl = $(elem).attr("data-" + data_key).split(/[ ,]+/).map($.trim); @@ -286,6 +296,20 @@ }); }; + Wybor.prototype.get_answer = function(question) { + var answer, + _this = this; + answer = []; + $('.question-piece', question).each(function(i, qpiece) { + var $qpiece; + $qpiece = $(qpiece); + if ($("input[type=checkbox],input[type=radio]", qpiece).is(':checked')) { + return answer.push($qpiece.attr('data-name')); + } + }); + return answer; + }; + return Wybor; })(Exercise); @@ -348,6 +372,16 @@ return _results; }; + Uporzadkuj.prototype.get_answer = function(question) { + var answer, + _this = this; + answer = []; + $(".question-piece", this.element).each(function(i, qpiece) { + return answer.push($(qpiece).attr('data-pos')); + }); + return answer; + }; + return Uporzadkuj; })(Exercise); @@ -509,6 +543,12 @@ return d1.data("no") === d2.data("no"); }; + Przyporzadkuj.prototype.draggable_accept = function($draggable, $droppable) { + var dropped; + dropped = $droppable.closest("ul, ol").find(".draggable"); + return (Przyporzadkuj.__super__.draggable_accept.call(this, $draggable, $droppable)) && dropped.length === 0; + }; + Przyporzadkuj.prototype.check_question = function(question) { var all, bad_count, count, mandatory, minimum, optional, pn, pred, qp, self, v, _i, _j, _len, _len1, _ref, _ref1; minimum = $(question).data("minimum"); @@ -576,6 +616,23 @@ return _results; }; + Przyporzadkuj.prototype.get_answer = function(question) { + var answer, + _this = this; + answer = {}; + $(".predicate [data-predicate]", question).each(function(i, subjects) { + var predicate; + predicate = $(subjects).attr('data-predicate'); + answer[predicate] = []; + return $('.question-piece', subjects).each(function(i, qpiece) { + var $qpiece; + $qpiece = $(qpiece); + return answer[predicate].push($qpiece.attr('data-id')); + }); + }); + return answer; + }; + return Przyporzadkuj; })(Exercise); @@ -641,6 +698,16 @@ return _results; }; + PrawdaFalsz.prototype.get_answer = function(question) { + var answer, + _this = this; + answer = []; + $(".question-piece", this.element).each(function(i, qpiece) { + return answer.push($(qpiece).data('value') || '-'); + }); + return answer; + }; + return PrawdaFalsz; })(Exercise);