From 12cebcb2522040e6ddade9043eeecbb2327be2d7 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Fri, 29 Sep 2017 21:10:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E5=91=98=E7=BB=9F=E8=AE=A1=E6=9D=BF?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E9=87=91=E5=B8=81=E5=80=BC=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=85=B6=E5=AE=83=E9=97=AE=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82tip=E6=A0=B7=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 22 +++++++----- app/models/myshixun.rb | 12 +++++++ app/views/challenges/_content_list.html.erb | 2 +- .../shixuns/_statistics_student_list.html.erb | 36 ++++++++++++++++--- app/views/shixuns/index.html.erb | 6 ++-- app/views/shixuns/settings.html.erb | 4 +-- app/views/users/_course_boardlist.html.erb | 6 ++-- app/views/users/show.html.erb | 2 +- public/stylesheets/css/edu-public.css | 1 + 9 files changed, 68 insertions(+), 23 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 6ce0e4c63..8ec389b5f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -16,14 +16,20 @@ class ShixunsController < ApplicationController def statistics_students - @statistics = @shixun.myshixuns.order("created_at desc") - @statistics_count = @statistics.count - @limit = 10 - @is_remote = true - @statistic_pages = Paginator.new @statistics_count, @limit, params['page'] || 1 - @offset ||= @statistic_pages.offset - @statistics = paginateHelper @statistics, @limit - + pub_shixun = ApplyAction.where(:container_type => "ApplyShixun", :status => 1, :container_id => @shixun.id).last + if pub_shixun.present? + updated_at = pub_shixun.updated_at + @statistics = @shixun.myshixuns.select{|myshixun| myshixun.updated_at > updated_at} + @statistics = @statistics.map(&:id) + @statistics = Myshixun.where(:id => @statistics).order("created_at desc") + #@statistics = @shixun.myshixuns.where("created_at > #{updated_at}").order("created_at desc") + @statistics_count = @statistics.count + @limit = 10 + @is_remote = true + @statistic_pages = Paginator.new @statistics_count, @limit, params['page'] || 1 + @offset ||= @statistic_pages.offset + @statistics = paginateHelper @statistics, @limit + end end diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index ace51c51f..1619b9313 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -54,6 +54,18 @@ class Myshixun < ActiveRecord::Base score end + def total_gold + score = 0 + self.games.each do |game| + if game.status == 2 + total_gold =game.answer_open? ? -game.challenge.score.to_i : game.final_score.to_i + score += total_gold + end + end + score + end + + # id 转换成 identifier def to_param identifier diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index cda61ccd4..16b99b5b6 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -71,7 +71,7 @@ <% when 2 %> 已完成 <% when 3,nil %> - 未开始 + 未开始 <% end %> <% end %> diff --git a/app/views/shixuns/_statistics_student_list.html.erb b/app/views/shixuns/_statistics_student_list.html.erb index 2bad02525..566625da9 100644 --- a/app/views/shixuns/_statistics_student_list.html.erb +++ b/app/views/shixuns/_statistics_student_list.html.erb @@ -14,31 +14,57 @@
| <%= link_to image_tag(url_to_avatar(statistics.owner), :width => "36", :height => "36", :alt => "头像", :style => "border-radius:18px;margin:15px 0 0 10px;"), user_path(statistics.owner), :target => '_blank', :class => ""%> | -+ | <%= link_to statistics.owner.try(:show_name), user_path(statistics.owner), :class => "panel-table-name hide fl color-black" %> | <%= format_time(statistics.created_at) %> 开启 |
|
- + <% if statistics.total_score == 0 || statistics.total_score.nil? %> -- <% else %> - + <%= statistics.total_score.to_i %> 经验值 + +<%= statistics.total_score.to_i %> 经验值 + <% end %> + + | ++ + <% if statistics.total_gold == 0 || statistics.total_gold.nil? %> + -- + <% else %> + <% if statistics.total_gold < 0 %> + <%= statistics.total_gold %> 金币 + <% else %> + +<%= statistics.total_gold %> 金币 + <% end %> <% end %> | diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index fc6235d62..6c6b6d9a3 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -98,7 +98,7 @@