fix bug calculating quiz completion with inactive questions
This commit is contained in:
@ -11,7 +11,7 @@ class QuizStatus
|
||||
end
|
||||
|
||||
def on_summary
|
||||
candidate.submitted_answers.count == candidate.questions.count
|
||||
candidate.submitted_answers.count == candidate.questions.where(active: true).count
|
||||
end
|
||||
|
||||
delegate :completed, to: :candidate
|
||||
@ -19,12 +19,12 @@ class QuizStatus
|
||||
def can_submit
|
||||
on_summary &&
|
||||
no_finish_later &&
|
||||
candidate.answered_questions.count == candidate.questions.count
|
||||
candidate.answered_questions.count == candidate.questions.where(active: true).count
|
||||
end
|
||||
|
||||
def progress
|
||||
answs = candidate.answered_questions.count.to_f
|
||||
total = candidate.quiz.questions.count.to_f
|
||||
total = candidate.quiz.questions.where(active: true).count.to_f
|
||||
|
||||
(answs / total * 100).round.to_i
|
||||
end
|
||||
@ -35,6 +35,7 @@ class QuizStatus
|
||||
inner join questions q on q.id = a.question_id
|
||||
where q.input_type = 'live_code'
|
||||
and a.answer like "%later: 'true'%"
|
||||
and q.active = true
|
||||
and a.candidate_id = #{candidate.id})
|
||||
result = ActiveRecord::Base.connection.exec_query(sql).to_hash.first
|
||||
result['todos'].zero?
|
||||
|
Reference in New Issue
Block a user