fixing issue with reverse questions

This commit is contained in:
Jared Cosulich 2017-12-08 09:08:12 -05:00
parent 4f2e779dd0
commit 5ebb5de439
2 changed files with 2 additions and 2 deletions

View file

@ -67,7 +67,7 @@ class Attempt < ApplicationRecord
end
def answer_index_with_reverse
return 5 - answer_index if question.reverse?
return 6 - answer_index if question.reverse?
return answer_index
end

View file

@ -19,7 +19,7 @@ class SchoolCategory < ApplicationRecord
for_school(school).
select('count(attempts.id) as attempt_count').
select('count(attempts.answer_index) as response_count').
select('sum(case when questions.reverse then 5 - attempts.answer_index else attempts.answer_index end) as answer_index_total')[0]
select('sum(case when questions.reverse then 6 - attempts.answer_index else attempts.answer_index end) as answer_index_total')[0]
return {
attempt_count: attempt_data.attempt_count || 0,