From: Aleksander Ɓukasz Date: Thu, 14 Nov 2013 09:32:18 +0000 (+0100) Subject: Allow for only one item in a bucket in questions of type "przyporzadkuj" X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/28e55ad9db74291ea3ca8380fb2bf96280336f55?hp=0cf3b5cb936715be5dcf2877a4873f8c5f7cb209 Allow for only one item in a bucket in questions of type "przyporzadkuj" --- diff --git a/wtem/static/wtem/edumed.coffee b/wtem/static/wtem/edumed.coffee index f4c5c28..ae7aea9 100644 --- a/wtem/static/wtem/edumed.coffee +++ b/wtem/static/wtem/edumed.coffee @@ -415,6 +415,9 @@ class Przyporzadkuj extends Exercise draggable_equal: (d1, d2) -> return d1.data("no") == d2.data("no") + draggable_accept: ($draggable, $droppable) -> + dropped = $droppable.closest("ul, ol").find(".draggable") + return (super $draggable, $droppable) && dropped.length == 0 check_question: (question) -> # subjects placed in predicates diff --git a/wtem/static/wtem/edumed.js b/wtem/static/wtem/edumed.js index df98753..940ca54 100644 --- a/wtem/static/wtem/edumed.js +++ b/wtem/static/wtem/edumed.js @@ -543,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");