fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
parse dublincore
[redakcja.git]
/
redakcja
/
static
/
edumed
/
js
/
edumed.coffee
diff --git
a/redakcja/static/edumed/js/edumed.coffee
b/redakcja/static/edumed/js/edumed.coffee
index
59430a2
..
6fce16b
100644
(file)
--- a/
redakcja/static/edumed/js/edumed.coffee
+++ b/
redakcja/static/edumed/js/edumed.coffee
@@
-28,15
+28,18
@@
class Exercise extends Binding
$(ev.target).next(".retry").show()
$(ev.target).hide()
$(".retry", @element).click (ev) =>
$(ev.target).next(".retry").show()
$(ev.target).hide()
$(".retry", @element).click (ev) =>
- $(".correct, .incorrect", @element).removeClass("correct incorrect")
- $(ev.target).prev(".check").show()
- $(ev.target).hide()
+ @retry()
$('.solutions', @element).click =>
@show_solutions()
$(".comment", @element).show()
$('.reset', @element).click =>
@reset()
$('.solutions', @element).click =>
@show_solutions()
$(".comment", @element).show()
$('.reset', @element).click =>
@reset()
+ retry: ->
+ $(".correct, .incorrect", @element).removeClass("correct incorrect")
+ $(".check", @element).show()
+ $(".retry", @element).hide()
+
reset: ->
$(@element).html($(@element).data('exercise-html'))
exercise @element
reset: ->
$(@element).html($(@element).data('exercise-html'))
exercise @element
@@
-94,7
+97,12
@@
class Exercise extends Binding
return [mandat, opt]
show_score: (score) ->
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) ->
draggable_equal: ($draggable1, $draggable2) ->
@@
-119,8
+127,9
@@
class Exercise extends Binding
if $added.is(".add-li")
$added.wrap("<li/>")
if $added.is(".add-li")
$added.wrap("<li/>")
- $added.append('<span class="remove">x</span>')
+ $added.append('<span class="remove">x</span>
<div class="clr"></div>
')
$('.remove', $added).click (ev) =>
$('.remove', $added).click (ev) =>
+ @retry()
if not ismultiple
$($added.data('original')).removeClass('disabled').draggable('enable')
if not ismultiple
$($added.data('original')).removeClass('disabled').draggable('enable')
@@
-136,6
+145,7
@@
class Exercise extends Binding
draggable_opts =
revert: 'invalid'
helper: 'clone'
draggable_opts =
revert: 'invalid'
helper: 'clone'
+ start: @retry
$(".draggable", question).draggable(draggable_opts)
self = this
$(".draggable", question).draggable(draggable_opts)
self = this
@@
-188,6
+198,7
@@
class Exercise extends Binding
class Wybor extends Exercise
constructor: (element) ->
super element
class Wybor extends Exercise
constructor: (element) ->
super element
+ $(".question-piece input", element).change(@retry);
check_question: (question) ->
check_question: (question) ->
@@
-227,14
+238,14
@@
class Wybor extends Exercise
else
should_be_checked = solution.indexOf(piece_no) >= 0
console.log("check " + $("input[type=checkbox]", qpiece).attr("id") + " -> " + should_be_checked)
else
should_be_checked = solution.indexOf(piece_no) >= 0
console.log("check " + $("input[type=checkbox]", qpiece).attr("id") + " -> " + should_be_checked)
- $("input[type=checkbox]", qpiece).prop 'checked', should_be_checked
+ $("input[type=checkbox]
,input[type=radio]
", qpiece).prop 'checked', should_be_checked
class Uporzadkuj extends Exercise
constructor: (element) ->
super element
class Uporzadkuj extends Exercise
constructor: (element) ->
super element
- $('ol, ul', @element).sortable({ items: "> li" })
+ $('ol, ul', @element).sortable({ items: "> li"
, start: @retry
})
check_question: (question) ->
positions = @get_value_list(question, 'original', true)
check_question: (question) ->
positions = @get_value_list(question, 'original', true)
@@
-364,7
+375,7
@@
class Zastap extends Exercise
class Przyporzadkuj extends Exercise
is_multiple: ->
for qp in $(".question-piece", @element)
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
return true
return false
@@
-385,7
+396,7
@@
class Przyporzadkuj extends Exercise
count = 0
all = 0
if not minimum
count = 0
all = 0
if not minimum
- all = $(".subject
s
.question-piece", question).length
+ all = $(".subject .question-piece", question).length
for pred in $(".predicate [data-predicate]", question)
pn = $(pred).attr('data-predicate')
for pred in $(".predicate [data-predicate]", question)
pn = $(pred).attr('data-predicate')
@@
-420,7
+431,7
@@
class Przyporzadkuj extends Exercise
for m in draggables
$pr = $(".predicate [data-predicate=" + m + "]", question)
$ph = $pr.find ".placeholder:visible"
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
@@
-429,14
+440,16
@@
class PrawdaFalsz extends Exercise
super element
for qp in $(".question-piece", @element)
super element
for qp in $(".question-piece", @element)
- $(".true", qp).click (ev)
-
>
+ $(".true", qp).click (ev)
=
>
ev.preventDefault()
ev.preventDefault()
- $(this).closest(".question-piece").data("value", "true")
- $(this).addClass('chosen').siblings('a').removeClass('chosen')
- $(".false", qp).click (ev) ->
+ @retry()
+ $(ev.target).closest(".question-piece").data("value", "true")
+ $(ev.target).addClass('chosen').siblings('a').removeClass('chosen')
+ $(".false", qp).click (ev) =>
ev.preventDefault()
ev.preventDefault()
- $(this).closest(".question-piece").data("value", "false")
- $(this).addClass('chosen').siblings('a').removeClass('chosen')
+ @retry()
+ $(ev.target).closest(".question-piece").data("value", "false")
+ $(ev.target).addClass('chosen').siblings('a').removeClass('chosen')
check_question: ->
check_question: ->
@@
-454,9
+467,9
@@
class PrawdaFalsz extends Exercise
return [good, all]
show_solutions: ->
return [good, all]
show_solutions: ->
- reset()
+
@
reset()
for qp in $(".question-piece", @element)
for qp in $(".question-piece", @element)
- if $(qp).data('solution') ==
'true'
+ if $(qp).data('solution') ==
true
$(".true", qp).click()
else
$(".false", qp).click()
$(".true", qp).click()
else
$(".false", qp).click()
@@
-488,4
+501,4
@@
$(document).ready () ->
new EduModule($("#book-text"))
$(".exercise").each (i, el) ->
new EduModule($("#book-text"))
$(".exercise").each (i, el) ->
- exercise(this)
\ No newline at end of file
+ exercise(this)