This commit is contained in:
cxt 2017-04-01 10:55:46 +08:00
parent a4be0daaf1
commit 076c241d10
62 changed files with 758 additions and 3304 deletions

View File

@ -3,18 +3,14 @@ class ChallengesController < ApplicationController
layout "base_shixun"
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build]
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy]
before_filter :authorize_tpi, :only => [:new, :create]
before_filter :build_challege_from_params, :only => [:new, :create]
before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :show, :edit, :new]
before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :show, :edit, :new, :create]
before_filter :query_challeges, :only => [:show, :edit, :update]
# before_filter :is_members, :only => [:show, :edit]
before_filter :find_shixun_language, :only => [:show, :new, :edit]
include ApplicationHelper
def new
unless @shixun.parent_id.nil?
return render_403
end
# 顶部导航
@project_menu_type = 11
respond_to do |format|
@ -91,9 +87,9 @@ class ChallengesController < ApplicationController
respond_to do |format|
if @challenge.update_attributes(params[:challenge])
ActiveRecord::Base.transaction do
@challenge_samples.destroy unless @challenge_samples.blank?
@test_sets.destroy unless @test_sets.blank?
@challenge_tags.destroy unless @challenge_tags.blank?
@challenge_samples.delete_all unless @challenge_samples.blank?
@test_sets.delete_all unless @test_sets.blank?
@challenge_tags.delete_all unless @challenge_tags.blank?
if params[:sample][:input].length > 0
params[:sample][:input].each_with_index do |value, index|
unless (value == params[:sample][:output][index] && value.blank?)
@ -125,7 +121,6 @@ class ChallengesController < ApplicationController
def index_down
# @challenges = @shixun.challenges
next_challenge = @challenge.next_challenge
position = @challenge.position
@challenge.update_attribute(:position, (position + 1))
@ -160,48 +155,7 @@ class ChallengesController < ApplicationController
end
end
def game_build_result
# status = params[:status].to_i
# task_id = params[:taskId]
# message = Base64.decode64(params[:msg]) unless params[:msg].blank?
# begin
# @training_task = TrainingTask.find(task_id)
# # 如果已经执行成功过,则不重复执行
# return if @training_task.status == 1
# original_project_id = Project.find(@training_task.project_id).try(:forked_from_project_id)
# original_project = Project.find(original_project_id)
# rescue
# return
# end
# original_tasks_count = original_project.training_tasks.count
# position = @training_task.try(:position)
# # 测试,默认成功
# if status == 0
# ActiveRecord::Base.transaction do
# if position < original_tasks_count
# # 继续发布下一个任务
# publish_training_tasks original_project_id, @training_task.project_id, position + 1, original_project.user_id
# end
# @training_task.update_attribute(:status, 1)
# @training_task.update_attribute(:result, 1)
# # 创建一条回复提醒
# content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务,请继续下一任务"
# add_training_task_journal(content, original_project.user_id)
# end
# else
# content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
# add_training_task_journal(content, original_project.user_id)
# # 失败的时候可以继续提交
# @training_task.update_attribute(:status, 0)
# @training_task.update_attribute(:result, 2)
# end
end
private
def is_members
render_403 unless User.current.manager_of_shixun?(@shixun)
end
def count_input input, output
if input.length == 0 && output.length == 0
result = 0
@ -213,7 +167,7 @@ class ChallengesController < ApplicationController
end
def tpi_manager_allowed
unless (User.current.manager_of_shixun?(@shixun))
unless (User.current.manager_of_shixun?(@shixun) || User.current.admin?)
render_403
end
end
@ -243,12 +197,6 @@ class ChallengesController < ApplicationController
render_404
end
# TPM:parent_id is nil
# TPI is not allowed
def authorize_tpi
render_403 if @shixun.tpi?
end
# Find project of id params[:id]
def find_shixun
shixun_id = params[:shixun_id] || (params[:challenge] && params[:challenge][:shixun_id])
@ -257,4 +205,9 @@ class ChallengesController < ApplicationController
render_404
end
def find_shixun_language
language = @shixun.language
@language = language_switch language
end
end

View File

@ -1,3 +1,4 @@
#coding=utf-8
class GamesController < ApplicationController
layout "base_myshixun"
skip_before_filter :verify_authenticity_token, :only => [:file_update]
@ -5,10 +6,12 @@ class GamesController < ApplicationController
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :game_status, :change_status]
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update]
before_filter :allowd_manager
before_filter :allowd_view, :only => [:show]
before_filter :find__shixun_language, :only => [:show, :entry]
include ApplicationHelper
def index
@games = @myshixun.games
@games = @myshixun.games.includes(:challenge)
@games_count = @games.count
respond_to do |format|
format.html
@ -20,7 +23,8 @@ class GamesController < ApplicationController
# 首次进入版本库自动打开文件
# path"" && path: @game.path
def show
game_path = (@game.path.blank? ? @game.path : @game.path.strip)
@game_challenge = @game.challenge
game_path = (@game_challenge.path.blank? ? @path : @game_challenge.path.strip)
@rev = @rev.nil? ? "master" : @rev
@git_url = git_repository_url(@myshixun, "Myshixun")
@type = params[:type]
@ -32,9 +36,10 @@ class GamesController < ApplicationController
else
@entries = @repository.entries(@path, @rev)
end
@latest_output = @game.latest_output.try(:out_put)
outputs = @game.outputs
@had_done = 1 if (@myshixun.games.count == @game.stage && @game.status ==2)
@had_done = 1 if (@myshixun.games.count == @game_challenge.position && @game.status ==2)
if outputs.count == 0
@results = []
else
@ -58,15 +63,16 @@ class GamesController < ApplicationController
end
def file_edit
entry_and_raw(false)
@content = @repository.cat(@path, @rev).rstrip
# respond_to do |format|
# format.js
# entry_and_raw(false)
# @content = @repository.cat(@path, @rev).strip
# # respond_to do |format|
# # format.js
# end
end
def file_update
@g = Gitlab.client
content = params[:content].strip
@g.edit_file(@myshixun.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "shixun exec")
respond_to do |format|
format.js{redirect_to entry_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => @path)}
@ -86,36 +92,45 @@ class GamesController < ApplicationController
# status 0: 未提交测评或者提交测评失败后报错1中间状态还没返回值2返回值并成功
def game_build
game_challenge = @game.challenge
gitUrl = git_repository_url(@myshixun, "Myshixun")
gitUrl = Base64.encode64(gitUrl)
taskId = params[:id]
jobName = "myshixun_#{@myshixun.id}"
@game.update_attribute(:status, 1)
testCode = {}
test_sets = @game.test_sets
unless test_sets.blank?
test_sets.each_with_index do |test_set, index|
testCode.store("testCode_#{index}",test_set.try(:output))
ActiveRecord::Base.transaction do
@game.update_attributes!(:status => 1)
testCode = {}
test_sets = game_challenge.test_sets
unless test_sets.blank?
test_sets.each_with_index do |test_set, index|
testCode.store("testCode_#{index}",test_set.try(:output))
end
end
testCode = testCode.to_json
jenkins_shixuns = Redmine::Configuration['jenkins_shixuns']
step = game_challenge.try(:position)
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}", :testCode => "#{testCode}"}
uri = URI("#{jenkins_shixuns}/jenkins-exec/api/buildJob")
res = uri_exec uri, params
if (res && res['code'] != 0)
raise("Build job failed")
end
render :json => {data:"success"}
end
testCode = testCode.to_json
jenkins_shixuns = Redmine::Configuration['jenkins_shixuns']
step = @game.stage
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}", :testCode => "#{testCode}"}
uri = URI("#{jenkins_shixuns}/jenkins-exec/api/buildJob")
res = uri_exec uri, params
render :json => {data:"success"}
rescue
raise ActiveRecord::Rollback
redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun)
end
def game_status
outputs = @game.outputs
game_challenge = @game.challenge
if outputs.count == 0
outputs = ""
else
outputs = outputs.map{|result| [result.code, result.id]}
end
had_done = 1 if (@myshixun.games.count == @game.stage && @game.status ==2)
(@myshixun.games.count == game_challenge.position && @game.status ==2) ? had_done = 1 : had_done = 0
latest_output = @game.latest_output.try(:out_put)
render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done}
end
@ -128,7 +143,7 @@ class GamesController < ApplicationController
else
outputs = outputs.map{|result| [result.code, result.id]}
end
render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done}
render :json => {status: @game.status, output: "服务器网络异常", results: outputs, had_done: 0}
end
# 自动推送下一个任务
@ -193,7 +208,17 @@ class GamesController < ApplicationController
end
def allowd_manager
render_403 unless (User.current.manager_of_myshixun?(@myshixun) || User.current.admin?)
render_403 unless (User.current.manager_of_myshixun?(@myshixun) || User.current.admin? || User.current.id == @myshixun.shixun.try(:user_id))
end
# 判断成员是否允许查看
def allowd_view
render_403 if @game.status == 3
end
def find__shixun_language
language = @myshixun.shixun.try(:language)
@language = language_switch(language)
end
# Find myshixun of id params[:id]

View File

@ -12,7 +12,7 @@ class ShixunsController < ApplicationController
def shixun_monitor
monitor_filter
if @had_exec
@tpm = Myshixun.where(:user_id => User.current, :parent_id => @shixun).first
@tpm = Myshixun.where(:user_id => User.current, :shixun_id => @shixun).first
end
respond_to do |format|
@ -21,39 +21,39 @@ class ShixunsController < ApplicationController
end
# copy_shixun复制一个新的实训模块包括版本库
# publish_challenges自动创建第一个Challenge
# copy_myshixun自动创建系列game,game中只包含状态等信息公共信息从Challeges中读取
#
def shixun_exec
monitor_filter
if @had_exec == true || User.current.id == @shixun.user_id
if has_exec_cur_shixun(@shixun) || User.current.id == @shixun.user_id
render_403
end
repository = @shixun.repository
ActiveRecord::Base.transaction do
begin
g = Gitlab.client
@g = Gitlab.client
if User.current.gid.nil?
s = Trustie::Gitlab::Sync.new
s.sync_user(User.current)
end
gshixun = g.fork(@shixun.gpid, User.current.gid)
if gshixun.id
gshixun = @g.fork(@shixun.gpid, User.current.gid)
if !gshixun.id.nil?
myshixun = copy_myshixun(@shixun, gshixun)
challenges = @shixun.challenges
# 之所以增加user_id是为了方便统计查询性能
challenges.each_with_index do |challenge, index|
publish_games(challenge, myshixun.id, index)
status = (index == 0 ? 0 : 3)
Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id)
end
else
raise("网络异常,请稍后重试")
end
respond_to do |format|
format.html{redirect_to myshixun_path(myshixun)}
end
rescue Exception => e
flash[:notice] = l(:notice_shixun_failed_exec)+ ":" + e.message
flash[:error] = l(:notice_shixun_failed_exec)+ " : " + e.message
@g.delete_project(gshixun.id) if !gshixun.id.nil?
raise ActiveRecord::Rollback
respond_to do |format|
format.html{
redirect_to shixun_path(@shixun)}
end
end
end
end
@ -70,6 +70,7 @@ class ShixunsController < ApplicationController
def create
@shixun = Shixun.new(params[:shixun])
@shixun.user_id = User.current.id
@shixun.language = params[:language]
(params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false)
respond_to do |format|
if @shixun.save
@ -90,21 +91,17 @@ class ShixunsController < ApplicationController
end
end
def index
end
def edit
end
def update
@shixun.attributes = params[:shixun]
@shixun.language = params[:language]
params[:shixun][:is_public] == "on" ? @shixun.is_public = 1 : @shixun.is_public = 0
if @shixun.save
redirect_to settings_shixun_url(@shixun)
else
@shixun.save
respond_to do |format|
format.html{redirect_to settings_shixun_url(@shixun)}
end
end
@ -140,15 +137,6 @@ class ShixunsController < ApplicationController
return
end
@shixun.update_attribute(:status, 1)
# jobName = "#{@shixun.id}"
# pipeLine = "#{Base64.encode64(@shixun.script)}"
# uri = URI("http://123.59.135.74:9999/jenkins-exec/api/createJob")
# params = {jobName: jobName, pipeLine: pipeLine}
# res = uri_exec uri, params
# training_shixun_notice res
# if res['code'] == 0
# @shixun.update_attribute(:status, 1)
# end
end
# 更新实训job
@ -189,39 +177,29 @@ class ShixunsController < ApplicationController
# REDO: 新增类型copy的时候
# 复制项目
# gshixun --> gitlab project
def copy_myshixun tpm_shixun, gshixun
def copy_myshixun shixun, gshixun
myshixun = Myshixun.new
myshixun.name = tpm_shixun.name
myshixun.description = tpm_shixun.description
myshixun.is_public = tpm_shixun.is_public
myshixun.parent_id = tpm_shixun.id
myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status")
myshixun.shixun_id = shixun.id
myshixun.user_id = User.current.id
myshixun.gpid = gshixun.id
myshixun.forked_from = tpm_shixun.id
jenkins_shixuns = Redmine::Configuration['jenkins_shixuns']
if myshixun.save
m = MyshixunMember.new(:user_id => User.current.id, :role => 1)
myshixun.myshixun_members << m
if myshixun.save!
MyshixunMember.create!(:myshixun_id => myshixun.id, :user_id => User.current.id, :role => 1)
uri = URI("#{jenkins_shixuns}/jenkins-exec/api/createJob")
pipeLine = "#{Base64.encode64(tpm_shixun.script)}"
pipeLine = "#{Base64.encode64(shixun.script)}"
params = {jobName: "myshixun_#{myshixun.id}", pipeLine: pipeLine}
res = uri_exec uri, params
copy_myshixun_repository(myshixun, gshixun)
rep = Repository.new(:myshixun_id => myshixun.id, :identifier => gshixun.name,:project_id => -1, :shixun_id => -2)
rep.type = "Repository::Gitlab"
rep.save!
if (res && res['code'] != 0)
raise("Job 创建失败")
end
return myshixun
end
end
def copy_myshixun_repository(myshixun, gshixun)
repository = Repository.factory('Git')
repository.myshixun_id = myshixun.id
repository.type = 'Repository::Gitlab'
repository.url = gshixun.name
repository.identifier = gshixun.name
repository.project_id = -1
repository.shixun_id = -2
repository = repository.save
end
def training_shixun_notice res
if res['code'] == 0
@notice = "实训开启成功"

