公共方法封装
This commit is contained in:
parent
072c9550fc
commit
48913a3c8c
|
@ -33,6 +33,33 @@ module ApplicationHelper
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
|
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
|
||||||
|
|
||||||
|
|
||||||
|
# 定义实训相关方法
|
||||||
|
# myshixun 最高分
|
||||||
|
def top_score shixun
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# 正在进行中任务
|
||||||
|
def shixun_running shixun
|
||||||
|
Myshixun.where(:parent_id => shixun, :status => 0).count
|
||||||
|
end
|
||||||
|
|
||||||
|
# 已完成任务
|
||||||
|
def shixun_done shixun
|
||||||
|
Myshixun.where(:parent_id => shixun, :status => 1).count
|
||||||
|
end
|
||||||
|
|
||||||
|
# 测评次数
|
||||||
|
def shixun_exec_count shixun
|
||||||
|
Game.find_by_sql("SELECT count(*) FROM `outputs` op, `games` g, `myshixuns` m where op.game_id = g.id and m.parent_id = '#{shixun.id}';")
|
||||||
|
end
|
||||||
|
|
||||||
|
# 实训平均分
|
||||||
|
def shixun_avg
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# def user_blogs_path(resource,parameters={})
|
# def user_blogs_path(resource,parameters={})
|
||||||
# super
|
# super
|
||||||
# end
|
# end
|
||||||
|
|
|
@ -3,7 +3,6 @@ class Game < ActiveRecord::Base
|
||||||
attr_accessible :description, :myshixun_id, :stage, :subject, :user_id, :status, :ready_knowledge, :task_pass, :answer, :score
|
attr_accessible :description, :myshixun_id, :stage, :subject, :user_id, :status, :ready_knowledge, :task_pass, :answer, :score
|
||||||
belongs_to :myshixun,:touch=> true
|
belongs_to :myshixun,:touch=> true
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :game_comments, :dependent => :destroy
|
|
||||||
has_many :outputs, :dependent => :destroy
|
has_many :outputs, :dependent => :destroy
|
||||||
has_many :test_sets, :dependent => :destroy
|
has_many :test_sets, :dependent => :destroy
|
||||||
has_many :challenge_samples, :dependent => :destroy
|
has_many :challenge_samples, :dependent => :destroy
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
</p>
|
</p>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<p class="ml15 mt15 color-grey">
|
<p class="ml15 mt15 color-grey">
|
||||||
<span class=" mr10">正在挑战:129</span>
|
<span class=" mr10">正在挑战:<%= shixun_running @shixun %></span>
|
||||||
<span class=" mr10">完成挑战:1.6万</span>
|
<span class=" mr10">完成挑战:<%= shixun_done @shixun %></span>
|
||||||
<span class=" mr10">最佳表现:98分</span>
|
<span class=" mr10">最佳表现:98分</span>
|
||||||
<span class=" mr10">测评次数:3次</span>
|
<span class=" mr10">测评次数:3次</span>
|
||||||
<span class=" mr10">平均表现:80分 </span>
|
<span class=" mr10">平均表现:80分 </span>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddStatusToMyshixuns < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :myshixuns, :status, :integer, :default => 0
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue