fix bug calculating quiz completion with inactive questions

This commit is contained in:
Mark Moser 2016-11-11 14:26:07 -06:00
parent 87e0406a03
commit 35cbe68f00
2 changed files with 33 additions and 3 deletions

View File

@ -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?

View File

@ -112,6 +112,35 @@ fed10:
sort: 9
active: true
fed11:
quiz: fed
question: nope, nope nope?
category: Performance
input_type: checkbox
input_options:
- "Live long and prosper"
- "Who ya gonna call?"
- "Who you calling Scruffy?"
- "J.J. Abrams"
- "wibbly wobbly, timey wimey"
sort: 91
active: false
fed12:
quiz: fed
question: yet, another old fake question
category: Performance
input_type: checkbox
input_options:
- "Live long and prosper"
- "Who ya gonna call?"
- "Who you calling Scruffy?"
- "J.J. Abrams"
- "wibbly wobbly, timey wimey"
sort: 91
active: false
admin1:
quiz: admin
question: 'You have a question you want to ask.'