X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3ca26d2173a3c1e0d03508f0de049ab6928fe2dd..c63cb9e4a92378f9a630f95faa3d4d167e7aa8ec:/redakcja/static/edumed/js/edumed.coffee diff --git a/redakcja/static/edumed/js/edumed.coffee b/redakcja/static/edumed/js/edumed.coffee index 7c40bff3..6fce16bf 100644 --- a/redakcja/static/edumed/js/edumed.coffee +++ b/redakcja/static/edumed/js/edumed.coffee @@ -97,7 +97,12 @@ class Exercise extends Binding return [mandat, opt] show_score: (score) -> - $(".message", @element).text("Wynik: #{score[0]} / #{score[1]}") + $msg = $(".message", @element) + $msg.text("Wynik: #{score[0]} / #{score[1]}") + if score[0] == score[1] + $msg.addClass("maxscore") + else + $msg.removeClass("maxscore") draggable_equal: ($draggable1, $draggable2) -> @@ -124,6 +129,7 @@ class Exercise extends Binding $added.append('x
') $('.remove', $added).click (ev) => + @retry() if not ismultiple $($added.data('original')).removeClass('disabled').draggable('enable') @@ -369,7 +375,7 @@ class Zastap extends Exercise class Przyporzadkuj extends Exercise is_multiple: -> for qp in $(".question-piece", @element) - if $(qp).data('solution').split(/[ ,]+/).length > 1 + if $(qp).attr('data-solution').split(/[ ,]+/).length > 1 return true return false @@ -390,7 +396,7 @@ class Przyporzadkuj extends Exercise count = 0 all = 0 if not minimum - all = $(".subjects .question-piece", question).length + all = $(".subject .question-piece", question).length for pred in $(".predicate [data-predicate]", question) pn = $(pred).attr('data-predicate') @@ -425,7 +431,7 @@ class Przyporzadkuj extends Exercise for m in draggables $pr = $(".predicate [data-predicate=" + m + "]", question) $ph = $pr.find ".placeholder:visible" - @draggable_move $(qp), $ph, @multiple + @draggable_move $(qp), $ph.eq(0), @multiple @@ -434,16 +440,16 @@ class PrawdaFalsz extends Exercise super element for qp in $(".question-piece", @element) - $(".true", qp).click (ev) -> + $(".true", qp).click (ev) => ev.preventDefault() @retry() - $(this).closest(".question-piece").data("value", "true") - $(this).addClass('chosen').siblings('a').removeClass('chosen') - $(".false", qp).click (ev) -> + $(ev.target).closest(".question-piece").data("value", "true") + $(ev.target).addClass('chosen').siblings('a').removeClass('chosen') + $(".false", qp).click (ev) => ev.preventDefault() @retry() - $(this).closest(".question-piece").data("value", "false") - $(this).addClass('chosen').siblings('a').removeClass('chosen') + $(ev.target).closest(".question-piece").data("value", "false") + $(ev.target).addClass('chosen').siblings('a').removeClass('chosen') check_question: ->