|
|
|
@ -16,7 +16,7 @@ class QuestionsController < ApplicationController |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def result |
|
|
|
def score |
|
|
|
|
|
|
|
not_found if result_node.blank? or current_player.answers.count < questions.size |
|
|
|
|
|
|
|
@ -31,8 +31,19 @@ class QuestionsController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
people_score = questions.count - planet_score |
|
|
|
score_diff = people_score - planet_score |
|
|
|
current_player.update(score: planet_score) |
|
|
|
|
|
|
|
redirect_to url_for(action: 'result') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def result |
|
|
|
not_found if result_node.blank? or current_player.score.blank? |
|
|
|
|
|
|
|
people_score = questions.count - current_player.score |
|
|
|
score_diff = people_score - current_player.score |
|
|
|
|
|
|
|
attachment_index = case |
|
|
|
when score_diff >= 2 |
|
|
|
@ -43,13 +54,6 @@ class QuestionsController < ApplicationController |
|
|
|
2 # Balanced |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# logger.info(">>> score_diff #{score_diff}") |
|
|
|
# logger.info(">>> people_score #{people_score}") |
|
|
|
# logger.info(">>> planet_score #{planet_score}") |
|
|
|
# logger.info(">>> attachment_index #{attachment_index}") |
|
|
|
|
|
|
|
@result_attachment = result_node.attachments.offset(attachment_index).first |
|
|
|
@stats_attachment = result_node.attachments.offset(3).first |
|
|
|
|
|
|
|
|