View File

@ -42,7 +42,8 @@ class UsersController < ApplicationController
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues,
:user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community]
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community,
:user_shixuns]
before_filter :auth_user_extension, only: :show
before_filter :show_system_message, :only => [:show]
#before_filter :rest_user_score, only: :show
@ -651,6 +652,14 @@ class UsersController < ApplicationController
end
end
# 我发布的实训
def user_shixuns
@shixuns = Shixun.where(:user_id => User.current)
respond_to do |format|
format.html{render :layout=>'base_users_new'}
end
end
#处理加入课程成为教辅教师的请求
#status 1 同意 2 拒绝
def dealwith_apply_request

View File

@ -33,26 +33,41 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
# codeMirror语言转换
def language_switch language
case language
when "Java"
"text/x-java"
when "C"
"text/x-csrc"
when "C++"
"text/x-c++src"
when "Python"
"text/x-python"
when "Ruby"
"text/x-ruby"
end
end
# 定义实训相关方法
# myshixun 最高分
def top_score shixun, position
Game.find_by_sql("SELECT max(final_score) as score FROM `games` where stage=#{position} and myshixun_id in (SELECT id FROM `myshixuns` where parent_id=#{shixun.id})").first
Game.find_by_sql("SELECT max(final_score) as top_score FROM `games` g, `challenges` c where g.challenge_id = c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:top_score)
end
# 实训平均分
def shixun_avg_score shixun, position
Game.find_by_sql("SELECT avg(final_score) as avg_score FROM `games` where stage=#{position} and myshixun_id in (SELECT id FROM `myshixuns` where parent_id=#{shixun.id})")
Game.find_by_sql("SELECT avg(g.final_score) as avg_score FROM `games` g, `challenges` c where g.challenge_id=c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:avg_score)
end
# 正在进行中任务
def shixun_running shixun, position
Myshixun.find_by_sql("SELECT * FROM `myshixuns` ms, `games` g where g.myshixun_id = ms.id and parent_id =#{shixun.id} and g.stage=#{position} and (g.status=0 or g.status=1);").count
Shixun.find_by_sql("SELECT count(*) as count FROM `myshixuns` ms, `games` g, `challenges` c where g.myshixun_id = ms.id and ms.shixun_id =#{shixun.id} and g.challenge_id=c.id and c.position=#{position} and g.status in ('0','1');").first.try(:count)
end
# 已完成任务
def shixun_done shixun, position
Myshixun.find_by_sql("SELECT * FROM `myshixuns` ms, `games` g where g.myshixun_id = ms.id and parent_id =#{shixun.id} and g.stage=#{position} and g.status=2;").count
Shixun.find_by_sql("SELECT count(*) as count FROM `myshixuns` ms, `games` g, `challenges` c where g.myshixun_id = ms.id and ms.shixun_id =#{shixun.id} and g.challenge_id=c.id and c.position=#{position} and g.status=2;").first.try(:count)
end
# 测评次数
@ -85,9 +100,36 @@ module ApplicationHelper
min = time % (24*60*60) % (60*60) / 60
end
# 耗时:天、小时、分
# 小于1分钟则不显示
def game_spend_time start_time, end_time
time = (end_time - start_time).to_i
day = time / 86400
hour = time % (24*60*60) / (60*60)
min = time % (24*60*60) % (60*60) / 60
if day < 1
if hour < 1
if time < 1
time = time == 0 ? "--" : "小于1分钟"
else
time = "#{min} 分钟"
end
else
time = "#{hour}小时 : #{min}"
end
else
time = "#{day}天 : #{hour}小时 : #{min}"
end
return time
end
def avg_spend_time shixun_id, position
Game.find_by_sql("SELECT avg(g.updated_at - g.created_at) as avg_time FROM `games` g, `challenges` c where c.id=g.challenge_id and g.status =2 and c.position = #{position} and g.myshixun_id in (SELECT id FROM `myshixuns` where shixun_id= #{shixun_id});").first.try(:avg_time).to_i
end
# 已闯关
def had_pass myshixun
Game.find_by_sql("SELECT * FROM `games` where status =2 and myshixun_id in (SELECT id FROM `myshixuns` where parent_id=#{myshixun.parent_id});").count
def had_pass shixun_id, position
Game.find_by_sql("SELECT count(*) as count FROM `games` g, `challenges` c where c.id=g.challenge_id and g.status =2 and c.position =#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` where shixun_id=#{shixun_id});").first.try(:count)
end
# 单个game测评次数
@ -96,7 +138,7 @@ module ApplicationHelper
end
def shixun_final_score myshixun
Game.find_by_sql("SELECT sum(final_score) as score FROM `games` where myshixun_id='#{myshixun.id}';")
Game.find_by_sql("SELECT sum(final_score) as final_score FROM `games` where myshixun_id='#{myshixun.id}';").first.try(:final_score)
end
# def user_blogs_path(resource,parameters={})
@ -230,7 +272,7 @@ module ApplicationHelper
# 判断当前用户是否已经实训过当前项目
# project: current_project
def has_exec_cur_shixun shixun
Myshixun.where(:user_id => User.current.id, :parent_id => shixun.id).count > 0 ? true : false
Myshixun.where(:user_id => User.current.id, :shixun_id => shixun.id).count > 0 ? true : false
end
def allow_shixun_exec shixun

View File

@ -5,6 +5,7 @@ class Challenge < ActiveRecord::Base
has_many :challenge_samples, :dependent => :destroy
has_many :test_sets, :dependent => :destroy
has_many :challenge_tags, :dependent => :destroy
has_many :games, :dependent => :destroy
validates_presence_of :subject
validates_presence_of :score

View File

@ -1,15 +1,18 @@
class Game < ActiveRecord::Base
# stauts 0: can exe 1doing 2successed 3:locked
default_scope :order => 'stage'
attr_accessible :description, :myshixun_id, :stage, :subject, :user_id, :status, :ready_knowledge, :task_pass, :answer, :score, :final_score, :path
default_scope :order => 'created_at desc'
attr_accessible :myshixun_id, :user_id, :status, :final_score, :challenge_id
belongs_to :myshixun,:touch=> true
belongs_to :user
belongs_to :challenge
has_many :outputs, :dependent => :destroy
has_many :test_sets, :dependent => :destroy
has_many :challenge_samples, :dependent => :destroy
def next_game
game = Game.where(:myshixun_id => self.myshixun_id, :stage => self.stage + 1).first
challenge = self.challenge
next_challenge_id = challenge.next_challenge
game = Game.where(:myshixun_id => self.myshixun_id, :challenge_id => next_challenge_id).first
render_404 if game.nil?
return game
end

View File

@ -4,6 +4,7 @@ class Myshixun < ActiveRecord::Base
has_many :myshixun_members
has_one :repository
has_many :games, :dependent => :destroy, :order => "games.id ASC"
belongs_to :shixun
# 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录)
# status:0 可以测评的,正在测评的
@ -12,7 +13,8 @@ class Myshixun < ActiveRecord::Base
games = self.games
current_game = games.select{|game| game.status==1 || game.status==0}.first
if current_game.blank?
current_game = games.last
passed_games = games.select{|game| game.status==2}
current_game = passed_games.last
end
return current_game
end

View File

@ -1,28 +1,12 @@
# status 控制实训的状态0未开启1: 已开启TPM
class Shixun < ActiveRecord::Base
attr_accessible :description, :is_public, :name, :parent_id, :changeset_num, :forked_form, :status, :user_id, :gpid, :forked_count
attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language
has_many :users, :through => :shixun_members
has_many :shixun_members
has_one :repository
has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC"
def parent
shixun = Shixun.find_by_parent_id(self.parent_id)
# raise ActiveRecord::RecordNotFound, "Couldn't find Shixun with parent_id=#{self.parent_id}" if shixun.nil?
end
def children
Myshixun.where(:parent_id => self.id)
end
def tpi?
(!self.parent_id.nil? && !self.forked_form.nil? && self.status == 2) ? true : false
end
def tpm?
(self.parent_id.nil? && self.status == 1) ? true : false
end
has_many :myshixuns
def owner
User.find(self.user_id)

View File

@ -31,7 +31,7 @@
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed;">
<thead>
<tr >
<tr>
<%= sort_header_tag('login', :caption => l(:field_login)) %>
<%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
<%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
@ -59,7 +59,6 @@
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center" title="<%= get_occupation_from_user(user) %>"> <%= truncate(get_occupation_from_user(user), :length => 12 ) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= change_status_link(user) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %></td>
</tr>
<% end -%>
</tbody>

View File

@ -4,7 +4,9 @@
<% if @challenges.count != 0 %>
<span class="btn-cir btn-cir-grey ml5 mt8 fl"><%= @challenges.count %></span>
<% end %>
<a href="<%= new_shixun_challenge_path(@shixun) %>" class=" task-btn task-btn-green fr">新建阶段</a>
<% if User.current.manager_of_shixun?(@shixun) || User.current.admin? %>
<a href="<%= new_shixun_challenge_path(@shixun) %>" class=" task-btn task-btn-green fr">新建阶段</a>
<% end %>
</div>
<div class="panel-list">
<% @challenges.each_with_index do |challenge, index| -%>
@ -21,25 +23,16 @@
<a href="<%= index_down_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="下移" data-remote="true"><i class="fa fa-long-arrow-down color-grey font-16 mr5" ></i></a>
<% end %>
<a href="<%= edit_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="编辑" ><i class="fa fa-pencil-square-o color-grey font-16 mr5" ></i></a>
<!-- <a href="#" title="删除" ><i class="fa fa-trash-o color-grey font-16 mr5" ></i></a>-->
<!-- <a href="#" title="删除" ><i class="fa fa-trash-o color-grey font-16 mr5" ></i></a>-->
<!--<a href="#" title="排名" ><i class="fa fa-signal color-grey font-16 mr5 " ></i></a>-->
</p>
<% end %>
<div class="cl"></div>
<p class="ml15 mt15 color-grey">
<% if shixun_running(@shixun, challenge.position) != 0 %>
<span class=" mr10">正在挑战:<%= shixun_running(@shixun, challenge.position) %></span>
<% end %>
<% if shixun_done(@shixun, challenge.position) != 0 %>
<span class=" mr10">完成挑战:<%= shixun_done(@shixun, challenge.position) %></span>
<% end %>
<% if top_score(@shixun, challenge.position).score.to_i != 0 %>
<span class=" mr10">最佳表现:<%= top_score(@shixun, challenge.position).score.to_i %>分</span>
<% end %>
<% if shixun_exec_total_count(@shixun, challenge.position).count != 0 %>
<span class=" mr10">测评次数:<%= shixun_exec_total_count(@shixun, challenge.position).count %>次</span>
<% end %>
<!--<span class=" mr10">平均表现:<%#= shixun_avg_score(@shixun, challenge.position).avg_score.to_i %>分 </span>-->
<span class=" mr10">正在挑战:<%= shixun_running(@shixun, challenge.position).to_i %></span>
<span class=" mr10">完成挑战:<%= shixun_done(@shixun, challenge.position).to_i %></span>
<span class=" mr10">最佳表现:<%= top_score(@shixun, challenge.position).to_i %>分</span>
<span class=" mr10">平均表现:<%= shixun_avg_score(@shixun, challenge.position).to_i %>分 </span>
</p>
</div>
<script>

View File

@ -33,11 +33,11 @@
</li>
<li class="clearfix">
<label class="panel-form-label fl">文件路径:</label>
<%= f.text_field :path, :class => "panel-form-width-690 panel-form-height-30 fl", :no_label => true, :placeholder => "进入实训后将默认打开该文件" %>
<%= f.text_field :path, :class => "panel-form-width-690 panel-form-height-30 fl", :no_label => true, :placeholder => "进入实训后将默认打开该文件app/controllers/welcome_controller.rb", :maxlength => "256" %>
</li>
<li class="clearfix">
<label class="panel-form-label fl">预备知识:</label>
<%= f.kindeditor :ready_knowledge, :placeholder => "请输入完成当前任务依赖的知识点或者其它相关信息,指导学员完成任务", :width=>'87.5%', :height =>159, :resizeType => 0, :no_label => true %>
<%= f.kindeditor :ready_knowledge, :placeholder => "请输入完成当前任务依赖的知识点或者其它相关信息,指导学员完成任务", :width=>'87.5%', :height => 159, :resizeType => 0, :no_label => true %>
<%#= f.text_area :ready_knowledge, :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true, :placeholder => "请输入完成当前任务依赖的知识点或者其它相关信息,指导学员完成任务" %>
</li>
<li class="clearfix">
@ -138,10 +138,7 @@
</li>
<li class="clearfix" style="line-height:1.9;">
<label class=" panel-form-label fl"> 参考答案:</label>
<%= f.text_area :answer, :id => 'challenge-answer', :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true, :style => "line-height:1.9;" %>
<script>
var text = document.getElementById("challenge-answer");
</script>
<%= f.text_area :answer, :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true, :style => "line-height:1.9;" %>
</li>
<li class="clearfix">
<label class=" panel-form-label fl"><span class="c_red mr5">*</span>分值设定:</label>
@ -153,71 +150,16 @@
<li class="clearfix">
<% if params[:action] == "edit" %>
<a href="javascript:void(0)" class="task-btn task-btn-green fr mr10" onclick="challenge_update()">保存</a>
<a href="<%= shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" class="task-btn fr mr10">取消</a>
<% else %>
<a href="javascript:void(0)" class="task-btn task-btn-green fr mr10" onclick="challenge_create()">保存</a>
<a href="<%= shixun_challenges_path(@shixun) %>" class="task-btn fr mr10">取消</a>
<% end %>
<a href="javascript:void(0)" class="task-btn fr mr10">取消</a>
</li>
</div>
<script type="text/javascript">
challenge_knowledge_editor = KindEditor.create('#challenge_task_pass',
{"width":"87.5%",
"resizeType":0,
"no_label":true,
"autoHeightMode":true,
"height":200,
"allowFileManager":true,
afterBlur:function () { this.sync(); },
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"
});
challenge_task_editor = KindEditor.create('#challenge_ready_knowledge',
{"width":"87.5%",
"resizeType":0,
"no_label":true,
"autoHeightMode":true,
"height":200,
"allowFileManager":true,
afterBlur:function () { this.sync(); },
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"
});
var editor = CodeMirror.fromTextArea(document.getElementById("challenge-answer"), {
mode: {name: 'text/x-java',
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 2,
matchBrackets: true
});
editor.on('change',function(cMirror){
// get value right from instance
$('#challenge-answer').val(cMirror.getValue());
});
function add_tag(){
var num = $(".task-bd-grey").children('div').length;
var val = $(".task-tag-input").val().trim();
if (val != ""){
testLength = $(".task-tag-input").val().trim().length;
$("#add_knowledge").before("<div class='task-tag tag-grey mt5 mr10 fl' id='knowledge_" + num + "'>" +
"<button data-dismiss='alert' class='close fr mt3 ml5' type='button' onclick='close_tag(this)'>×</button>" +
"<input style='width:"+ testLength*12 +"px' class='knowledge_frame' name='knowledge[input][]' value='" + val +"'>" +
" </div>");
$(".task-tag-input").attr("value","");
}
}
function close_tag(thisObj){
// 获取父节点的id
var obj = thisObj.parentNode.id;
$("#"+obj).remove();
}
$(function () {
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
@ -234,8 +176,8 @@
}
if (inputs.length == outputs.length) {
for (var i = 0; i < inputs.length; i++) {
// autoTextarea2(inputs[i], outputs[i], 0, 140);
// autoTextarea2(outputs[i], inputs[i], 0, 140);
// autoTextarea2(inputs[i], outputs[i], 0, 140);
// autoTextarea2(outputs[i], inputs[i], 0, 140);
}
}
$(inputs[inputs.length - 1]).focus();
@ -275,12 +217,12 @@
});
var text1 = document.getElementById("textarea_sample_input_test");
var text2 = document.getElementById("textarea_sample_output_test");
// autoTextarea(text1, 0, 140);
// autoTextarea(text2, 0, 140);
// autoTextarea(text1, 0, 140);
// autoTextarea(text2, 0, 140);
var text3 = document.getElementById("textarea_input_test");
var text4 = document.getElementById("textarea_output_test");
// autoTextarea2(text3, text4, 0, 140);
// autoTextarea2(text4, text3, 0, 140);
// autoTextarea2(text3, text4, 0, 140);
// autoTextarea2(text4, text3, 0, 140);
$("#challenge_score").keyup(function(){
(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)
});
@ -316,4 +258,62 @@
$('#edit_challenge_<%= @challenge.id %>').submit();
}
}
var editor = CodeMirror.fromTextArea(document.getElementById("challenge_answer"), {
mode: {name: '<%= @language %>',
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 2,
matchBrackets: true
});
editor.on('change',function(cMirror){
// get value right from instance
$('#challenge_answer').val(cMirror.getValue());
});
challenge_task_pass_editor = KindEditor.create('#challenge_task_pass',
{"width":"87.5%",
"resizeType":0,
"no_label":true,
"autoHeightMode":true,
"height":200,
"allowFileManager":true,
afterBlur:function () { this.sync(); },
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"
});
challenge_task_editor = KindEditor.create('#challenge_ready_knowledge',
{"width":"87.5%",
"resizeType":0,
"no_label":true,
"autoHeightMode":true,
"height":200,
"allowFileManager":true,
afterBlur:function () { this.sync(); },
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"
});
function add_tag(){
var num = $(".task-bd-grey").children('div').length;
var val = $(".task-tag-input").val().trim();
if (val != ""){
testLength = $(".task-tag-input").val().trim().length;
$("#add_knowledge").before("<div class='task-tag tag-grey mt5 mr10 fl' id='knowledge_" + num + "'>" +
"<button data-dismiss='alert' class='close fr mt3 ml5' type='button' onclick='close_tag(this)'>×</button>" +
"<input style='width:"+ testLength*12 +"px' class='knowledge_frame' name='knowledge[input][]' value='" + val +"'>" +
" </div>");
$(".task-tag-input").attr("value","");
}
}
function close_tag(thisObj){
// 获取父节点的id
var obj = thisObj.parentNode.id;
$("#"+obj).remove();
}
</script>

View File

@ -1,10 +1,14 @@
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<%= stylesheet_link_tag "/assets/kindeditor/plugins/code/previewcode" %>
<div class="task-pm-content mb20">
<div class="task-pm-box mt20">
<div class="panel-header clearfix">
<h3 class="fl mt5">阶段详情</h3>
<a href="<%= new_shixun_challenge_path(@shixun) %>" class=" task-btn task-btn-green fr">新建阶段</a>
</div>
<div class="panel-form">
<div class="panel-form ">
<div class="clearfix mb20">
<h3 class="fl panel-inner-title"><span class="color-red mr10">第<%= @challenge.position %>关</span><%= @challenge.subject %></h3>
<p class="fr">
@ -20,21 +24,21 @@
<%= @challenge.path.blank? ? "无" : (h @challenge.path.html_safe) %>
</div>
</li>
<li class="clearfix">
<li class="clearfix challenge_bottom">
<label class="panel-form-label fl">预备知识:</label>
<div class="fl task-bg-grey">
<div class="fl task-bg-grey task-bg-grey-ligh">
<%= @challenge.ready_knowledge.blank? ? "无" : (h @challenge.ready_knowledge.html_safe) %>
</div>
</li>
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>过关任务:</label>
<div class="fl task-bg-grey">
<div class="fl task-bg-grey task-bg-grey-ligh" id="challenge_task_pass">
<%= h @challenge.task_pass.html_safe %>
</div>
</li>
<li class="clearfix">
<label class="panel-form-label fl">样例设置:</label>
<ul class="fl task-bg-grey">
<ul class="fl task-bg-grey task-bg-grey-ligh">
<% if @challenge_samples.count > 0 %>
<% @challenge_samples.each_with_index do |sample, index| %>
<li class="clearfix">
@ -52,7 +56,7 @@
</li>
<li class="clearfix">
<label class="panel-form-label fl">测试集设置:</label>
<ul class="fl task-bg-grey">
<ul class="fl task-bg-grey task-bg-grey-ligh">
<% if @test_sets.count > 0 %>
<% @test_sets.each_with_index do |test, index| %>
<li class="clearfix">
@ -82,9 +86,8 @@
</li>
<li class="clearfix">
<label class=" panel-form-label fl"> 参考答案:</label>
<div class="fl task-bg-grey">
<%= @challenge.answer.blank? ? "无" : (h @challenge.answer) %>
</div>
<div class="fl" id="tpm_answer_show" style="line-height: 1.2"></div>
<div id="hidden_tpm_answer_show" class="undis"><%= @challenge.answer.blank? ? "无" : (@challenge.answer) %></div>
</li>
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>分值设定:</label>
@ -96,5 +99,20 @@
</div>
</div>
</div>
<script>
$('#challenge_task_pass').find('img').css("max-width", "680px");
var tpmMirror = $("#tpm_answer_show")[0];
var TpmCodeMirror = CodeMirror(tpmMirror, {
value: $("#hidden_tpm_answer_show").text(),
mode: "<%= @language %>",
readOnly: "nocursor", //只读,并隐藏光标
//cursorBlinkRate: -1, //隐藏光标
autofocus: true,
border: 0,
lineNumbers: true
});
$(document).ready(function(){
TpmCodeMirror.setSize('700px','auto');//设置版本库codemirror的高度
});
</script>

View File

@ -1,6 +1,6 @@
<div class="col-width fl content-all-fix undis" style="margin-top:50px">
<div class="content-info col-width content-all-fix undis" id="game_left_contents">
<div class="panel-header clearfix">
<h3 class="fl">第1关Python的初始化</h3>
<h3 class="fl">第<%= @game_challenge.position %>关:<%= @game_challenge.subject %></h3>
<div class="fr mt5">
<a href="javascript:void(0);" onclick="close_game_descpition()"><i class="fa fa-compress font-14 fl color-grey"></i></a>
</div>
@ -20,59 +20,45 @@
<div class="cl"></div>
<div id="big_tab_con_1" class="tab-info" >
<div class="big-tab-info-inner">
<%= h @game.task_pass.try(:html_safe) %>
<%= h @game_challenge.task_pass.try(:html_safe) %>
</div>
</div>
<div id="big_tab_con_2" class="undis tab-info" >
<div class="big-tab-info-inner">
<%= h @game.ready_knowledge.try(:html_safe) %>
<%= h @game_challenge.ready_knowledge.try(:html_safe) %>
</div>
</div>
<div id="big_tab_con_3" class="undis tab-info" >
<div class="big-tab-info-inner">
<%= h @game.answer.try(:html_safe) %>
</div>
<div class="big-tab-info-inner" id="extend_game_answer_show"></div>
<div class="undis" id="hidden_extend_game_answer"><%= h @game_challenge.answer.try(:html_safe) %></div>
</div>
</div>
</div>
<script type="text/javascript" language="javascript">
var web_h = window.innerHeight;
$(document).ready(function(){
if($.browser.msie) {
$(".content-all-fix").css("height", web_h - 225 + "px");
$(".content-all-fix").css("width", "87%");
$(".big-tab-info-inner").css("height", web_h - 185 + "px");
}
else if($.browser.safari)
{
$(".content-all-fix").css("height", web_h - 225 + "px");
$(".big-tab-info-inner").css("height", web_h - 195 + "px");
$(".content-all-fix").css("width", "87%");
}
else if($.browser.mozilla)
{
$(".content-all-fix").css("height", web_h - 225 + "px");
$(".big-tab-info-inner").css("height", web_h - 185 + "px");
$(".content-all-fix").css("width", "87%");
}
else if($.browser.opera) {
$(".content-all-fix").css("height", web_h - 225 + "px");
$(".big-tab-info-inner").css("height", web_h - 185 + "px");
$(".content-all-fix").css("width", "87%");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content-all-fix").css("height", web_h - 225 + "px");
$(".big-tab-info-inner").css("height", web_h - 185 + "px");
$(".content-all-fix").css("width", "87.5%");
}else{
$(".content-all-fix").css("height", web_h - 225 + "px");
$(".big-tab-info-inner").css("height", web_h - 185 + "px");
$(".content-all-fix").css("width", "87.5%");
}
}
var ExtendMirror = $("#extend_game_answer_show")[0];
var ExtendCodeMirror = CodeMirror(ExtendMirror, {
value: $("#hidden_extend_game_answer").text(),
mode: "<%= @language %>",
readOnly: "nocursor", //只读
//cursorBlinkRate: -1, //隐藏光标
autofocus: true,
border: 0
});
// 设置参考答案的line-height
$("#extend_game_answer_show" ).children(".CodeMirror").css("line-height", 1.2);
$(document).ready(function(){
var web_h = window.innerHeight;
// codemirror的高度
var Cm_h = web_h - 185;
// 设置版本库codemirror的高度
ExtendCodeMirror.setSize('auto', Cm_h+'px');
// 设置codemirror无边框
$("#extend_game_answer_show").children().css("border", 0);
});
function close_game_descpition(){
$(".content-all-fix").hide();
$("#game_left_contents").hide();
}
function HoverLi_new(n){
for(var i=1;i<=3;i++){
@ -81,5 +67,8 @@
}
g('big_tab_con_'+n).className='dis';
g('big_tab_nav_'+n).className='tab_hover';
if(n==3){
ExtendCodeMirror.refresh();
}
}
</script>

View File

@ -1,35 +1,10 @@
<%= content_for(:header_tags) do %>
<%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %>
<% end %>
<div id="code_results">
<div id="code_results" class="panel-footer CELL COLS mt15 ml15">
</div>
<script id="t:exec_results" type="text/html">
<div class="col-width fl mt15 content-half-fix undis" style="margin-top:125px;">
<div class="panel-header clearfix">
<h3 class="fl">测评历史</h3>
<div class="fr mt5">
<a href="javascript:void(0)" onclick="hide_windows();"><i class="fa fa-compress font-14 fl color-grey"></i></a>
</div>
</div>
<div class="content-history-inner" style="height: 100px;">
<! for(var i=0;i< results.length; i++) { !>
<! if(results[i][0] == 0){ !>
<div class="clearfix history-success mb10">
<span class="icon-success fl mr5"><!= i+1 !></span>
<p class="fl">恭喜,您已经完成了本任务!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a>
</div>
<! }else{ !>
<div class="clearfix history-fail mb10">
<span class="icon-fail fl mr5"><!= i+1 !></span>
<p class="fl">错误结果!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true" >详情</a>
</div>
<! } !>
<! } !>
</div>
</div>
<div class="col-width fl content-history mt15" >
<div class="col-width content-history CELL mb15" >
<div class="panel-header clearfix">
<h3 class="fl">测评历史</h3>
<div class="fr mt5">
@ -41,36 +16,39 @@
<! for(var i=0;i< results.length; i++) { !>
<! if(results[i][0] == 0){ !>
<div class="clearfix history-success mb10">
<span class="icon-success fl mr5"><!= i+1 !></span>
<span class="icon-success fl mr5"><!= results.length - i !></span>
<p class="fl">恭喜,您已经完成了本任务!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a>
</div>
<! }else{ !>
<div class="clearfix history-fail mb10">
<span class="icon-fail fl mr5"><!= i+1 !></span>
<span class="icon-fail fl mr5"><!= results.length - i !></span>
<p class="fl">错误结果!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true" >详情</a>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a>
<div class="cl"></div>
</div>
<div class="undis" style="background: #f5f9fc;padding: 10px;margin-top:-10px;margin-bottom: 10px" id="game_exception_results_<!= results[i][1] !>"></div>
<! } !>
<! } !>
<!--<! } !>-->
</div>
</div>
<div class="col-width fl content-output ml15 mt15">
<div class="panel-header">
<h3 >测试输出</h3>
<div class="col-width content-output ml15 CELL mb15">
<div class="panel-header clearfix">
<h3>测试输出</h3>
</div>
<div class="content-history-inner" id="game_test_output">
<!=output !>
</div>
</div>
<div class="col-width fl content-submit ml19 mt15">
<div class="panel-header ">
<div class="col-width content-submit ml15 CELL mb15">
<div class="panel-header">
<h3 >操作</h3>
</div>
<div class="content-submitbox">
<a href="javascript:void(0)" class="task-btn task-btn-green mb10" style="display:none;" id="bottom_save_edit" onclick="file_edit_submit1()">保存修改</a>
<div id="game_rep_modify">
</div>
<! if(status == 0){ !>
<div id="game_commit">
<a href="javascript:void(0)" class="task-btn task-btn-green" onclick="training_task_submmit();">提交评测</a>
@ -78,7 +56,7 @@
<! }else if(status == 1){ !>
<a class="task-btn mb10">评测中..</a>
<! }else if(status == 2 && had_done != 1){ !>
<%= link_to "下 一 ", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :remote => true %>
<%= link_to "下 一 ", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :remote => true %>
<! } !>
<! if(had_done == 1) { !>
<a href="javascript:void(0)" class="task-btn mb10" >已通关</a>
@ -103,8 +81,11 @@
url: '<%= game_build_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
success: function (){
//移除载入
var temp = $("#ajax-indicator");
$("#ajax-indicator").remove();
var temp = $("#ajax-indicator").children('span')[0];
$("#ajax-indicator").children('span')[0].remove();
$("#ajax-indicator").css('border', 0);
$("#ajax-indicator").css('padding', 0);
var intId = setInterval(function(){
var ajaxTimeoutTest = $.ajax({
url: '<%= game_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
@ -112,14 +93,29 @@
data:'test',
success:function(data){
//如果查到了,就退出
// i变量用来统计setInterval执行了多少次便于统计访问时间
i = i + 1;
if(data.status == 2 || data.status == 0){
clearInterval(intId);
$("#ajax-position").html(temp);
$("#ajax-indicator").hide();
// 显示载入
$("#ajax-indicator").html(temp);
$("#ajax-indicator").css('border', "1px solid #bbb");
$("#ajax-indicator").css('padding', "0.6em");
var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done});
$("#code_results").html(html);
var html = bt('t:extend_exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done});
$("#extend_code_results").html(html);
if(data.status == 2){
if( data.had_done == 0 ) {
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 0}) %>";
}else{
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>";
}
// 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕
pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight);
}
}
// 访问30次即60s后后台还未改变状态即执行
if(i == 30){
$.ajax({
url: '<%= change_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
@ -141,39 +137,8 @@
});
}
function extend_window(){
var web_h = window.innerHeight;
if($.browser.msie) {
$(".content-half-fix").css("width", "42%");
$(".content-half-fix").css("height", web_h - 168 + "px");
}
else if($.browser.safari)
{
$(".content-half-fix").css("width", "42%");
$(".content-half-fix").css("height", web_h - 168 + "px");
}
else if($.browser.mozilla)
{
$(".content-half-fix").css("width", "42.5%");
$(".content-half-fix").css("height", web_h - 158 + "px");
}
else if($.browser.opera) {
$(".content-half-fix").css("width", "42%");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content-half-fix").css("width", "42.5%");
$(".content-half-fix").css("height", web_h - 160 + "px");
}else{
$(".content-half-fix").css("width", "42.5%");
$(".content-half-fix").css("height", web_h - 155 + "px");
}
}
$(".content-half-fix").show();
$("#extend_code_results").show();
}
function hide_windows(){
$(".content-half-fix").hide();
}
function file_edit_submit1(){
$('#file_update_id').submit();
$("#bottom_save_edit").hide();

View File

@ -4,18 +4,16 @@
<form action="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/file_update?path=<%= @path %>" method="post" id="file_update_id" data-remote="true">
<li class="clearfix" xmlns="http://www.w3.org/1999/html" style="height: 700px">
<textarea class = "" id="challenge-answer" name="content">
<%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %>
</textarea>
<textarea class = "" id="challenge-file-edit" name="content"><%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %></textarea>
<script>
var text = document.getElementById("challenge-answer");
var text = document.getElementById("challenge-file-edit");
</script>
</li>
</form>
<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById("challenge-answer"), {
mode: {name: 'text/x-java',
var editor = CodeMirror.fromTextArea(document.getElementById("challenge-file-edit"), {
mode: {name: '<%= @language %>',
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
@ -25,8 +23,9 @@
editor.on('change',function(cMirror){
// get value right from instance
$('#challenge-answer').val(cMirror.getValue());
$('#challenge-file-edit').val(cMirror.getValue());
});
$(".CodeMirror").css("line-height", 1.2);
var web_h = window.innerHeight;
$(document).ready(function(){
if($.browser.msie) {

View File

@ -0,0 +1,43 @@
<div id="extend_code_results" class="undis">
</div>
<script id="t:extend_exec_results" type="text/html">
<div class="col-width content-history content-half-fix" id="game_text_results">
<div class="panel-header clearfix">
<h3 class="fl">测评历史</h3>
<div class="fr mt5">
<a href="javascript:void(0)" onclick="hide_windows();"><i class="fa fa-compress font-14 fl color-grey"></i></a>
</div>
</div>
<div class="content-history-inner" style="height: 90%;">
<! for(var i=0;i< results.length; i++) { !>
<! if(results[i][0] == 0){ !>
<div class="clearfix history-success mb10">
<span class="icon-success fl mr5"><!= results.length - i !></span>
<p class="fl">恭喜,您已经完成了本任务!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a>
</div>
<! }else{ !>
<div class="clearfix history-fail mb10">
<span class="icon-fail fl mr5"><!= results.length - i !></span>
<p class="fl">错误结果!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a>
<div class="cl"></div>
</div>
<div class="undis" style="background: #f5f9fc;padding: 10px;margin-top:-10px;margin-bottom: 10px" id="extend_game_exception_results_<!= results[i][1] !>"></div>
<! } !>
<! } !>
</div>
</div>
</script>
<script>
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
$(function(){
var html = bt('t:extend_exec_results',{status: <%= @game.status %>, output:"<%= @latest_output %>", results: <%= @results %>, had_done: "<%= @had_done %>"});
$("#extend_code_results").html(html);
});
function hide_windows(){
$("#extend_code_results").hide();
}
</script>

View File

@ -1,61 +1,36 @@
<%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %>
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c", '/assets/codemirror/autorefresh' %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<form action="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/file_update?path=<%= @path %>" method="post" id="file_update_id" data-remote="true">
<li class="clearfix" xmlns="http://www.w3.org/1999/html" id="edit_code_contents">
<textarea class = "" id="challenge-answer" name="content" style="height: 98%;width: 98%;">
<%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %>
</textarea>
<textarea class = "" id="challenge-answer-edit-small" name="content" style="height: 98%;width: 98%;"><%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %></textarea>
<script>
var text = document.getElementById("challenge-answer");
var text = document.getElementById("challenge-answer-edit-small");
</script>
</li>
</form>
<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById("challenge-answer"), {
mode: {name: 'text/x-java',
var editor_CodeMirror = CodeMirror.fromTextArea(document.getElementById("challenge-answer-edit-small"), {
mode: {name: '<%= @language %>',
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 2,
matchBrackets: true
matchBrackets: true,
autofocus: true,
autoRefresh:true
});
var web_h = window.innerHeight;
editor_CodeMirror.on('change',function(cMirror){
// get value right from instance
$('#challenge-answer-edit-small').val(cMirror.getValue());
});
editor_CodeMirror.refresh();
// 设置版本库字体间距
$("#challenge-answer-edit-small" ).nextAll(".CodeMirror").css("line-height", 1.2);
$(document).ready(function(){
if($.browser.msie) {
$(".CodeMirror").css("height", web_h * 0.61 + "px");
$("#edit_code_contents").css("height", web_h * 0.61 + "px");
$("#challenge-answer").css("height", web_h * 0.61 + "px");
}
else if($.browser.safari)
{
$(".CodeMirror").css("height", web_h * 0.61 + "px");
$("#edit_code_contents").css("height", web_h * 0.61 + "px");
$("#challenge-answer").css("height", web_h * 0.61 + "px");
}
else if($.browser.mozilla)
{
$(".CodeMirror").css("height", web_h * 0.595 + "px");
$("#edit_code_contents").css("height", web_h * 0.595 + "px");
$("#challenge-answer").css("height", web_h * 0.595 + "px");
}
else if($.browser.opera) {
$(".CodeMirror").css("height", web_h * 0.61 + "px");
$("#edit_code_contents").css("height", web_h * 0.61 + "px");
$("#challenge-answer").css("height", web_h * 0.61 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".CodeMirror").css("height", web_h * 0.61 + "px");
$("#edit_code_contents").css("height", web_h * 0.61 + "px");
$("#challenge-answer").css("height", web_h * 0.61 + "px");
}else{
$(".CodeMirror").css("height", web_h * 0.58 + "px");
$("#edit_code_contents").css("height", web_h * 0.58 + "px");
$("#challenge-answer").css("height", web_h * 0.58 + "px");
}
}
// 设置codemirror的高度/宽度自适应
editor_CodeMirror.setSize("auto",residue_h+50+"px")
});
</script>

View File

@ -1,13 +1,13 @@
<div class="content clearfix">
<div class="alert alert-blue mr45 mt15 ml15" id="myshixun_tip" >
<button data-dismiss="alert" class="task-close fr" type="button" id="close_myshixun_tip">×</button>
完成任务后,请点击“提交评测”按钮,若通过系统评测,将为你解锁下一关,祝你早日通关,加油!
</div>
<div class="content-row mr15">
<%= render :partial => 'desc_full_show'%>
<div class="content-info col-width fl">
<div class="panel-header clearfix">
<h3 class="fl">第<%= @game.stage %>关:<%= @game.subject %></h3>
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<div class="alert alert-blue CELL mb15 ml15 mr15 mt15" id="myshixun_tip" >
<button data-dismiss="alert" class="task-close fr" type="button" id="close_myshixun_tip"></button>
完成任务后,请点击“提交评测”按钮,若通过系统评测,将为你解锁下一关,祝你早日通关,加油!
</div>
<div class="content clearfix CELL _FLEX COLS ml15 mr15">
<div class="content-info col-width CELL" id="tpi_contents_info">
<div class="panel-header clearfix" id="contents_top">
<h3 class="fl">第<%= @game_challenge.position %>关:<%= @game_challenge.subject %></h3>
<div class="fr mt5">
<a href="javascript:void(0);" onclick="extend_game_description();"><i class="fa fa-expand font-14 fl color-grey"></i></a>
</div>
@ -26,74 +26,49 @@
</ul>
<div class="cl"></div>
<div id="tab_con_1" class="tab-info" >
<div class="tab-info-inner">
<%= h @game.task_pass.try(:html_safe) %>
<div class="tab-info-inner" id="task_pass_contents">
<%= h @game_challenge.task_pass.try(:html_safe) %>
</div>
</div>
<div id="tab_con_2" class="undis tab-info">
<div class="tab-info-inner"><%= h @game.ready_knowledge.try(:html_safe) %></div>
<div class="tab-info-inner" id="task_pass_contents">
<%= h @game_challenge.ready_knowledge.try(:html_safe) %>
</div>
</div>
<div id="tab_con_3" class="undis tab-info">
<div class="tab-info-inner"><%= h @game.answer.try(:html_safe) %></div>
<div class="tab-info-inner" style="line-height: 1.9" id="game_answer_show"></div>
<div class="undis" id="hidden_game_answer"><%= @game_challenge.answer %></div>
</div>
</div>
</div>
<div id="code_content">
<%= render :partial => 'repository' %>
</div>
<%= render :partial => 'exec_results' %>
</div>
<%= render :partial => 'games/repository' %>
</div>
<%= render :partial => 'games/exec_results' %>
<%#= render :partial => 'games/desc_full_show' %>
<script type="text/javascript" language="javascript">
var web_h = window.innerHeight;
var myMirror = $("#game_answer_show")[0];
var myCodeMirror = CodeMirror(myMirror, {
value: $("#hidden_game_answer").text(),
mode: "<%= @language %>",
readOnly: "nocursor", //只读
//cursorBlinkRate: -1, //隐藏光标
autofocus: true,
border: 0
});
$(document).ready(function(){
if($.browser.msie) {
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px"); //IE
$(".content-editor").css("height", web_h * 0.55 + 100 + "px");
}
else if($.browser.safari)
{
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px"); //Safari
$(".content-editor").css("height", web_h * 0.55 + 105 + "px");
}
else if($.browser.mozilla)
{
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.48 + 50 + "px"); //Firefox
$(".content-editor").css("height", web_h * 0.48 + 155 + "px");
}
else if($.browser.opera) {
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px"); //Opera
$(".content-editor").css("height", web_h * 0.55 + 105 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px");
$(".content-editor").css("height", web_h * 0.55 + 105 + "px");
}else{
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.52 + "px");
$(".content-editor").css("height", web_h * 0.52 + 105 + "px");
}
}
myCodeMirror.setSize('auto','auto');//设置版本库codemirror的高度
$("#game_answer_show" ).children(".CodeMirror").css("line-height", 1.2);
$("#game_answer_show").children().css("border", 0);
// 设置图片最大宽度不能超出边框
$('#task_pass_contents').find('img').css("max-width", "100%");
$("#task_pass_contents").css("height", residue_h + "px");
$(".tab-info-inner").css("height", residue_h+"px");
});
//课程大纲tab
function g(o){return document.getElementById(o);}
function HoverLi(n){
for(var i=1;i<=3;i++){
g('tab_nav_'+i).className='tab_nomal';
g('tab_con_'+i).className='undis';
}
g('tab_con_'+n).className='dis';
g('tab_nav_'+n).className='tab_hover';
}
$("#close_myshixun_tip").click(function(){
$("#myshixun_tip").hide();
});
function extend_game_description(){
$(".content-all-fix").show();
$("#game_left_contents").show();
}
</script>

View File

@ -8,45 +8,45 @@
<div class=" clearfix panel-inner">
<% if game.status == 0 %>
<div class="fl">
<h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.stage %>关</span>
<%= link_to game.subject, myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4>
<h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
<%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4>
<p class="ml15 mt15 color-grey">
<span class=" mr10">已闯关:<%= had_pass(@myshixun) %>人</span>
<span class=" mr10">平均耗时:0小时28分</span>
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
<span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span>
</p>
</div>
<a href="#" class=" task-btn task-btn-green fr">马上开启</a>
<a href="<%= game_build_myshixun_game_path(game, :myshixun_id => @myshixun) %>" class="task-btn task-btn-green fr" id="open_game" data-remote="true">马上开启</a>
<div class="cl"></div>
<% elsif game.status == 1 %>
<div class="fl">
<h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.stage %>关</span>
<%= game.subject %></h4>
<h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
<%= game.challenge.try(:subject) %></h4>
<p class="ml15 mt15 color-grey">
<span class=" mr10">已闯关:<%= had_pass(@myshixun) %>人</span>
<span class=" mr10">平均耗时:0小时28分</span>
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
<span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span>
</p>
</div>
<a href="#" class=" fr link-color-green">正在解决中</a>
<div class="cl"></div>
<% elsif game.status == 2 %>
<h4 class="fl panel-inner-title "><i class="fa fa-check-circle font-18 color-green mr5"></i><span class="color-red">第<%= game.stage %>关</span>
<%= link_to game.subject, myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4>
<p class="fr "><i class="fa fa-trophy color-yellow font-16 mr5 "></i><span class=" color-grey">NO.120</span></p>
<h4 class="fl panel-inner-title "><i class="fa fa-check-circle font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
<%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4>
<!--<p class="fr "><i class="fa fa-trophy color-yellow font-16 mr5 "></i><span class=" color-grey">NO.120</span></p>-->
<div class="cl"></div>
<p class="ml15 mt15 color-grey">
<span class=" mr10">开始时间:<%= format_time(game.created_at) %></span>
<span class=" mr10">完成时间:<%= format_time(game.updated_at) %></span>
<span class=" mr10">耗时:<%= game_avg_hour(game.created_at, game.updated_at) %>小时<%= game_avg_min(game.created_at, game.updated_at) %>分</span>
<span class=" mr10">测评次数:<%= avg_my_pass game %>次</span>
<span class=" mr10">耗时:<%= game_spend_time(game.created_at, game.updated_at) %>分</span>
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
<span class=" mr10">得分:<%= game.final_score %>分</span>
</p>
<% elsif game.status == 3 %>
<div class="fl">
<h4 class=" panel-inner-title "><i class="fa fa-lock font-18 color-grey mr5"></i><span class="color-red">第<%= game.stage %>关</span>
<%= game.subject %></h4>
<h4 class=" panel-inner-title "><i class="fa fa-lock font-18 color-grey mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
<%= game.challenge.try(:subject) %></h4>
<p class="ml15 mt15 color-grey">
<span class=" mr10">已闯关:<%= had_pass(@myshixun) %>人</span>
<span class=" mr10">平均耗时:0小时28分</span>
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
<span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span>
</p>
</div>
<a href="#" class=" task-btn fr"> &nbsp;&nbsp;已锁定&nbsp;&nbsp;</a>
@ -57,5 +57,10 @@
<% end %>
</div>
</div>
<script>
$("#open_game").click(function(){
$("#open_game").removeClass("task-btn-green");
$("#open_game").html("评测中..")
});
</script>

View File

@ -1,4 +1,3 @@
<!--<a href="#">testrepo</a> / <a href="#">lib</a> / <a href="#">plugins</a> / <a href="#">acts_as_searchable</a> / <span class="color-light-green">init.rb</span>-->
<% if @path.blank? %>
<%= @repository.identifier %>
<% else %>
@ -14,19 +13,13 @@
link_path << '/' unless link_path.empty?
link_path << "#{dir}"
%>
<span class="c_grey">/</span> <%= link_to h(dir), {:action => 'show', :id => @game, :myshixun_id => @myshixun, :path => to_path_param(link_path), :rev => @rev},
:remote => true, :class => "f14 fb" %>
<% if dir.include?(".") %>
<span class="c_grey">/</span> <%= link_to h(dir), {:action => 'entry', :id => @game, :myshixun_id => @myshixun, :path => to_path_param(link_path), :rev => @rev},
:remote => true, :class => "f14 fb" %>
<% else %>
<span class="c_grey">/</span> <%= link_to h(dir), {:action => 'show', :id => @game, :myshixun_id => @myshixun, :path => to_path_param(link_path), :rev => @rev},
:remote => true, :class => "f14 fb" %>
<% end %>
<% end %>
<% if filename %>
<span class="c_grey">/</span> <%#= link_to h(filename),
{:action => 'changes', :id => @shixun, :repository_id => @repository.identifier_param,
:path => to_path_param("#{link_path}/#{filename}"), :rev => @rev}, :class => "f14 fb" %>
<% end %>
<%
# @rev is revsion or Git and Mercurial branch or tag.
# For Mercurial *tip*, @rev and @changeset are nil.
rev_text = @changeset.nil? ? @rev : format_revision(@changeset)
%>
<%#= "@ #{h rev_text}" unless rev_text.blank? %>
<% end %>

View File

@ -1,5 +1,5 @@
<div class="panel-header clearfix" style="border: none">
<h3 class="fl"><%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h3>
<h3 class="fl"><%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir'} %></h3>
<div class="fr mt5">
<% if params[:action] == "entry" || @file_open %>
<a href="javascript:void(0)" class="undis" id="sava_edit_btn" onclick="file_edit_submit()" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
@ -19,28 +19,3 @@
<% end %>
<% end %>
</div>
<script>
var web_h = window.innerHeight;
$(document).ready(function(){
if($.browser.msie) {
$(".content-history-extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.safari)
{
$(".content-history-extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.mozilla)
{
$(".content-history-extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.opera) {
$(".content-history-extend").css("height", web_h * 0.825 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content-history-extend").css("height", web_h * 0.835 + "px");
}else{
$(".content-history-extend").css("height", web_h * 0.825 + "px");
}
}
});
</script>

View File

@ -1,20 +1,18 @@
<div class="panel-header-border clearfix">
<h3 class="fl">
<%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
<%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir'} %>
</h3>
<div class="fr mt5">
<% if params[:action] == "entry" || @file_open %>
<a href="javascript:void(0)" class="undis" id="sava_edit_btn1" onclick="file_edit_submit()" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
<a href="javascript:void(0)" class="undis" id="sava_edit_btn1" onclick="file_edit_submit()"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
<a href="<%= file_edit_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => params[:path]) %>" data-remote="true" ><i class="fa fa-edit font-18 fl color-grey mr10"></i></a>
<a href="javascript:void(0)" id="sava_edit_btn1" onclick="file_edit_submit()" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
<% end %>
<a href="javascript:void(0)" onclick="extend_repository();"><i class="fa fa-expand font-18 fl color-grey"></i></a>
</div>
</div>
<div class="content-editor-inner">
<div class="content-editor-inner" id="repository_contents_show">
<% if params[:action] == "entry" || @file_open %>
<div id="file_entry_content">
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
<%= render :partial => 'games/file_edit_form', :locals => {:filename => @path, :content => @content} %>
</div>
<% else %>
<% unless @entries.blank? %>
@ -25,40 +23,11 @@
<script>
var web_h = window.innerHeight;
$(document).ready(function(){
if($.browser.msie) {
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
}
else if($.browser.safari)
{
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
}
else if($.browser.mozilla)
{
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.595 + "px");
}
else if($.browser.opera) {
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
}else{
$(".content-half-fix02").css("height", web_h - 80 + "px");
$(".content-half-fix02").css("width", "85.7%");
$(".autoscroll_new").css("height", web_h * 0.583 + "px");
}
}
// 右侧版本库内容
$("#repository_contents_show").css("height", residue_h + 55 + "px");
});
function file_edit_submit(){
$('#file_update_id').submit();
$("#bottom_save_edit").hide();
}
</script>

View File

@ -0,0 +1,15 @@
<%= stylesheet_link_tag 'css/bigdata-common', 'css/bigdata-popup' %>
<div class="task-popup-warp" style="background-color: rgba(0,0,0,0.7);">
<div class="task-popup-box <%= had_done == 0 ? "task-box1" : "task-box2" %>">
<a href="javascript:void(0)" class="task-popup-close" onclick="hideModal();"></a>
<div class="task-su-con">
<% if had_done == 0 %>
<p class="task-su-p">恭喜您通过本关</p>
<%= link_to "下 一 关", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :onclick => "hideModal();",:remote => true %>
<% else %>
<a href="<%= myshixun_games_path(myshixun) %>" class="task-su-btn-white mt50" onclick="hideModal();" data-remote="true">查看光辉历史</a>
<% end %>
</div>
</div>
</div>

View File

@ -1,57 +1,16 @@
<div class="col-width fl ml15 mt15 content-half-fix02 undis" style="border: none" id="myshixun_extend_repository">
<%= render :partial => 'myshixun_extend_repository' %>
</div>
<div class="content-editor col-width2 fl" id="myshixun_repository">
<div class="content-editor col-width2 CELL" id="myshixun_repository">
<%= render :partial => 'myshixun_repository' %>
</div>
<div class="cl"></div>
<script>
var web_h = window.innerHeight;
$(document).ready(function(){
if($.browser.msie) {
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.safari)
{
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.mozilla)
{
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.595 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.opera) {
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.835 + "px");
}else{
$(".content-half-fix02").css("height", web_h - 80 + "px");
$(".content-half-fix02").css("width", "85.7%");
$(".autoscroll_new").css("height", web_h * 0.58 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
}
});
function close_big_repository(){
$(".content-half-fix02").hide()
}
function extend_repository(){
$(".content-half-fix").hide();
$(".content-half-fix02").show();
// $(".content-half-fix").hide();
$("#myshixun_extend_repository").show();
editor.refresh();
}
</script>

View File

@ -1,14 +0,0 @@
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
<div class="wrap-big">
<div style="padding-left: 8px;">
<!--目录跳转-->
<div class="fl mt3">
<%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
</div>
<div class="cl"></div>
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
<% end %>
</div>
</div>

View File

@ -1,7 +1,6 @@
<% if params[:extend] == 'false' %>
$("#myshixun_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_repository') %>');
$("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>');
<% else %>
$("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>');
$("#myshixun_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_repository') %>');
<% end %>
$("#game_rep_modify").html('<a href="javascript:void(0)" class="task-btn task-btn-green mb10" id="bottom_save_edit" onclick="file_edit_submit1()">保存修改</a>');

View File

@ -1,5 +1,7 @@
$("#file_entry_content").replaceWith('<%= escape_javascript(render :partial => 'games/file_edit_form') %>');
$("#file_entry_content_inner").html('<%= escape_javascript(render :partial => 'games/extend_file_edit_form') %>');
$("#sava_edit_btn1").show();
$("#sava_edit_btn").show();
$("#bottom_save_edit").show();
//$("#file_entry_content").html('<%#= escape_javascript(render :partial => 'games/file_edit_form') %>');
//$("#file_entry_content_inner").html('<%#= escape_javascript(render :partial => 'games/extend_file_edit_form') %>');
//$("#sava_edit_btn1").show();
//$("#sava_edit_btn").show();
//$("#bottom_save_edit").show();
//editor_CodeMirror.refresh();
//editor.refresh();

View File

@ -1 +1,2 @@
$("#content_list").html('<%= escape_javascript(render :partial => 'games/games_list') %>');
$("#content_list").html('<%= escape_javascript(render :partial => 'games/games_list') %>');
$("#current_task_tab").attr('href','<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>');

View File

@ -1 +1,8 @@
$("#game_test_output").html("<%= @game.msg %>");
$("#game_test_output").html("<%= @game.out_put.nil? ? "没有编译结果" : @game.out_put %>");
// 窄版
$("#game_exception_results_<%= @game.id %>").html("<%= @game.msg %>");
$("#game_exception_results_<%= @game.id %>").toggle();
// 宽版
$("#extend_game_exception_results_<%= @game.id %>").html("<%= @game.msg %>");
$("#extend_game_exception_results_<%= @game.id %>").toggle();

View File

@ -1,43 +1,31 @@
<div id="content_list">
<%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %>
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<div id="content_list" class="CELL _FLEX ROWS">
<%= render :partial => "game_show" %>
</div>
<div id="content_attr_1">
<%= render :partial => 'desc_full_show'%>
</div>
<div class="col-width content-all-fix undis" style="border: none" id="myshixun_extend_repository">
<%= render :partial => 'myshixun_extend_repository' %>
</div>
<div id="content_attr_2">
<%= render :partial => 'extend_test_output' %>
</div>
<script type="text/javascript" language="javascript">
var web_h = window.innerHeight;
// contents_h 是中间左侧内容页的高度,不同浏览器的得到高度不一致
// contents_top_h 是内容页头部的高度
// contents_tab_nav是三个tab的高度
// residue_h contents剩余展示内容的高度
// 左侧内容
var contents_h = $("#tpi_contents_info").height();
var contents_top_h = $("#contents_top").height() + 20;
var contents_tab_nav = $("#tab_nav").height();
var residue_h = contents_h - contents_top_h - contents_tab_nav-15;
$(document).ready(function(){
if($.browser.msie) {
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px"); //IE
$(".content-editor").css("height", web_h * 0.55 + 100 + "px");
}
else if($.browser.safari)
{
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px"); //Safari
$(".content-editor").css("height", web_h * 0.55 + 105 + "px");
}
else if($.browser.mozilla)
{
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.48 + 50 + "px"); //Firefox
$(".content-editor").css("height", web_h * 0.48 + 155 + "px");
}
else if($.browser.opera) {
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px"); //Opera
$(".content-editor").css("height", web_h * 0.55 + 105 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.55 + "px");
$(".content-editor").css("height", web_h * 0.55 + 105 + "px");
}else{
$(".content").css("height", web_h - 75 + "px");
$(".tab-info-inner").css("height", web_h * 0.52 + "px");
$(".content-editor").css("height", web_h * 0.52 + 105 + "px");
}
}
$(".tab-info-inner").css("height", residue_h+"px");
});
//课程大纲tab
function g(o){return document.getElementById(o);}
@ -48,11 +36,15 @@
}
g('tab_con_'+n).className='dis';
g('tab_nav_'+n).className='tab_hover';
if(n == 3){
// 点击参考答案时让codemirror展示,如果不refresh的话第一次展示会隐藏
myCodeMirror.refresh();
}
}
$("#close_myshixun_tip").click(function(){
$("#myshixun_tip").hide();
});
function extend_game_description(){
$(".content-all-fix").show();
function close_big_repository(){
$("#myshixun_extend_repository").hide()
}
</script>

View File

@ -1,9 +1,5 @@
<% if params[:extend] == 'false' %>
$("#myshixun_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_repository') %>');
$("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>');
<% elsif params[:extend].nil? %>
$("#content_list").html('<%= escape_javascript(render :partial => 'games/game_show') %>');
<% else %>
$("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>');
$("#myshixun_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_repository') %>');
<% end %>
$("#content_list").html('<%= escape_javascript(render :partial => 'games/game_show') %>');
$("#content_attr_1").html('<%= escape_javascript(render :partial => 'games/desc_full_show') %>');
$("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>');
$("#content_attr_2").html('<%= escape_javascript(render :partial => 'games/extend_test_output') %>');
$("#current_task_tab").attr('href','<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>');

View File

@ -55,6 +55,9 @@
<li>
<%= link_to "竞赛", user_contest_community_path(User.current), :class => "new-nav-a", :target => "_blank" %>
</li>
<!--<li>-->
<!--<%#= link_to "智能实训", user_shixuns_user_path(User.current), :class => "new-nav-a", :target => "_blank" %>-->
<!--</li>-->
<li>
<%= link_to "问吧", forums_path, :class =>"new-nav-a", :target => "_blank" %>
</li>

View File

@ -9,50 +9,51 @@
<%= favicon %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/font-awesome','css/taskstyle','css/structure','scm','css/public', 'css/project','css/popup','repository','css/gantt', 'css/calendar', 'css/moduel' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/font-awesome','css/taskstyle','css/structure','scm','css/public', 'css/project','css/popup','repository','css/gantt', 'css/calendar', 'css/moduel', 'css/cssPlus-v.0.2-build' %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
</head>
<%= @shixun %>
<!--add by huang-->
<body onload="prettyPrint();">
<div class="cl"></div>
<div class="task-container">
<div class="leftbar">
<div class="user-info">
<%= link_to image_tag(url_to_avatar(@myshixun.owner), :width => "100", :height => "100"), user_path(@myshixun.owner), :alt => "用户头像", :class => "user-info-img" %>
<!--<a href="#" class="user-info-img"><img src="images/user/male.jpg" width="100" height="" alt="100"></a>-->
<%= link_to @myshixun.owner.try(:show_name), user_path(@myshixun.owner), :class => "user-info-name" %>
<div class="task-container EXTENDER">
<div class="COLS">
<div class="leftbar CELL" style="width: 120px;">
<div class="CELL">
<div class="user-info" style="width: 120px;height:120px;padding-top: 10px;">
<%= link_to image_tag(url_to_avatar(@myshixun.owner), :width => "100", :height => "100"), user_path(@myshixun.owner), :alt => "用户头像", :class => "user-info-img", :style => "border-radius: 100px;margin-left: 5px;" %>
<!--<a href="#" class="user-info-img"><img src="images/user/male.jpg" width="100" height="" alt="100"></a>-->
<%#= link_to @myshixun.owner.try(:show_name), user_path(@myshixun.owner), :class => "user-info-name" %>
</div>
<div class="leftnav">
<ul>
<li class="leftnav-box" style="width: 120px">
<a href="<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>" class="leftnav-box-inner leftnav-active" style="width: 120px" id="current_task_tab" data-remote="true">
<i class="fa fa-gamepad font-28"></i><br/><span class="font-16">当前任务</span>
</a>
</li>
<li class="leftnav-box" style="width: 120px">
<a href="<%= myshixun_games_path(@myshixun) %>" class="leftnav-box-inner" style="width: 120px" id="all_task_tab" data-remote="true">
<i class="fa fa-qrcode font-28"></i><br/><span class="font-16">全部任务</span><span class="btn-cir ml5"><%= @myshixun.games.count %></span>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="leftnav">
<ul>
<li class="leftnav-box">
<a href="<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>" class="leftnav-box-inner leftnav-active" id="current_task_tab" data-remote="true">
<i class="fa fa-gamepad font-28"></i><br/><span class="font-16">当前任务</span>
</a>
</li>
<li class="leftnav-box">
<a href="<%= myshixun_games_path(@myshixun) %>" class="leftnav-box-inner" id="all_task_tab" data-remote="true">
<i class="fa fa-qrcode font-28"></i><br/><span class="font-16">全部任务</span><span class="btn-cir ml5"><%= @myshixun.games.count %></span>
</a>
</li>
</ul>
<div class="rightbar CELL _FLEX ROWS">
<%= render :partial => "myshixuns/myshixun_top" %>
<%= yield %>
</div>
</div>
<div class="rightbar">
<%= render :partial => "myshixuns/myshixun_top" %>
<%= render_flash_messages %>
<%= yield %>
</div>
</div>
<div id="ajax-position">
</div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
</div>
<div id="ajax-modal" style="display:none;"></div>
</body>
<!-- MathJax的配置 -->

View File

@ -22,6 +22,7 @@
<%#= render_flash_messages %>
<div class="task-pm-content">
<%= render_flash_messages %>
<%= yield %>
</div>

View File

@ -1,10 +1,12 @@
<div class="rightbar-header clearfix">
<div class="rightbar-header clearfix CELL">
<h2 class="rightbar-h2 fl"><%= @myshixun.name %></h2>
<a href="javascript:void(0)" class="fr rightbar-pause" id="leave_shixun_page"><i class="fa fa-power-off font-20 mt5"></i><span class="ml10">暂时离开</span></a>
<ul class="rightbar-score fr" >
<!--<li><i class="fa fa-signal font-14 mr5"></i>排名:<a href="#" class="">123</a></li>-->
<li><i class="fa fa-trophy font-14 mr5"></i>积分:<a class=""><%= shixun_final_score(@myshixun).first.try(:score) %></a></li>
<!--<li><i class="fa fa-clock-o font-14 mr5"></i>耗时:<a class=""><%#= game_avg_hour(@game.created_at, @game.updated_at) %><%#= game_avg_min(@game.created_at, @game.updated_at) %></a></li>-->
<li><i class="fa fa-trophy font-14 mr5"></i>积分:<%= shixun_final_score(@myshixun) %></li>
<% if (Time.now - @game.created_at) > 60 %>
<li><i class="fa fa-clock-o font-14 mr5"></i>耗时:<%= @game.status != 2 ? game_spend_time(@game.created_at, Time.now) : game_spend_time(@game.created_at, @game.updated_at) %></li>
<% end %>
</ul>
</div>
<script>

View File

@ -31,6 +31,10 @@
%>
<div class="cl"></div>
</li>
<li class="mb5 ml63">
<label class="fl">&nbsp;语言&nbsp;&nbsp;</label>
<%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby"], "Java"), :id => 'shixun[language]', :class => "ml5", :style => "height: 28px;" %>
</li>
<li class="mb5 ml70">
<label >&nbsp;公开&nbsp;</label>
<%= f.text_field :is_public, :id => "project_is_public", :name => "shixun[is_public]", :type => "checkbox", :value => "1", :checked => "checked" %>

View File

@ -23,6 +23,10 @@
:maxlength => 5000 }
%>
</li>
<li class="clearfix">
<label class="panel-form-label fl">语言:</label>
<%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby"], @shixun.language), :id => 'shixun[language]', :style => "height: 28px;" %>
</li>
<li class="clearfix">
<label class="panel-form-label fl">公开:</label>
<input type="checkbox" <%= @shixun.is_public ? "checked" : ""%> class="fl mt15 mr10" name="shixun[is_public]" />

View File

@ -24,12 +24,6 @@
{:action => 'changes', :id => @project, :repository_id => @repository.identifier_param,
:path => to_path_param("#{link_path}/#{filename}"), :rev => @rev}, :class => "f14 fb" %>
<% end %>
<%
# @rev is revsion or Git and Mercurial branch or tag.
# For Mercurial *tip*, @rev and @changeset are nil.
rev_text = @changeset.nil? ? @rev : format_revision(@changeset)
%>
<%#= "@ #{h rev_text}" unless rev_text.blank? %>
<% end %>

View File

@ -0,0 +1,5 @@
<ul>
<% @shixuns.each do |shixun| %>
<li><%= shixun.name %></li>
<% end %>
</ul>

View File

@ -744,6 +744,8 @@ RedmineApp::Application.routes.draw do
end
member do
get 'user_shixuns', :to => 'users#user_shixuns'
get 'user_myshixuns', :to => 'users#user_myshixuns'
match 'user_projects_index', :to => 'users#user_projects_index', :via => :get
match 'user_projects', :to => 'users#user_projects', :via => :get
match 'user_activities', :to => 'users#user_activities', :via => :get, :as => "user_activities"
@ -1267,7 +1269,7 @@ RedmineApp::Application.routes.draw do
get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
# shixun
get 'shixuns/:id/repository/:repository_id', :to => 'repositories#shixun_show', :path => nil
get 'shixuns/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
get 'shixuns/:id/repository/:repository_id/:rev/:action(/*path(.:ext))',
:controller => 'repositories',
:format => false,
:constraints => {
@ -1280,7 +1282,7 @@ RedmineApp::Application.routes.draw do
:controller => 'games',
:format => false,
:constraints => {
:action => /(browse|show|entry|raw|annotate|diff|commit_diff)/,
:action => /(browse|show|entry)/,
:rev => /[a-z0-9\.\-_]+/
}

View File

@ -0,0 +1,8 @@
class RenameParentIdInShixun < ActiveRecord::Migration
def up
rename_column :myshixuns, :parent_id, :shixun_id
end
def down
end
end

View File

@ -0,0 +1,10 @@
class ModifyShixun < ActiveRecord::Migration
def up
remove_column :shixuns, :parent_id
remove_column :shixuns, :forked_form
remove_column :shixuns, :forked_count
end
def down
end
end

View File

@ -0,0 +1,8 @@
class ModifyMyshixun < ActiveRecord::Migration
def up
remove_column :myshixuns, :forked_from
end
def down
end
end

View File

@ -0,0 +1,15 @@
class ModifyGames < ActiveRecord::Migration
def up
remove_column :games, :subject
remove_column :games, :description
remove_column :games, :stage
remove_column :games, :ready_knowledge
remove_column :games, :task_pass
remove_column :games, :answer
remove_column :games, :score
remove_column :games, :path
end
def down
end
end

View File

@ -0,0 +1,5 @@
class AddChallengeIdToGame < ActiveRecord::Migration
def change
add_column :games, :challenge_id, :integer
end
end

View File

@ -0,0 +1,9 @@
class ChangeTypeToChanllenge < ActiveRecord::Migration
def up
change_column :challenges, :task_pass, :longtext
change_column :challenges, :answer, :longtext
end
def down
end
end

View File

@ -0,0 +1,5 @@
class AddLanguageToShixuns < ActiveRecord::Migration
def change
add_column :shixuns, :language, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20170324090202) do
ActiveRecord::Schema.define(:version => 20170331013652) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -350,15 +350,15 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
t.string "subject"
t.text "description"
t.integer "user_id"
t.integer "status", :limit => 1, :default => 0
t.integer "position", :limit => 1, :default => 1
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "status", :limit => 1, :default => 0
t.integer "position", :limit => 1, :default => 1
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "ready_knowledge"
t.text "task_pass"
t.text "answer"
t.text "task_pass", :limit => 2147483647
t.text "answer", :limit => 2147483647
t.integer "score"
t.integer "visits", :default => 0
t.integer "visits", :default => 0
t.string "path"
end
@ -1081,18 +1081,11 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
create_table "games", :force => true do |t|
t.integer "myshixun_id"
t.integer "user_id"
t.string "subject"
t.text "description"
t.integer "stage"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "status", :default => 0
t.text "ready_knowledge"
t.text "task_pass"
t.text "answer"
t.integer "score"
t.integer "final_score", :default => 0
t.string "path"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "status", :default => 0
t.integer "final_score", :default => 0
t.integer "challenge_id"
end
create_table "groups_users", :id => false, :force => true do |t|
@ -1159,8 +1152,8 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
t.string "name"
t.integer "user_id"
t.text "description"
t.date "publish_time"
t.date "end_time"
t.datetime "publish_time"
t.datetime "end_time"
t.integer "homework_type", :default => 1
t.string "late_penalty"
t.integer "course_id"
@ -1257,6 +1250,19 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
t.datetime "updated_at", :null => false
end
create_table "ii", :force => true do |t|
t.integer "project_id"
t.string "author_login"
t.string "rep_identifier"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "sonar_version", :default => 0
t.string "path"
t.string "branch"
t.string "language"
t.string "sonar_name"
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end
@ -1524,11 +1530,10 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
create_table "myshixuns", :force => true do |t|
t.string "name"
t.text "description"
t.integer "parent_id"
t.integer "shixun_id"
t.boolean "is_public", :default => true
t.integer "user_id"
t.integer "gpid"
t.integer "forked_from", :default => 0
t.integer "visits", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
@ -2135,21 +2140,15 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
t.string "name"
t.text "description"
t.text "script"
t.boolean "is_public", :default => true
t.integer "parent_id"
t.boolean "is_public", :default => true
t.integer "user_id"
t.integer "gpid"
t.integer "forked_count", :default => 0
t.integer "visits", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "visits", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "changeset_num"
t.integer "forked_form"
t.integer "status", :default => 0
t.text "ready_knowledge"
t.text "task_pass"
t.text "answer"
t.integer "score"
t.integer "status", :default => 0
t.string "language"
end
create_table "softapplications", :force => true do |t|
@ -2446,7 +2445,7 @@ ActiveRecord::Schema.define(:version => 20170324090202) do
t.datetime "updated_at", :null => false
t.integer "author_id"
t.integer "status", :limit => 1, :default => 0
t.integer "position", :limit => 1
t.integer "position", :limit => 1, :default => 0
t.integer "result", :default => 0
end

View File

@ -113,7 +113,7 @@ module Redmine
:path => File.join(path,tree.name),
:kind => tree.type == 'tree' ? 'dir' : 'file',
:size => nil,
:lastrev => tree.commit_id
:lastrev => nil
})
end
entries.sort_by_name

View File

@ -5891,7 +5891,7 @@
};
};
textarea.style.display = "none";
//textarea.style.display = "none";
var cm = CodeMirror(function(node) {
textarea.parentNode.insertBefore(node, textarea.nextSibling);
}, options);

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

File diff suppressed because it is too large Load Diff

View File

@ -3,4 +3,17 @@
.task-popup-text-center{ text-align: center; color: #666;}
.task-popup-title{ border-bottom: 1px solid #eee; padding:10px 15px; }
.task-popup-content{ padding:15px;}
.task-popup-submit{ margin:15px auto; width: 200px;}
.task-popup-submit{ margin:15px auto; width: 200px;}
/************实训弹窗****************/
.task-popup-warp{ width: 100%; height:100%; background:black; position:fixed;}
.task-popup-box{ position: relative; margin:150px auto; }
.task-box1{ width:428px; height:420px;background:url(/images/task/task-success.png) 0px 0px no-repeat;}
.task-box2{ width:496px; height:373px;background:url(/images/task/task-success02.png) 0px 50px no-repeat;}
a.task-popup-close{ display: block; background:url(/images/task/task-close.png) 0px 0px no-repeat; width: 31px; height: 31px; position:absolute; right:5px; top:100px;}
a:hover.task-popup-close{background:url(/images/task/task-close.png) -40px 0px no-repeat; }
.task-su-con{ text-align: center; padding-top:285px;}
.task-su-p{ font-size: 20px; color:#ee4a1f; font-weight: bold;}
a.task-su-btn{display: block;background:url(/images/task/task-su-btn.png) 0px -64px no-repeat; width: 138px; height: 57px;color:#ee4a1f; line-height: 50px; text-align: center; font-size: 16px; margin:20px auto;}
a:hover.task-su-btn{background:url(/images/task/task-su-btn.png) 0px 0px no-repeat; }
a.task-su-btn-white{ display: inline-block; padding:8px 25px; border:1px solid #fff; color:#fff; text-align: center; border-radius:5px; font-size:14px;}
a:hover.task-su-btn-white{ color: #ee4a1f; border:1px solid #ee4a1f; }

View File

@ -89,7 +89,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.ml10{ margin-left:10px;}.ml14{ margin-left:14px;}.ml15{ margin-left:15px;}.ml16{ margin-left:16px;}.ml20{ margin-left:20px;}.ml21{ margin-left:21px;}
.ml24{margin-left:24px;}.ml25{margin-left:25px;}.ml30{margin-left:30px !important;}.ml35{margin-left: 35px;}.ml36{ margin-left:36px; }.ml38{ margin-left:38px;}
.ml39{ margin-left:39px;}.ml40{ margin-left:40px;}.ml41{ margin-left:41px;}.ml42{ margin-left:42px;}.ml45{ margin-left:45px;}.ml48{ margin-left:48px;}.ml50{ margin-left: 50px;}
.ml53{margin-left:53px;}.ml55{ margin-left:55px;}.ml56{ margin-left:56px !important;}.ml58{margin-left:58px;}.ml60{ margin-left:60px;}.ml65{ margin-left:65px;}
.ml53{margin-left:53px;}.ml55{ margin-left:55px;}.ml56{ margin-left:56px !important;}.ml58{margin-left:58px;}.ml60{ margin-left:60px;}.ml65{ margin-left:65px;}.ml63{ margin-left:63px;}
.ml70{margin-left: 70px;}.ml78{ margin-left:78px;}.ml80{ margin-left:80px;}.ml85{margin-left:85px;}.ml90{ margin-left:90px;}.ml95{margin-left:95px;}.ml100{ margin-left:100px;}
.ml110{ margin-left:110px;}.ml125 { margin-left:125px;}.ml130 { margin-left:130px;}.ml140 { margin-left:140px;}.ml150 { margin-left:150px;}
.ml160 {margin-left:160px;}.ml250 {margin-left:250px;}.ml258{ margin-left:258px;}.ml320{ margin-left:320px;}.ml358{ margin-left:358px;}.mr-5 {margin-right:-5px;}

File diff suppressed because one or more lines are too long

View File

@ -75,7 +75,7 @@ a:hover.task-btn-blue{ background:#5f7cab;}
/****************************/
.task-container{ min-width:1300px; margin:0 auto; background: #f5f9fc; position: relative;}
/*左侧导航*/
.leftbar{ position: fixed; height: 100%;overflow-y: auto; z-index: 100; background: #1f212d; width: 210px;}
.leftbar{ height: 100%; background: #1f212d; width: 210px;}
.user-info{ width: 210px; height:180px; background:#29bd8b; padding-top:30px;}
a.user-info-img{ display: block; width: 100px; height: 100px; margin:0 auto; }
a.user-info-img img{border-radius:100px;border:5px solid #3fcf9e;}
@ -89,18 +89,18 @@ a:hover.leftnav-box-inner,a.leftnav-active{border-left:3px solid #29bd8b;color:
.btn-cir-grey{background: #e1e1e1;color: #333;}
.btn-cir-grey:hover{background: #c3c3c3;}
/*右侧头部*/
.rightbar-header{position: fixed; top: 0; left:210px; width: 100%; z-index:100; background:#282c37; height:60px; min-width: 1300px;}
.rightbar-header{width: 100%; background:#282c37; height:60px; min-width:1000px;}
.rightbar-score{ margin-top: 17px; font-size: 14px; margin-right:20px;}
.rightbar-score li{ float: left; color:#fff; margin-right: 20px;}
.rightbar-score li a{ color:#fff;}
a.rightbar-pause{ color:#29bd8b; font-size: 18px; margin-right:245px; margin-top: 12px;}
a.rightbar-pause{ color:#29bd8b; font-size: 18px; margin-right:15px; margin-top: 12px;}
.rightbar-h2{ color:#fff; margin:12px 0 0 20px; font-weight: normal;}
.rightbar{padding-top: 60px;margin-left: 210px;background:#f5f9fc; color:#333;}
.rightbar{background:#f5f9fc; color:#333; position: relative;}
/*右侧内容*/
.content{ width:100%; min-width:1000px; }
.content{ min-width:1000px; }
.content-row{ padding:15px; }
.content-info{ width:49%; min-width:450px;}
.content-editor{ width:49%; min-width:450px; margin-left:15px; }
.content-info{ width:49.5%; min-width:250px;}
.content-editor{ width:49.3%; min-width:250px; margin-left:15px; }
.panel-header{ border-bottom:1px solid #eee; padding:10px 15px;}
.panel-header-border{ border:1px solid #eee; padding:10px 15px; border-bottom:none;}
/* tab */
@ -113,21 +113,20 @@ a.rightbar-pause{ color:#29bd8b; font-size: 18px; margin-right:245px; margin-top
.undis {display:none;}
.dis {display:block;}
.tab-info{ }
.content-editor-inner{ overflow:hidden;}
.tab-info-inner{ overflow:auto; margin:15px 0 0px 15px; }
.big-tab-info-inner{ overflow:auto; margin:15px 0 0px 15px; }
.content-history-inner{overflow:auto; padding:15px; height: 80px}
.content-history-extend{overflow:auto; padding:15px;}
.content-history{width:49%; min-width:150px; }
.content-editor-inner{ overflow:auto; height:600px; }
.tab-info-inner{ overflow:auto; height:600px; margin:0 0 0px 15px;padding-top: 15px}
.content-history-inner{height:120px; overflow:auto; padding:15px;}
.content-history{width:48.7%; min-width:500px; }
.history-success{ width: 100%; height:40px; line-height: 40px; background:#eef1f2; color:#666; }
.history-fail{ width: 100%; height:40px; line-height: 40px; background:#fdebeb; color:#e53238; }
.icon-fail{ display:inline-block; padding:0 8px; background:#e53238; color:#fff;}
.icon-success{ display:inline-block; padding:0 8px; background:#252e38; color:#fff;}
.content-output{width:37.5%; min-width:350px;}
.content-submit{width:10%; min-width:135px;}
.content-submitbox{ height: 80px; width:120px; margin: 15px auto;}
.content-output{width:37.5%; min-width:200px; }
.content-submit{width:10%; min-width:135px; }
.content-submitbox{ width:120px; margin: 15px auto; height:135px;}
.panel-inner{ background:#EFF2F7; margin:15px; padding:15px;}
.panel-inner-title{ font-size: 14px; color: #666; max-width: 85%; line-height: 30px; word-wrap: break-word;}
.panel-inner-title{ font-size: 14px; color: #666; max-width:85%; line-height:30px;word-wrap: break-word;}
.panel-footer{ min-width:1000px; height: 210px!important;}
/* 弹框 */
.task-popup{ width: 30%;background: #fff; border:1px solid #e8e8e8; border-radius:3px; -webkit-box-shadow:0 0 10px #ccc; -moz-box-shadow:0 0 10px #ccc; box-shadow:0 0 10px #ccc; margin: 50px auto;}
.task-popup-text-center{ text-align: center; color: #666;}
@ -151,6 +150,8 @@ a.task-header-name{ max-width:200px;}
.task-paner-con{ padding:15px; color:#666; line-height:2.0;}
.panel-form{ width:800px; margin:0 100px; padding:30px 0; line-height: 40px; }
.panel-form li{ margin-bottom:20px; font-size: 14px; color:#666;}
.panel-form-label{ display:inline-block; width:90px; text-align:right; }
.panel-form input,.panel-form textarea{ border:1px solid #e2e2e2;color:#666;line-height: 1.9;}
.panel-form-width-690{ width: 690px; padding:5px;}
@ -158,6 +159,8 @@ a.task-header-name{ max-width:200px;}
.panel-form-height-150{ height: 150px;}
.panel-form-height-30{height: 30px;}
.task-bg-grey{ background:#f3f3f3; width:680px; padding:0 10px; border:1px solid #f3f3f3;}
.task-bg-grey-ligh{line-height: 1.9;padding:5px 10px;}
.task-bg-grey li{ margin-bottom: 0}
.task-bd-grey{width:680px; padding:10 0px;}
input.task-tag-input{ border:none; background: none; height:30px; padding:0 5px; color:#888; line-height: 30px;}
textarea.task-textarea-pd{ padding-bottom: 0px; padding-top:0px;}
@ -166,10 +169,10 @@ textarea.task-textarea-pd{ padding-bottom: 0px; padding-top:0px;}
.mb20{margin-bottom: 20px;}
input.knowledge_frame{height:30px;line-height:30px;border:none;background:#f3f5f7;}
/* TPi全屏展示css */
.content-all-fix{ margin:0; position: absolute; top:15px; z-index:99; }
.content-all-fix .tab-info-inner{ overflow:auto; margin:15px 0 0px 15px; }
.content-half-fix{ min-width:450px; margin:0; position: absolute; top:15px; z-index:99;}
.content-all-fix{ position: absolute; top:75px; left:15px; right:15px; z-index:99; height: 91%; width: 98.5%;}
.content-all-fix .big-tab-info-inner{ display: block; height:50%; overflow:auto; margin:15px 0 0px 15px; }
.content-half-fix{ min-width:450px; margin:0; position: absolute; top:140px; left:15px; z-index:99; height:84%;}
.content-half-fix .content-history-inner{height:100%; overflow:auto; }
.content-half-fix02{margin:0; position: absolute; top:65px; z-index:99; right:45px;}
.autoscroll_new{ overflow:auto; }
.autoscroll_extend{ overflow:auto; }
.content-history-extend{ height: 95%;overflow:auto;}
.task-bg-grey .prettyprint{font-size: 9pt;font-family: Courier New,Arial;border: 1px solid #ddd;border-left: 5px solid #6CE26C;background: #f6f6f6;padding: 5px;}