+class Przyporzadkuj extends Exercise
+ is_multiple: ->
+ for qp in $(".question-piece", @element)
+ if $(qp).attr('data-solution').split(/[ ,]+/).length > 1
+ return true
+ return false
+
+ constructor: (element) ->
+ super element
+
+ @multiple = @is_multiple()
+
+ @dragging @multiple, true
+
+ draggable_equal: (d1, d2) ->
+ return d1.data("no") == d2.data("no")
+
+
+ check_question: (question) ->
+ # subjects placed in predicates
+ minimum = $(question).data("minimum")
+ count = 0
+ bad_count = 0
+ all = 0
+ if not minimum
+ self = this
+ $(".subject .question-piece", question).each (i, el) ->
+ v = self.get_value_optional_list el, 'solution'
+ mandatory = v[0]
+ all += mandatory.length
+
+ for pred in $(".predicate [data-predicate]", question)
+ pn = $(pred).attr('data-predicate')
+ #if minimum?
+ # all += minimum
+
+ for qp in $(".question-piece", pred)
+ v = @get_value_optional_list qp, 'solution'
+ mandatory = v[0]
+ optional = v[1]
+
+ if mandatory.indexOf(pn) >= 0 or (minimum and optional.indexOf(pn) >= 0)
+ count += 1
+ @piece_correct qp
+ else
+ bad_count += 1
+ @piece_incorrect qp
+
+ return [count, bad_count, all]
+
+ solve_question: (question) ->
+ minimum = $(question).data("min")
+
+ for qp in $(".subject .question-piece", question)
+ v = @get_value_optional_list qp, 'solution'
+ mandatory = v[0]
+ optional = v[1]
+
+ if minimum
+ draggables = mandatory.count(optional)[0...minimum]
+ else
+ draggables = mandatory
+ for m in draggables
+ $pr = $(".predicate [data-predicate=" + m + "]", question)
+ $ph = $pr.find ".placeholder:visible"
+ @draggable_move $(qp), $ph.eq(0), @multiple
+
+
+
+class PrawdaFalsz extends Exercise
+ constructor: (element) ->
+ super element
+
+ for qp in $(".question-piece", @element)
+ $(".true", qp).click (ev) =>
+ ev.preventDefault()
+ @retry()
+ $(ev.target).closest(".question-piece").data("value", "true")
+ $(ev.target).addClass('chosen').siblings('a').removeClass('chosen')
+ $(".false", qp).click (ev) =>
+ ev.preventDefault()
+ @retry()
+ $(ev.target).closest(".question-piece").data("value", "false")
+ $(ev.target).addClass('chosen').siblings('a').removeClass('chosen')
+
+
+ check_question: ->
+ all = 0
+ good = 0
+ bad = 0
+ for qp in $(".question-piece", @element)
+ if $(qp).data("solution").toString() == $(qp).data("value")
+ good += 1
+ @piece_correct qp
+ else
+ bad += 1
+ @piece_incorrect qp
+
+ all += 1
+
+ return [good, bad, all]
+
+ show_solutions: ->
+ @reset()
+ for qp in $(".question-piece", @element)
+ if $(qp).data('solution') == true
+ $(".true", qp).click()
+ else
+ $(".false", qp).click()
+