+ Luki.prototype.solve_question = function(question) {
+ var _this = this;
+ return $(".placeholder", question).each(function(i, placeholder) {
+ var $qp;
+ $qp = $(".question-piece[data-no=" + $(placeholder).data('solution') + "]", question);
+ return _this.draggable_move($qp, $(placeholder), false);
+ });
+ };
+
+ return Luki;
+
+ })(Exercise);
+
+ Zastap = (function(_super) {
+
+ __extends(Zastap, _super);
+
+ function Zastap(element) {
+ var _this = this;
+ Zastap.__super__.constructor.call(this, element);
+ $(".paragraph", this.element).each(function(i, par) {
+ return _this.wrap_words($(par), $('<span class="placeholder zastap"/>'));
+ });
+ this.dragging(false, false);
+ }
+
+ Zastap.prototype.check = function() {
+ var all, correct,
+ _this = this;
+ all = 0;
+ correct = 0;
+ $(".paragraph", this.element).each(function(i, par) {
+ return $(".placeholder", par).each(function(j, qpiece) {
+ var $dragged, $qp;
+ $qp = $(qpiece);
+ $dragged = $qp.next(".draggable");
+ if ($qp.data("solution")) {
+ if ($dragged && $qp.data("solution") === $dragged.data("no")) {
+ _this.piece_correct($dragged);
+ correct += 1;
+ }
+ return all += 1;
+ }
+ });
+ });
+ return this.show_score([correct, all]);
+ };
+
+ Zastap.prototype.show_solutions = function() {
+ var _this = this;
+ this.reset();
+ return $(".paragraph", this.element).each(function(i, par) {
+ return $(".placeholder[data-solution]", par).each(function(j, qpiece) {
+ var $dr, $qp;
+ $qp = $(qpiece);
+ $dr = $(".draggable[data-no=" + $qp.data('solution') + "]", _this.element);
+ return _this.draggable_move($dr, $qp, false);
+ });
+ });
+ };
+
+ Zastap.prototype.wrap_words = function(element, wrapper) {
+ var chld, i, ignore, insertWrapped, j, len, space, wordb, _i, _ref, _results;
+ ignore = /^[ \t.,:;()]+/;
+ insertWrapped = function(txt, elem) {
+ var nw;
+ nw = wrapper.clone();
+ return $(document.createTextNode(txt)).wrap(nw).parent().attr("data-original", txt).insertBefore(elem);
+ };
+ _results = [];
+ for (j = _i = _ref = element.get(0).childNodes.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; j = _ref <= 0 ? ++_i : --_i) {
+ chld = element.get(0).childNodes[j];
+ if (chld.nodeType === document.TEXT_NODE) {
+ len = chld.textContent.length;
+ wordb = 0;
+ i = 0;
+ while (i < len) {
+ space = ignore.exec(chld.textContent.substr(i));
+ if (space != null) {
+ if (wordb < i) {
+ insertWrapped(chld.textContent.substr(wordb, i - wordb), chld);
+ }
+ $(document.createTextNode(space[0])).insertBefore(chld);
+ i += space[0].length;
+ wordb = i;
+ } else {
+ i = i + 1;
+ }
+ }
+ if (wordb < len - 1) {
+ insertWrapped(chld.textContent.substr(wordb, len - 1 - wordb), chld);
+ }
+ _results.push($(chld).remove());
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ return Zastap;
+
+ })(Exercise);
+
+ Przyporzadkuj = (function(_super) {
+
+ __extends(Przyporzadkuj, _super);
+
+ Przyporzadkuj.prototype.is_multiple = function() {
+ var qp, _i, _len, _ref;
+ _ref = $(".question-piece", this.element);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ qp = _ref[_i];
+ if ($(qp).data('solution').split(/[ ,]+/).length > 1) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ function Przyporzadkuj(element) {
+ Przyporzadkuj.__super__.constructor.call(this, element);
+ this.multiple = this.is_multiple();
+ this.dragging(this.multiple, true);
+ }
+
+ Przyporzadkuj.prototype.draggable_equal = function(d1, d2) {
+ return d1.data("no") === d2.data("no");
+ };
+
+ Przyporzadkuj.prototype.check_question = function(question) {
+ var all, count, mandatory, minimum, optional, pn, pred, qp, v, _i, _j, _len, _len1, _ref, _ref1;
+ minimum = $(question).data("minimum");
+ count = 0;
+ all = 0;
+ if (!minimum) {
+ all = $(".subjects .question-piece", question).length;
+ }
+ _ref = $(".predicate [data-predicate]", question);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ pred = _ref[_i];
+ pn = $(pred).attr('data-predicate');
+ if (minimum != null) {
+ all += minimum;
+ }
+ _ref1 = $(".question-piece", pred);
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ qp = _ref1[_j];
+ v = this.get_value_optional_list(qp, 'solution');
+ mandatory = v[0];
+ optional = v[1];
+ if (mandatory.indexOf(pn) >= 0 || (minimum && optional.indexOf(pn) >= 0)) {
+ count += 1;
+ this.piece_correct(qp);
+ } else {
+ this.piece_incorrect(qp);
+ }
+ }
+ }
+ return [count, all];
+ };
+
+ Przyporzadkuj.prototype.solve_question = function(question) {
+ var $ph, $pr, draggables, m, mandatory, minimum, optional, qp, v, _i, _len, _ref, _results;
+ minimum = $(question).data("min");
+ _ref = $(".subject .question-piece", question);
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ qp = _ref[_i];
+ v = this.get_value_optional_list(qp, 'solution');
+ mandatory = v[0];
+ optional = v[1];
+ if (minimum) {
+ draggables = mandatory.count(optional).slice(0, minimum);
+ } else {
+ draggables = mandatory;
+ }
+ _results.push((function() {
+ var _j, _len1, _results1;
+ _results1 = [];
+ for (_j = 0, _len1 = draggables.length; _j < _len1; _j++) {
+ m = draggables[_j];
+ $pr = $(".predicate [data-predicate=" + m + "]", question);
+ $ph = $pr.find(".placeholder:visible");
+ _results1.push(this.draggable_move($(qp), $ph, this.multiple));
+ }
+ return _results1;
+ }).call(this));
+ }
+ return _results;
+ };
+
+ return Przyporzadkuj;
+
+ })(Exercise);
+
+ PrawdaFalsz = (function(_super) {
+
+ __extends(PrawdaFalsz, _super);
+
+ function PrawdaFalsz(element) {
+ var qp, _i, _len, _ref;
+ PrawdaFalsz.__super__.constructor.call(this, element);
+ _ref = $(".question-piece", this.element);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ qp = _ref[_i];
+ $(".true", qp).click(function(ev) {
+ ev.preventDefault();
+ $(this).closest(".question-piece").data("value", "true");
+ return $(this).addClass('chosen').siblings('a').removeClass('chosen');
+ });
+ $(".false", qp).click(function(ev) {
+ ev.preventDefault();
+ $(this).closest(".question-piece").data("value", "false");
+ return $(this).addClass('chosen').siblings('a').removeClass('chosen');
+ });
+ }
+ }
+
+ PrawdaFalsz.prototype.check_question = function() {
+ var all, good, qp, _i, _len, _ref;
+ all = 0;
+ good = 0;
+ _ref = $(".question-piece", this.element);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ qp = _ref[_i];
+ if ($(qp).data("solution").toString() === $(qp).data("value")) {
+ good += 1;
+ this.piece_correct(qp);
+ } else {
+ this.piece_incorrect(qp);
+ }
+ all += 1;
+ }
+ return [good, all];
+ };
+
+ PrawdaFalsz.prototype.show_solutions = function() {
+ var qp, _i, _len, _ref, _results;
+ reset();
+ _ref = $(".question-piece", this.element);
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ qp = _ref[_i];
+ if ($(qp).data('solution') === 'true') {
+ _results.push($(".true", qp).click());
+ } else {
+ _results.push($(".false", qp).click());
+ }
+ }
+ return _results;
+ };
+
+ return PrawdaFalsz;