+class Przyporzadkuj extends Exercise
+ is_multiple: ->
+ for qp in $(".question-piece", @element)
+ if $(qp).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
+ all = 0
+ if not minimum
+ all = $(".subjects .question-piece", question).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
+ @piece_incorrect qp
+
+ return [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, @multiple
+
+
+
+class PrawdaFalsz extends Exercise
+ constructor: (element) ->
+ super element
+
+ for qp in $(".question-piece", @element)
+ $(".true", qp).click (ev) ->
+ ev.preventDefault()
+ $(this).closest(".question-piece").data("value", "true")
+ $(this).addClass('chosen').siblings('a').removeClass('chosen')
+ $(".false", qp).click (ev) ->
+ ev.preventDefault()
+ $(this).closest(".question-piece").data("value", "false")
+ $(this).addClass('chosen').siblings('a').removeClass('chosen')
+
+
+ check_question: ->
+ all = 0
+ good = 0
+ for qp in $(".question-piece", @element)
+ if $(qp).data("solution").toString() == $(qp).data("value")
+ good += 1
+ @piece_correct qp
+ else
+ @piece_incorrect qp
+
+ all += 1
+
+ return [good, all]
+
+ show_solutions: ->
+ reset()
+ for qp in $(".question-piece", @element)
+ if $(qp).data('solution') == 'true'
+ $(".true", qp).click()
+ else
+ $(".false", qp).click()
+