+ Exercise.prototype.show_solutions = function() {
+ var _this = this;
+ this.reset();
+ return $(".question", this.element).each(function(i, question) {
+ return _this.solve_question(question);
+ });
+ };
+
+ Exercise.prototype.get_value_list = function(elem, data_key, numbers) {
+ var vl;
+ vl = $(elem).attr("data-" + data_key).split(/[ ,]+/).map($.trim);
+ if (numbers) {
+ vl = vl.map(function(x) {
+ return parseInt(x);
+ });
+ }
+ return vl;
+ };
+
+ Exercise.prototype.get_value_optional_list = function(elem, data_key) {
+ var mandat, opt, v, vals, _i, _len;
+ vals = this.get_value_list(elem, data_key);
+ mandat = [];
+ opt = [];
+ for (_i = 0, _len = vals.length; _i < _len; _i++) {
+ v = vals[_i];
+ if (v.slice(-1) === "?") {
+ opt.push(v.slice(0, -1));
+ } else {
+ mandat.push(v);
+ }
+ }
+ return [mandat, opt];
+ };
+
+ Exercise.prototype.show_score = function(score) {
+ var $msg;
+ $msg = $(".message", this.element);
+ $msg.text("Wynik: " + score[0] + " / " + score[2]);
+ if (score[0] >= score[2] && score[1] === 0) {
+ return $msg.addClass("maxscore");
+ } else {
+ return $msg.removeClass("maxscore");
+ }
+ };
+
+ Exercise.prototype.draggable_equal = function($draggable1, $draggable2) {
+ return false;
+ };
+
+ Exercise.prototype.draggable_accept = function($draggable, $droppable) {
+ var d, dropped, _i, _len;
+ dropped = $droppable.closest("ul, ol").find(".draggable");
+ for (_i = 0, _len = dropped.length; _i < _len; _i++) {
+ d = dropped[_i];
+ if (this.draggable_equal($draggable, $(d))) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ Exercise.prototype.draggable_move = function($draggable, $placeholder, ismultiple) {
+ var $added,
+ _this = this;
+ $added = $draggable.clone();
+ $added.data("original", $draggable.get(0));
+ if (!ismultiple) {
+ $draggable.addClass('disabled').draggable('disable');
+ }
+ $placeholder.after($added);
+ if (!$placeholder.hasClass('multiple')) {
+ $placeholder.hide();
+ }
+ if ($added.is(".add-li")) {
+ $added.wrap("<li/>");
+ }
+ $added.append('<span class="remove">x</span><div class="clr"></div>');
+ return $('.remove', $added).click(function(ev) {
+ _this.retry();
+ if (!ismultiple) {
+ $($added.data('original')).removeClass('disabled').draggable('enable');
+ }
+ if ($added.is(".add-li")) {
+ $added = $added.closest('li');
+ }
+ $added.prev(".placeholder:not(.multiple)").show();
+ return $added.remove();