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 @@ <% @statistics.each do |statistics| %> + <% if had_passed_changllenge_count(@shixun, statistics.owner) == -1 %> + <% coefficient = 1%> + <% elsif (had_passed_changllenge_count(@shixun, statistics.owner).class == Array) %> + <% coefficient = had_passed_changllenge_count(@shixun,statistics.owner)[0].to_i*2 - 1%> + <% else %> + <% coefficient = had_passed_changllenge_count(@shixun, statistics.owner)*2%> + <% 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 @@
  • 所有状态 -
  • <%= 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) %> 开启
    - +
    - 挑战至第<%= statistics.current_stage %>关/共<%= statistics.games.count %>关 + <% if had_passed_changllenge_count(@shixun, statistics.owner) == -1 %> + 已挑战至 第1关 / 共<%= @shixun.challenges.count %>关 + <% elsif (had_passed_changllenge_count(@shixun, statistics.owner).class == Array) %> + 已挑战至 第<%= had_passed_changllenge_count(@shixun,statistics.owner)[0].to_i %>关 / 共<%= @shixun.challenges.count %>关 + <% else %> + 已完成至 第<%= had_passed_changllenge_count(@shixun, statistics.owner) %>关 / 共<%= @shixun.challenges.count %>关 + <% end %>
    - + <% 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 %>