$(".question", @element).each (i, question) =>
@solve_question question
+ get_answers: ->
+ answers = []
+ $('.question', @element).each (i, question) =>
+ answers.push(@get_answer question)
+ return answers
+
# Parses a list of values, separated by space or comma.
# The list is read from data attribute of elem using data_key
# Returns a list with elements
console.log("check " + $("input[type=checkbox]", qpiece).attr("id") + " -> " + should_be_checked)
$("input[type=checkbox],input[type=radio]", qpiece).prop 'checked', should_be_checked
+ get_answer: (question) ->
+ answer = []
+ $('.question-piece', question).each (i, qpiece) =>
+ $qpiece = $(qpiece)
+ if $("input[type=checkbox],input[type=radio]", qpiece).is(':checked')
+ answer.push($qpiece.attr('data-name'))
+ return answer
class Uporzadkuj extends Exercise
for p in pkts
parent.prepend(p)
+ get_answer: (question) ->
+ answer = []
+ $(".question-piece", @element).each (i, qpiece) =>
+ answer.push($(qpiece).attr('data-pos'))
+ return answer
+
# XXX propozycje="1/0"
class Luki extends Exercise
draggable_equal: (d1, d2) ->
return d1.data("no") == d2.data("no")
+ draggable_accept: ($draggable, $droppable) ->
+ dropped = $droppable.closest("ul, ol").find(".draggable")
+ return (super $draggable, $droppable) && dropped.length == 0
check_question: (question) ->
# subjects placed in predicates
$ph = $pr.find ".placeholder:visible"
@draggable_move $(qp), $ph.eq(0), @multiple
+ get_answer: (question) ->
+ answer = {}
+ $(".predicate [data-predicate]", question).each (i, subjects) =>
+ predicate = $(subjects).attr('data-predicate')
+ answer[predicate] = []
+ $('.question-piece', subjects).each (i, qpiece) =>
+ $qpiece = $(qpiece)
+ answer[predicate].push($qpiece.attr('data-id'))
+ return answer
class PrawdaFalsz extends Exercise
else
$(".false", qp).click()
+ get_answer: (question) ->
+ answer = []
+ $(".question-piece", @element).each (i, qpiece) =>
+ answer.push($(qpiece).data('value') || '-')
+ return answer
##########