From ab3cfc69bd725ed7bae877ba0d3e0128dfd53596 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 14 Sep 2017 18:59:41 +0800 Subject: [PATCH] =?UTF-8?q?TPI=E5=8D=95=E9=80=89=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=85=A8=E9=83=A8=E5=88=97=E8=A1=A8=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 8 ++++++++ app/views/games/_games_list.html.erb | 15 +++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 128a64d8b..64d87dca2 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -49,6 +49,14 @@ class Challenge < ActiveRecord::Base return score end + def choose_tags_num + num = 0 + self.challenge_chooses.each do |choose| + num += choose.challenge_tags.count + end + return num + end + def next_challenge challenge_count = Challenge.where(:shixun_id => self.shixun_id).count render_404 if self.position ==challenge_count diff --git a/app/views/games/_games_list.html.erb b/app/views/games/_games_list.html.erb index 29e3f87cf..95c954040 100644 --- a/app/views/games/_games_list.html.erb +++ b/app/views/games/_games_list.html.erb @@ -37,10 +37,16 @@
- <% if game.try(:status) == 0 || game.try(:status) == 1 || game.try(:status) == 3 %> - 经验值<%= challenge.score %> - 金币<%= challenge.score %> - 技能标签<%= challenge.challenge_tags.count %> + <% if game.try(:status) != 2 %> + <% if challenge.st == 0 %> + 经验值<%= challenge.score %> + 金币<%= challenge.score %> + 技能标签<%= challenge.challenge_tags.count %> + <% else %> + 经验值<%= challenge.choose_score %> + 金币<%= challenge.choose_score %> + 技能标签<%= challenge.choose_tags_num %> + <% end %> <% elsif game.try(:status) == 2 %> <% final_score = (game.answer_open? || @myshixun.shixun.status <= 1) ? 0 : game.final_score.to_i %> <% gold_score = @myshixun.shixun.status <= 1 ? 0 : (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) %> @@ -48,6 +54,7 @@ 金币 ml5"><%= gold_score < 0 ? gold_score : "+"+gold_score.to_s %> 技能标签+<%= (game.answer_open? || @myshixun.shixun.status <= 1) ? 0 : challenge.challenge_tags.count %> <% end %> +