fix bug calculating quiz completion with inactive questions
This commit is contained in:
parent
87e0406a03
commit
35cbe68f00
@ -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?
|
||||
|
29
test/fixtures/questions.yml
vendored
29
test/fixtures/questions.yml
vendored
@ -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.'
|
||||
|
Loading…
Reference in New Issue
Block a user