corrected can_submit to account for finish_later

This commit is contained in:
Mark Moser 2016-08-01 19:51:04 -05:00
parent f06aed6541
commit f076db259f

View File

@ -18,7 +18,9 @@ class QuizStatus
end
def can_submit
on_summary && candidate.answered_questions.count == candidate.questions.count
on_summary &&
no_finish_later &&
candidate.answered_questions.count == candidate.questions.count
end
def progress
@ -28,6 +30,17 @@ class QuizStatus
(answs / total * 100).round.to_i
end
def no_finish_later
sql = %(select count(a.id) todos
from answers a
inner join questions q on q.id = a.question_id
where q.input_type = 'live_code'
and a.answer like "%later: 'true'%"
and a.candidate_id = #{candidate.id})
result = ActiveRecord::Base.connection.exec_query(sql).to_hash.first
result['todos'].zero?
end
def current_question_id
sql = "select q.id question_id
from candidates c