From f076db259fde4c236c6cbf5cda4ffb9e2a93efc6 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Mon, 1 Aug 2016 19:51:04 -0500 Subject: [PATCH] corrected can_submit to account for finish_later --- app/workers/quiz_status.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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