实训临时一些优化

dev_ec
jingquan huang 6 years ago
parent eea7aae984
commit 3685c386db

@ -2,7 +2,7 @@
class ChallengesController < ApplicationController class ChallengesController < ApplicationController
layout "base_shixun" layout "base_shixun"
# 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位 # 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位
before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:index] # before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:index]
before_filter :check_authentication, :except => [:index] before_filter :check_authentication, :except => [:index]
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question, before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question,
:choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose] :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose]

@ -24,6 +24,14 @@ class Challenge < ActiveRecord::Base
scope :choose_type, lambda{where(st: 1)} scope :choose_type, lambda{where(st: 1)}
scope :practice_type, lambda{where(st: 0)} scope :practice_type, lambda{where(st: 0)}
def shixun_done_new
self.games.map{|game| game.status == 2 }.size
end
def shixun_running_new
self.games.map{|game| game.status != 2 }.size
end
def game_difficulty def game_difficulty
str = "简单" str = "简单"
case self.difficulty case self.difficulty

@ -73,8 +73,8 @@
</div> </div>
<div class="clearfix pl28"> <div class="clearfix pl28">
<span class="task-colspan"><%= shixun_done(@shixun, challenge.position).to_i %>&nbsp;人完成挑战</span> <span class="task-colspan"><%= challenge.shixun_done_new.to_i %>&nbsp;人完成挑战</span>
<span class="task-colspan"><%= shixun_running(@shixun, challenge.position).to_i %>&nbsp;人正在挑战</span> <span class="task-colspan"><%= challenge.shixun_running_new.to_i %>&nbsp;人正在挑战</span>
<% if challenge.st != 0 %> <% if challenge.st != 0 %>
<span class="task-colspan"><span class="colspan-grey">经验值&nbsp;<%= challenge.choose_score %></span></span> <span class="task-colspan"><span class="colspan-grey">经验值&nbsp;<%= challenge.choose_score %></span></span>
<% else %> <% else %>

Loading…
Cancel
Save