5 constructor: (@handler, @element) ->
6 $(@element).data(@handler, this)
9 class EduModule extends Binding
10 constructor: (element) ->
11 super 'edumodule', element
13 $("[name=teacher-toggle]").change (ev) =>
14 if $(ev.target).is(":checked")
15 $(".teacher", @element).addClass "show"
17 $(".teacher", @element).removeClass "show"
21 class Excercise extends Binding
22 constructor: (element) ->
23 super 'excercise', element
25 $(".check", @element).click =>
27 $('.solutions', @element).click =>
31 class Wybor extends Excercise
32 constructor: (element) ->
37 $(".question").each (i, question) =>
38 scores.push(@check_question question)
41 $.each scores, (i, s) ->
46 check_question: (question) ->
49 solution = $(question).attr('data-solution').split(',').map($.trim).map((x)->parseInt(x))
50 $(".question-piece", question).each (i, qpiece) =>
51 piece_no = parseInt $(qpiece).attr 'data-no'
52 should_be_checked = solution.indexOf(piece_no) >= 0
53 is_checked = $("input", qpiece).is(":checked")
63 @piece_incorrect qpiece
65 $(qpiece).removeClass("correct,incorrect")
69 piece_correct: (qpiece) ->
70 $(qpiece).removeClass('incorrect').addClass('correct')
72 piece_incorrect: (qpiece) ->
73 $(qpiece).removeClass('correct').addClass('incorrect')
78 show_score: (score) ->
79 $(".message", @element).text("Wynik: #{score[0]} / #{score[1]}")
89 cls = es[$(ele).attr('data-type')]
94 'EduModule': EduModule
99 $(document).ready () ->
100 new EduModule($("#book-text"))
102 $(".excercise").each (i, el) ->