+ 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;
+
+ })(Excercise);
+
+ 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;
+
+ })(Excercise);
+