1 // Generated by CoffeeScript 1.4.0
3 var $, Binding, EduModule, Excercise, Wybor, excercise,
4 __hasProp = {}.hasOwnProperty,
5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
9 Binding = (function() {
11 function Binding(handler, element) {
12 this.handler = handler;
13 this.element = element;
14 $(this.element).data(this.handler, this);
21 EduModule = (function(_super) {
23 __extends(EduModule, _super);
25 function EduModule(element) {
27 EduModule.__super__.constructor.call(this, 'edumodule', element);
28 $("[name=teacher-toggle]").change(function(ev) {
29 if ($(ev.target).is(":checked")) {
30 return $(".teacher", _this.element).addClass("show");
32 return $(".teacher", _this.element).removeClass("show");
41 Excercise = (function(_super) {
43 __extends(Excercise, _super);
45 function Excercise(element) {
47 Excercise.__super__.constructor.call(this, 'excercise', element);
48 $(".check", this.element).click(function() {
51 $('.solutions', this.element).click(function() {
52 return _this.show_solutions();
60 Wybor = (function(_super) {
62 __extends(Wybor, _super);
64 function Wybor(element) {
65 Wybor.__super__.constructor.call(this, element);
68 Wybor.prototype.check = function() {
72 $(".question").each(function(i, question) {
73 return scores.push(_this.check_question(question));
76 $.each(scores, function(i, s) {
78 return score[1] += s[1];
80 return this.show_score(score);
83 Wybor.prototype.check_question = function(question) {
84 var all, good, solution,
88 solution = $(question).attr('data-solution').split(',').map($.trim).map(function(x) {
91 $(".question-piece", question).each(function(i, qpiece) {
92 var is_checked, piece_no, should_be_checked;
93 piece_no = parseInt($(qpiece).attr('data-no'));
94 should_be_checked = solution.indexOf(piece_no) >= 0;
95 is_checked = $("input", qpiece).is(":checked");
96 if (should_be_checked) {
100 if (should_be_checked) {
102 return _this.piece_correct(qpiece);
104 return _this.piece_incorrect(qpiece);
107 return $(qpiece).removeClass("correct,incorrect");
113 Wybor.prototype.piece_correct = function(qpiece) {
114 return $(qpiece).removeClass('incorrect').addClass('correct');
117 Wybor.prototype.piece_incorrect = function(qpiece) {
118 return $(qpiece).removeClass('correct').addClass('incorrect');
121 Wybor.prototype.show_solutions = function() {};
123 Wybor.prototype.show_score = function(score) {
124 return $(".message", this.element).text("Wynik: " + score[0] + " / " + score[1]);
131 excercise = function(ele) {
136 cls = es[$(ele).attr('data-type')];
141 'EduModule': EduModule
144 $(document).ready(function() {
145 new EduModule($("#book-text"));
146 return $(".excercise").each(function(i, el) {
147 return excercise(this);