diff --git a/app/workers/quiz_status.rb b/app/workers/quiz_status.rb index bca6a87..8245c8e 100644 --- a/app/workers/quiz_status.rb +++ b/app/workers/quiz_status.rb @@ -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