dev_bj
caishi 5 years ago
commit fc9d98080c

@ -67,6 +67,9 @@ gem 'oauth2'
gem 'axlsx', '3.0.0.pre'
gem 'axlsx_rails', '0.3.0'
# state machine
gem 'aasm'
#Ruby 2.2+ has removed test/unit from the core library.
if RUBY_VERSION>='2.2'
gem 'test-unit', '~> 3.0'

@ -38,32 +38,34 @@ class CompetitionTeamsController < ApplicationController
end
def create
if params[:name]
# 判断用户是否已创建过战队
if @competition.competition_teams.where(:user_id => User.current.id).count > 0 && !User.current.is_teacher
@status = 1
else
invite_code = generate_team_code
teacher_id = User.current.user_extensions.identity == 0 ? User.current.id : params[:teacher]
new_team = CompetitionTeam.create(:competition_id => @competition.id, :name => params[:name],
:invite_code => invite_code, :user_id => User.current.id, :teacher_id => teacher_id)
new_team.team_members << TeamMember.new(:user_id => User.current.id, :role => 1, :competition_id => @competition.id, :is_teacher => User.current.user_extensions.identity == 0 ? 1 : 0)
if params[:member_ids]
params[:member_ids].each do |user_id|
new_team.team_members << TeamMember.new(:user_id => user_id, :role => 2, :competition_id => @competition.id)
end
end
if params[:teacher] && params[:teacher].strip != ""
new_team.team_members << TeamMember.new(:user_id => params[:teacher], :role => 2, :competition_id => @competition.id, :is_teacher => 1)
# 创建成功且配置了指导老师
@status = 0
elsif User.current.user_extensions.identity != 0
# 创建成功未配置指导老师
@status = 2
elsif User.current.user_extensions.identity == 0
@status = 0
end
# 判断用户是否已创建过战队
if @competition.competition_teams.where(:user_id => User.current.id).count > 0 && !User.current.is_teacher
@status, @message = -1, '您已创建过战队,不能重复创建'
return
end
if params[:name].blank?
@status, @message = -1, '战队名称不能为空'
return
end
is_teacher = User.current.user_extensions.identity == 0
return unless member_and_teacher_count_valid?(is_teacher)
ActiveRecord::Base.transaction do
invite_code = generate_team_code
new_team = CompetitionTeam.create(:competition_id => @competition.id, :name => params[:name],
:invite_code => invite_code, :user_id => User.current.id)
new_team.team_members.create!(user_id: User.current.id, role: 1, competition_id: @competition.id, is_teacher: User.current.user_extensions.identity == 0 ? 1 : 0)
params[:member_ids].try(:each) do |user_id|
next if user_id.to_i == User.current.id
new_team.team_members.create!(user_id: user_id, role: 2, competition_id: @competition.id)
end
params[:teacher_ids].try(:each) do |user_id|
next if user_id.to_i == User.current.id
new_team.team_members.create!(user_id: user_id, role: 3, competition_id: @competition.id, is_teacher: 1)
end
end
end
@ -89,79 +91,80 @@ class CompetitionTeamsController < ApplicationController
end
def update
unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now
if params[:name]
teacher_id = User.current.user_extensions.identity == 0 ? User.current.id : params[:teacher]
@team.update_attributes(:name => params[:name], :teacher_id => teacher_id)
@team.team_members.update_all(:is_teacher => 0)
if @team.user.user_extensions.identity == 0
@team.team_members.where(:user_id => @team.user_id).update_all(:is_teacher => 1)
end
is_teacher = @team.user.user_extensions.identity == 0
return unless member_and_teacher_count_valid?(is_teacher)
ActiveRecord::Base.transaction do
unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now
@team.update_attributes(name: params[:name]) if params[:name].present?
team_member_ids = @team.team_members.where(:role => 2, :is_teacher => 0).map(&:user_id)
new_member_ids = (params[:member_ids] || []).collect(&:to_i)
team_member_ids = @team.team_members.where(role: 2, is_teacher: 0).pluck(:user_id)
new_member_ids = (params[:member_ids].presence || []).map(&:to_i)
new_member_ids << @team.user_id unless is_teacher
# 删除的成员
delete_member_ids = team_member_ids - new_member_ids
@team.team_members.where(:role => 2, :user_id => delete_member_ids).destroy_all
@team.team_members.where(role: 2, user_id: delete_member_ids).delete_all
# 新增加的成员
(new_member_ids - team_member_ids).each do |user_id|
@team.team_members << TeamMember.new(:user_id => user_id, :role => 2, :competition_id => @competition.id)
next if user_id.to_i == @team.user_id
@team.team_members.create!(user_id: user_id, role: 2, competition_id: @competition.id)
end
end
end
# 判断之前是否已存在指导老师,不存在则创建 否则更新
if params[:teacher] && params[:teacher].strip != ""
o_teacher = @team.team_members.where(:is_teacher => 1).first
unless o_teacher.present? && o_teacher.user_id == params[:teacher].to_i
if o_teacher.present?
o_teacher.update_attributes(:user_id => params[:teacher])
else
teacher = @team.team_members.where(:user_id => params[:teacher]).first
if teacher.present?
teacher.update_column("is_teacher", 1)
else
@team.team_members << TeamMember.new(:user_id => params[:teacher], :role => 2, :competition_id => @competition.id, :is_teacher => 1)
end
end
teacher_ids = @team.teachers.pluck(:user_id)
new_teacher_ids = (params[:teacher_ids].presence || []).map(&:to_i)
new_teacher_ids << @team.user_id if is_teacher
# 删除的老师
delete_teacher_ids = teacher_ids - new_teacher_ids
@team.team_members.where(role: 3, user_id: delete_teacher_ids).delete_all
# 新增加的老师
(new_teacher_ids - teacher_ids).each do |user_id|
next if user_id.to_i == @team.user_id
@team.team_members.create!(user_id: user_id, role: 3, competition_id: @competition.id, is_teacher: true)
end
@team.update_attributes(:teacher_id => params[:teacher])
elsif @team.user.user_extensions.identity != 0
@team.update_attributes(:teacher_id => nil)
@team.team_members.where(:is_teacher => 1).destroy_all
end
end
# @status:提示语标志0加入成功1邀请码错误2已经加入了其他队, 3超过人数限制4已有指导老师5只有学生和老师身份的用户才能加入战队
def join_team
team = @competition.competition_teams.where(:invite_code => params[:code]).first
if team.present?
if TeamMember.where(:user_id => User.current.id, :competition_team_id => @competition.competition_teams.map(&:id), :is_teacher => 0).count > 0
@status = 2
else
# 老师身份加入战队判断是否已有指导老师
if User.current.user_extensions.identity == 0
if team.teacher_id.present?
@status = 4
else
@status = 0
team.update_attributes(:teacher_id => User.current.id)
team.team_members << TeamMember.new(:user_id => User.current.id, :role => 2, :competition_id => @competition.id, :is_teacher => 1)
end
elsif User.current.user_extensions.identity == 1
if team.team_members.count < @competition.max_num.to_i
team.team_members << TeamMember.new(:user_id => User.current.id, :role => 2, :competition_id => @competition.id)
@status = 0
else
@status = 3
end
else
@status = 5
end
team = @competition.competition_teams.where(invite_code: params[:code]).first
if team.blank?
@status, @message = -1, '战队邀请码错误'
return
end
if TeamMember.where(:user_id => User.current.id, :competition_team_id => @competition.competition_teams.map(&:id), :is_teacher => 0).count > 0
@status, @message = -1, '您已加入战队,不能重复加'
return
end
if team.team_members.where(user_id: User.current.id).exists?
@status, @message = -1, '您已加入该战队'
return
end
# 老师身份加入战队
if User.current.user_extensions.identity == 0
teacher_staff = @competition.where(category: 'teacher').first
if teacher_staff.blank?
@status, @message = -1, '该竞赛不能配备导师'
return
end
if team.teachers.count + 1 > teacher_staff.maximum
@status, @message = -1, '该战队导师人数已满'
return
end
team.team_members.create!(user_id: User.current.id, role: 3, competition_id: @competition.id, is_teacher: true)
else
@status = 1
max_member_count = @competition.where('category != "teacher"').sum(:maximum)
if team.members.count + 1 > max_member_count
@status, @message = -1, '该战队成员人数已满'
return
end
team.team_members.create!(user_id: User.current.id, role: 2, competition_id: @competition.id)
end
end
@ -169,9 +172,6 @@ class CompetitionTeamsController < ApplicationController
def exit_team
team_member = @team.team_members.where(:user_id => User.current.id).first
if team_member.present?
if team_member.is_teacher
@team.update_attributes(:teacher_id => nil)
end
if team_member.user_id != @team.user_id
team_member.destroy
@status = 1
@ -214,4 +214,33 @@ class CompetitionTeamsController < ApplicationController
rescue ActiveRecord::RecordNotFound
render_404
end
def member_and_teacher_count_valid?(is_teacher)
teacher_staff = @competition.competition_staffs.where(category: 'teacher').first
teacher_count = params[:teacher_ids].try(:size) || 0
teacher_count += 1 if is_teacher
# 检查老师数量
if teacher_staff.blank? && teacher_count > 0
@status, @message = -1, '该竞赛不能配备导师'
return false
elsif teacher_staff.present? && (teacher_staff.minimum > teacher_count || teacher_staff.maximum < teacher_count)
@status = -1
@message = teacher_staff.maximum == teacher_staff.maximum ? "导师数量应为#{teacher_staff.minimum}" : "导师数量应为#{teacher_staff.minimum}-#{teacher_staff.maximum}"
return false
end
member_relations = @competition.competition_staffs.where('category != "teacher"')
min_member_count = member_relations.sum(:minimum)
max_member_count = member_relations.sum(:maximum)
member_count = params[:member_ids].try(:size) || 0
member_count += 1 unless is_teacher
# 检查成员数据
if min_member_count > member_count || member_count > max_member_count
@status = -1
@message = min_member_count == max_member_count ? "成员数量应为#{max_member_count}" : "成员数量应为#{min_member_count}-#{max_member_count}"
return false
end
true
end
end

@ -110,8 +110,12 @@ class CompetitionsController < ApplicationController
@team_members_count = TeamMember.where(:competition_team_id => @teams.pluck(:id)).count
@is_enroll = CompetitionTeam.where(:id => TeamMember.where(:user_id => @user, :competition_team_id => @competition.competition_teams.map(&:id)).pluck(:competition_team_id)).reorder("created_at desc")
@show_notice = (@competition.identifier == "gcc-dev-2018" || @competition.identifier == "gcc-annotation-2018") && @competition.competition_teams.where(:user_id => User.current.id, :teacher_id => nil).count > 0
@teams = paginateHelper @teams, 50
@show_notice = (@competition.identifier == "gcc-dev-2018" || @competition.identifier == "gcc-annotation-2018") &&
@competition.competition_teams.joins(:team_members).where(:user_id => User.current.id).group('competition_teams.id').sum('IF(team_members.is_teacher=1, 1, 0)').values.any?(&:zero?)
@teams = paginateHelper @teams.includes(:user, teachers: :user, members: :user), 50
@minimum_staff = @competition.competition_staffs.sum(:minimum)
@maximum_staff = @competition.competition_staffs.sum(:maximum)
respond_to do |format|
format.js
format.html
@ -458,41 +462,51 @@ class CompetitionsController < ApplicationController
def competition_setting
# @competition = Competition.find params[:id]
if params[:md_name]
md_modules = @competition.competition_modules.where(:md_edit => true)
md_modules.destroy_all if md_modules
params[:md_name].each_with_index do |name, index|
hidden = params[:md_checked][index].to_i == 0 ? 1 : 0
cm = CompetitionModule.create(:competition_id => @competition.id,:name => name, :position => params[:md_position][index], :hidden => hidden, :md_edit => true)
# 创建md_contents
CompetitionModuleMdContent.create(:competition_module_id => cm.id)
ActiveRecord::Base.transaction do
if params[:md_name]
md_modules = @competition.competition_modules.where(:md_edit => true)
md_modules.destroy_all if md_modules
params[:md_name].each_with_index do |name, index|
hidden = params[:md_checked][index].to_i == 0 ? 1 : 0
cm = CompetitionModule.create(:competition_id => @competition.id,:name => name, :position => params[:md_position][index], :hidden => hidden, :md_edit => true)
# 创建md_contents
CompetitionModuleMdContent.create(:competition_module_id => cm.id)
end
end
end
if params[:competition_module]
@competition.competition_modules.where(:id => params[:competition_module], :md_edit => false).update_all(:hidden => 0)
none_modules = @competition.competition_modules.where("name != '首页' and md_edit = false").map(&:id).join(",").split(",") - params[:competition_module]
@competition.competition_modules.where(:id => none_modules).update_all(:hidden => 1)
end
if params[:name]
@competition.competition_modules.where("name not in ('首页', '报名', '通知公告', '排行榜', '资料下载') and md_edit = false").each_with_index do |mod, index|
mod.update_attribute("name", params[:name][index])
if params[:competition_module]
@competition.competition_modules.where(:id => params[:competition_module], :md_edit => false).update_all(:hidden => 0)
none_modules = @competition.competition_modules.where("name != '首页' and md_edit = false").map(&:id).join(",").split(",") - params[:competition_module]
@competition.competition_modules.where(:id => none_modules).update_all(:hidden => 1)
end
end
if params[:url]
@competition.competition_modules.where("name not in ('首页', '报名', '通知公告', '排行榜') and md_edit = false").each_with_index do |mod, index|
mod.update_attribute("url", params[:url][index])
if params[:name]
@competition.competition_modules.where("name not in ('首页', '报名', '通知公告', '排行榜', '资料下载') and md_edit = false").each_with_index do |mod, index|
mod.update_attribute("name", params[:name][index])
end
end
end
if params[:position]
@competition.competition_modules.where(:md_edit => false).each_with_index do |mod, index|
mod.update_attribute("position", params[:position][index])
if params[:url]
@competition.competition_modules.where("name not in ('首页', '报名', '通知公告', '排行榜') and md_edit = false").each_with_index do |mod, index|
mod.update_attribute("url", params[:url][index])
end
end
end
@competition.update_attributes(:identifier => params[:identifier], :min_num => params[:min_num], :max_num => params[:max_num], :enroll_end_time => params[:enroll_end_time])
if params[:new_name]
params[:new_name].each_with_index do |new_module, index|
@competition.competition_modules << CompetitionModule.new(:name => new_module, :position => params[:new_position][index], :hidden => 0, :url => params[:new_url][index])
if params[:position]
@competition.competition_modules.where(:md_edit => false).each_with_index do |mod, index|
mod.update_attribute("position", params[:position][index])
end
end
@competition.update_attributes(:identifier => params[:identifier], :enroll_end_time => params[:enroll_end_time])
if params[:competition_staffs].present?
@competition.competition_staffs.delete_all
params[:competition_staffs].each_with_index do |staff_params, index|
@competition.competition_staffs.create(staff_params.merge(position: index + 1))
end
end
if params[:new_name]
params[:new_name].each_with_index do |new_module, index|
@competition.competition_modules << CompetitionModule.new(:name => new_module, :position => params[:new_position][index], :hidden => 0, :url => params[:new_url][index])
end
end
end
end

@ -1194,12 +1194,14 @@ class CoursesController < ApplicationController
@exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc")
@tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc")
=begin
@homeworks.where(:homework_type => 4).each do |homework|
items = homework.student_works.where("work_status != 0")
if items.count == 0 && homework.publish_time < Time.now && !@course.is_end
update_shixun_work_status homework
end
end
=end
respond_to do |format|
format.xls {
@ -2383,12 +2385,13 @@ class CoursesController < ApplicationController
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
#sheet1.row(0).default_format = blue
#sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)])
teacher_co = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet1[0,0] = "课程编号"
sheet1[0,1] = course.id
sheet1[1,0] = "课程名称"
sheet1[1,1] = course.name
sheet1[2,0] = "教师团队"
sheet1[2,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet1[2,1] = teacher_co
sheet1[3,0] = "主讲教师"
sheet1[3,1] = course.teacher.show_real_name
sheet1[4,0] = "排名"
@ -2401,16 +2404,16 @@ class CoursesController < ApplicationController
homeworks.where(:homework_type => 4).each do |homework|
sheet1[4,current_col+=1] = "#{homework.name}"
end
for i in 0 ... homeworks.where(:homework_type => 1).count
for i in 0 ... homeworks.where(:homework_type => 1).size
sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+""
end
for i in 0 ... homeworks.where(:homework_type => 3).count
for i in 0 ... homeworks.where(:homework_type => 3).size
sheet1[4,current_col+=1] = "分组作业第"+(i+1).to_s+""
end
for i in 0 ... exercises.count
for i in 0 ... exercises.size
sheet1[4,current_col+=1] = "试卷第"+(i+1).to_s+""
end
for i in 0 ... tasks.count
for i in 0 ... tasks.size
sheet1[4,current_col+=1] = "毕设任务第"+(i+1).to_s+""
end
@ -2511,15 +2514,15 @@ class CoursesController < ApplicationController
sheet = book.create_worksheet :name => "分班信息"
sheet.row(0).concat(["课程编号", course.id])
sheet.row(1).concat(["课程名称", course.name])
sheet.row(2).concat(["教师团队", (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')])
sheet.row(2).concat(["教师团队", teacher_co])
sheet.row(3).concat(["主讲教师", course.teacher.show_real_name])
sheet.row(4).concat(["序号", "分班名称", "邀请码", "学生数量"])
current_row = 5
course.course_groups.each do |course_group|
course.course_groups.includes(:members).each do |course_group|
sheet[current_row,0]= current_row - 4
sheet[current_row,1]= course_group.name
sheet[current_row,2]= course_group.invite_code
sheet[current_row,3]= course_group.members.count
sheet[current_row,3]= course_group.members.size
current_row += 1
end
end
@ -2530,7 +2533,7 @@ class CoursesController < ApplicationController
sheet2[1,0] = "课程名称"
sheet2[1,1] = course.name
sheet2[2,0] = "教师团队"
sheet2[2,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet2[2,1] = teacher_co
sheet2[3,0] = "主讲教师"
sheet2[3,1] = course.teacher.show_real_name
sheet2.row(4).concat(["排名","学生姓名","昵称","学号","分班","作业完成数(*10","试卷完成数(*10","问卷完成数(*7","资源发布数(*5","帖子发布数(*2","帖子回复数(*1","作业回复数(*1","活跃度"])
@ -2559,14 +2562,14 @@ class CoursesController < ApplicationController
count_row += 1
end
homeworks.where(:homework_type => 4).includes(:student_works).each_with_index do |home, i|
homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "#{home.name}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
sheet[1,0] = "课程名称"
sheet[1,1] = course.name
sheet[2,0] = "教师团队"
sheet[2,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet[2,1] = teacher_co
sheet[3,0] = "主讲教师"
sheet[3,1] = course.teacher.show_real_name
sheet[3,0] = "作业批次"
@ -2575,11 +2578,11 @@ class CoursesController < ApplicationController
sheet[3,1] = home.name
sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
count_row = 5
items = home.student_works.where("work_status != 0").order("work_score desc")
if items.count == 0 && home.publish_time < Time.now && !course.is_end
update_shixun_work_status home
items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc")
end
items = home.score_student_works
# if items.count == 0 && home.publish_time < Time.now && !course.is_end
# update_shixun_work_status home
# items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc")
# end
items.each_with_index do |stu, j|
sheet[count_row,0]= j + 1
sheet[count_row,1] = stu.user.show_real_name
@ -2593,14 +2596,14 @@ class CoursesController < ApplicationController
end
end
homeworks.where(:homework_type => 1).includes(:student_works).each_with_index do |home, i|
homeworks.where(:homework_type => 1).includes(:score_student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "普通作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
sheet[1,0] = "课程名称"
sheet[1,1] = course.name
sheet[2,0] = "教师团队"
sheet[2,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet[2,1] = teacher_co
sheet[3,0] = "主讲教师"
sheet[3,1] = course.teacher.show_real_name
sheet[3,0] = "作业批次"
@ -2615,7 +2618,7 @@ class CoursesController < ApplicationController
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
end
count_row = 5
items = home.student_works.where("work_status != 0").order("work_score desc")
items = home.score_student_works
items.each_with_index do |stu, j|
sheet[count_row,0]= j + 1
sheet[count_row,1] = stu.user.show_real_name
@ -2640,14 +2643,14 @@ class CoursesController < ApplicationController
end
homeworks.where(:homework_type => 3).includes(:student_works).each_with_index do |home, i|
homeworks.where(:homework_type => 3).includes(:score_student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "分组作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
sheet[1,0] = "课程名称"
sheet[1,1] = course.name
sheet[2,0] = "教师团队"
sheet[2,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet[2,1] = teacher_co
sheet[3,0] = "主讲教师"
sheet[3,1] = course.teacher.show_real_name
sheet[3,0] = "作业批次"
@ -2663,7 +2666,7 @@ class CoursesController < ApplicationController
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
end
count_row = 5
items = home.student_works.where("work_status != 0").order("work_score desc")
items = home.score_student_works
items.each_with_index do |stu, j|
sheet[count_row,0] = j + 1
sheet[count_row,1] = stu.user.show_real_name
@ -2688,14 +2691,14 @@ class CoursesController < ApplicationController
end
end
exercises.each_with_index do |exercise, i|
exercises.includes(:score_exercise_users).each_with_index do |exercise, i|
sheet = book.create_worksheet :name => "试卷第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
sheet[1,0] = "课程名称"
sheet[1,1] = course.name
sheet[3,0] = "教师团队"
sheet[3,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet[3,1] = teacher_co
sheet[3,0] = "主讲教师"
sheet[3,1] = course.teacher.show_real_name
sheet[3,0] = "试卷批次"
@ -2705,7 +2708,7 @@ class CoursesController < ApplicationController
sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)])
count_row = 5
items = exercise.exercise_users.where("commit_status != 0").order("score desc")
items = exercise.score_exercise_users
items.each_with_index do |stu, j|
sheet[count_row,0] = j + 1
sheet[count_row,1] = stu.user.show_real_name
@ -2726,7 +2729,7 @@ class CoursesController < ApplicationController
sheet[1,0] = "课程名称"
sheet[1,1] = course.name
sheet[2,0] = "教师团队"
sheet[2,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、')
sheet[2,1] = teacher_co
sheet[3,0] = "主讲教师"
sheet[3,1] = course.teacher.show_real_name
sheet[3,0] = "作业批次"

@ -879,7 +879,7 @@ class ExerciseController < ApplicationController
if @order == "student_id"
@exercise_users_list = @exercise_users_list.includes(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}")
else
@exercise_users_list = @exercise_users_list.includes(:user => {:user_extensions => []}).order("#{@order} #{@b_sort}")
@exercise_users_list = @exercise_users_list.includes(:user => {:user_extensions => []}).order("#{@order} #{@b_sort}, id desc")
end
end

@ -0,0 +1,105 @@
class LibrariesController < ApplicationController
layout 'base_library'
before_filter :require_login
def index
libraries = Library.where(nil)
libraries =
if params[:type] == 'mine'
libraries.where(user_id: current_user.id).order('created_at desc')
else
libraries.where(status: :published).order('visited_count desc')
end
search = params[:search].to_s.strip
libraries = libraries.where('title LIKE :search OR uuid LIKE :search', search: "%#{search}%") if search.present?
per_page = params[:per_page].to_i <= 0 ? 20 : params[:per_page].to_i
@libraries = paginateHelper libraries.includes(user: :user_extensions), per_page
end
def show
@library = Library.find(params[:id])
return redirect_to libraries_path unless admin_or_self?
@library_applies = @library.library_applies.where(status: :refused).order('created_at desc')
@library.increment_visited_count!
end
def new
@library = current_user.libraries.new
end
def create
@library = current_user.libraries.new
Libraries::SaveService.new(@library, current_user, form_params).call
if with_publish?
Libraries::SubmitService.new(@library).call
redirect_to publish_success_libraries_path
else
flash[:message] = '保存成功'
render 'new'
end
rescue ActiveRecord::RecordInvalid => _
render 'new'
rescue Libraries::SubmitService::Error => ex
flash[:message] = ex.message
render 'new'
end
def edit
@library = current_library
redirect_to library_path(id: @library.id) unless @library.editable?
end
def update
@library = current_library
Libraries::SaveService.new(@library, current_user, form_params).call
if with_publish?
Libraries::SubmitService.new(@library).call
redirect_to publish_success_libraries_path
else
flash[:message] = '保存成功'
render 'edit'
end
rescue ActiveRecord::RecordInvalid => _
render 'edit'
rescue Libraries::SubmitService::Error => ex
flash[:message] = ex.message
render 'edit'
end
def publish
Libraries::SubmitService.new(current_library).call
render json: { status: 0 }
rescue Libraries::SubmitService::Error => ex
render json: { status: 0, message: ex.message }
end
def publish_success
end
private
def current_library
@_current_library ||= current_user.libraries.find(params[:id])
end
def form_params
@_form_params ||= begin
hash = params[:library].presence || {}
hash[:attachment_ids] = (params[:attachments].presence || []).values.map{|h| h[:attachment_id]}
hash
end
end
def with_publish?
params[:apply_publish].to_s == 'true'
end
def admin_or_self?
@library.user_id == current_user.id || current_user.admin?
end
end

@ -0,0 +1,47 @@
class Managements::LibraryAppliesController < Managements::BaseController
before_filter :set_menu_type
def index
applies = LibraryApply.order('library_applies.updated_at desc')
search = params[:search].to_s.strip
if search.present?
applies = applies.joins(:library)
.where('libraries.uuid like :search or libraries.title like :search', search: "%#{search}%")
end
applies = applies.where(status: params[:status].presence || :pending)
@library_applies = paginateHelper applies.includes(library: { user: :user_extensions })
respond_to do |format|
format.js
format.html
end
end
def agree
Libraries::AgreeApplyService.new(current_library_apply, current_user).call
render json: { status: 0 }
rescue Libraries::AgreeApplyService::Error => e
render json: { status: -1, message: e.message }
end
def refuse
Libraries::RefuseApplyService.new(current_library_apply, current_user, reason: params[:reason]).call
render json: { status: 0 }
rescue Libraries::RefuseApplyService::Error => e
render json: { status: -1, message: e.message }
end
private
def current_library_apply
@_current_library_apply ||= LibraryApply.find(params[:id])
end
def set_menu_type
@menu_type = 10
@sub_type = 8
end
end

@ -749,6 +749,7 @@ class ShixunsController < ApplicationController
@main_type = MirrorRepository.published_main_mirror
@small_type = MirrorRepository.published_small_mirror
respond_to do |format|
format.html{render :layout => 'base_edu'}
format.json
@ -817,7 +818,7 @@ class ShixunsController < ApplicationController
ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end
end
# 自动构建版本库
#自动构建版本库
repository = Repository.new
repository.shixun = @shixun
repository.type = 'Repository::Gitlab'
@ -877,6 +878,16 @@ class ShixunsController < ApplicationController
ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => new_shixun.id)
end
# 同步配置
@shixun.shixun_service_configs.each do |config|
ShixunServiceConfig.create!(:shixun_id => new_shixun.id,
:cpu_limit => config.cpu_limit,
:lower_cpu_limit => config.lower_cpu_limit,
:memory_limit => config.memory_limit,
:request_limit => config.request_limit,
:mirror_repository_id => config.mirror_repository_id)
end
# 同步复制版本库先fork再修改版本库名
# eduforge用户作为版本库的创建者
repository = Repository.new
@ -1050,6 +1061,7 @@ class ShixunsController < ApplicationController
mirror_ids = (@shixun.shixun_mirror_repositories.blank? ? [] : @shixun.shixun_mirror_repositories.map(&:id))
update_miiror_id = []
@shixun.shixun_mirror_repositories.destroy_all
if params[:main_type].present?
update_miiror_id << params[:main_type].to_i
ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => params[:main_type])
@ -1061,21 +1073,18 @@ class ShixunsController < ApplicationController
ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end
end
# 超级管理员才能保存 中间层服务器pod信息的配置
if User.current.admin? || User.current.business?
@shixun.shixun_service_configs.each_with_index do |config, index|
config.update_attributes(:cpu_limit => params[:cpu_limit][index],
:lower_cpu_limit => params[:lower_cpu_limit][index],
:memory_limit => params[:memory_limit][index],
# :resource_limit => params[:resource_limit][index],
:request_limit => params[:request_limit][index],
:mirror_repository_id => params[:mirror_id][index])
end
@shixun.shixun_service_configs.destroy_all
params[:mirror_id].each_with_index do |mirror_id, index|
ShixunServiceConfig.create!(:shixun_id => @shixun.id,
:cpu_limit => params[:cpu_limit][index],
:lower_cpu_limit => params[:lower_cpu_limit][index],
:memory_limit => params[:memory_limit][index],
# :resource_limit => params[:resource_limit][index],
:request_limit => params[:request_limit][index],
:mirror_repository_id => mirror_id)
end
ActiveRecord::Base.transaction do
begin
@shixun.save!
@ -1160,6 +1169,8 @@ class ShixunsController < ApplicationController
@small_type = MirrorRepository.published_small_mirror
@shixun_main_mirror = @shixun.mirror_repositories.published_main_mirror.first
# 权限
logger.info("###########{User.current.admin?}")
logger.info("#########business:##{User.current.business?}")
@power = (@shixun.status < 2 ? true : ( User.current.admin? ? true : false))
# unless @repository.nil?
# gitlab_address = Redmine::Configuration['gitlab_address']

@ -277,7 +277,7 @@ module ApplicationHelper
:cpuLimit => config.cpu_limit,
:cpuRequest => config.lower_cpu_limit,
:memoryLimit => "#{config.memory_limit}M",
:memoryRequest => "#{config.request_limit}",
:memoryRequest => "#{config.request_limit}M",
:resourceLimit => "#{config.resource_limit}K",
:type => mirror.try(:main_type) == "1" ? "main" : "sub"}
end
@ -745,16 +745,17 @@ module ApplicationHelper
when 9
sub_type == 1 ? "实训留言列表" : ""
when 10
sub_type == 1 ? "实名认证" :
(sub_type == 2 ? "试用授权" :
(sub_type == 3 ? "部门审批" :
(sub_type == 4 ? "单位审批" :
(sub_type == 5 ? "实训发布" :
(sub_type == 6 ? "实训课程发布" : "职业认证")
)
)
)
)
case sub_type
when 1 then '实名认证'
when 2 then '试用授权'
when 3 then '部门审批'
when 4 then '单位审批'
when 5 then '实训发布'
when 6 then '实训课程发布'
when 7 then '职业认证'
when 8 then '文库发布'
else '职业认证'
end
when 11
"工程认证+"
when 12
@ -3079,7 +3080,7 @@ module ApplicationHelper
elsif @syllabus
title << (@syllabus.title.nil? ? "课堂" : @syllabus.title)
else
title << (User.current.id == 2 ? "未登录" : User.current.show_name)
title << (User.current.anonymous? ? "Educoder实践教学" : User.current.show_name)
end
# if first_page.nil? || first_page.web_title.nil?
# title << Setting.app_title unless Setting.app_title == title.last
@ -6610,12 +6611,14 @@ def update_shixun_work_status homework
compelete_status = 1
end
end
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
if setting.publish_time && setting.publish_time < Time.now && setting_time.end_time
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
# 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => homework.id).first
@ -7448,6 +7451,8 @@ def tiding_url tiding
project_pull_requests_path(tiding.parent_container_id)
when 'Department'
my_account_path
when 'Library'
tiding.tiding_type == 'Apply' ? library_applies_path : library_path(tiding.container_id)
end
end

@ -0,0 +1,7 @@
module Util
module_function
def generate_time_uuid
"#{Time.zone.now.strftime('%Y%m%d%H%M%S')}#{Random.rand(10**8).to_i}"
end
end

@ -13,6 +13,7 @@ class Competition < ActiveRecord::Base
has_many :chart_rules, :dependent => :destroy
has_many :competition_scores, :dependent => :destroy
has_many :competition_text_configs, :dependent => :destroy
has_many :competition_staffs, dependent: :destroy
acts_as_attachable
after_create :create_competition_modules

@ -0,0 +1,22 @@
class CompetitionStaff < ActiveRecord::Base
default_scope order: 'position asc'
attr_accessible :minimum, :maximum, :category, :position
belongs_to :competition
validates :position, numericality: { only_integer: true }
validates :minimum, numericality: { only_integer: true, greater_than: 0 }
validates :maximum, numericality: { only_integer: true, greater_than_or_equal_to: lambda { |obj| obj.minimum } }
validates :category, presence: true, inclusion: { in: %w(all teacher student profession) }
def category_text
I18n.t("competition_staff.category.#{category}", locale: 'zh')
end
def self.category_options
%w(all teacher student profession).map do |category|
[I18n.t("competition_staff.category.#{category}", locale: 'zh'), category]
end
end
end

@ -2,7 +2,10 @@
class CompetitionTeam < ActiveRecord::Base
belongs_to :user
belongs_to :competition
has_many :team_members, :dependent => :destroy
has_many :members, conditions: 'is_teacher = 0', class_name: 'TeamMember'
has_many :teachers, conditions: 'is_teacher = 1', class_name: 'TeamMember'
has_many :competition_scores, :dependent => :destroy
# team_type 0组队 1个人
# attr_accessible :invite_code, :name, :team_type

@ -7,6 +7,7 @@ class Exercise < ActiveRecord::Base
has_many :exercise_group_settings, :dependent => :destroy
has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number"
has_many :exercise_users, :dependent => :destroy, :conditions => "exercise_users.is_delete = 0"
has_many :score_exercise_users, :conditions => "exercise_users.is_delete = 0 and commit_status != 0", :order => "exercise_users.score desc"
has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# 课程消息

@ -28,6 +28,7 @@ class HomeworkCommon < ActiveRecord::Base
# has_many :homework_tests, :dependent => :destroy
# has_many :homework_samples, :dependent => :destroy
has_many :student_works, :conditions => "student_works.is_test=0 and student_works.is_delete != 1"
has_many :score_student_works, :class_name => "StudentWork", :conditions => "student_works.is_test=0 and student_works.is_delete != 1 and work_status != 0", :order => "work_score desc"
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :apply_homeworks

@ -0,0 +1,52 @@
class Library < ActiveRecord::Base
include AASM
belongs_to :user
has_many :library_applies, dependent: :delete_all
has_many :attachments, as: :container
attr_accessible :title, :content
validates :title, presence: true
validates :content, presence: true
validates :uuid, presence: true, uniqueness: true
acts_as_attachable
aasm(:status) do
state :pending, initiali: true
state :processing
state :refused
state :published
event :submit do
transitions from: [:pending, :refused], to: :processing
end
event :refuse do
transitions from: :processing, to: :refused
end
event :publish do
transitions from: :processing, to: :published
end
end
def generate_uuid
uuid = Util.generate_time_uuid
while Library.exists?(uuid: uuid)
uuid = Util.generate_time_uuid
end
self.uuid = uuid
end
def increment_visited_count!
Library.connection.execute("update libraries set visited_count = COALESCE(visited_count, 0) + 1 where id = #{id}")
end
def editable?
pending? || refused?
end
end

@ -0,0 +1,19 @@
class LibraryApply < ActiveRecord::Base
include AASM
belongs_to :library
aasm(:status) do
state :pending, initiali: true
state :refused
state :agreed
event :refuse do
transitions from: :pending, to: :refused
end
event :agree do
transitions from: :pending, to: :agreed
end
end
end

@ -273,6 +273,10 @@ class Shixun < ActiveRecord::Base
return name
end
def child_mirror_ids
self.mirror_repositories.where(:main_type => 0).pluck(:id)
end
def mirror_name
self.mirror_repositories.map(&:type_name).blank? ? "" : self.mirror_repositories.map(&:type_name)
end

@ -3,5 +3,5 @@ class TeamMember < ActiveRecord::Base
belongs_to :competition
belongs_to :user
# role 1创建者 2成员 3指导老师
# attr_accessible :role
attr_accessible :role, :user_id, :competition_id, :is_teacher
end

@ -358,6 +358,14 @@ class Tiding < ActiveRecord::Base
" "
when 'Department'
"你选填的二级单位:#{self.container.try(:name)}(#{self.container.try(:school).name})因不符合规范,已被系统删除.请重新选择"
when 'Library'
library = Library.find_by_id(container_id)
if tiding_type == 'Apply'
"申请发布文库:#{library.try(:title)}"
elsif tiding_type == 'System'
text = status == 1 ? "审核已通过" : "审核未通过,<br/>原因:#{extra}"
"你提交的发布文库申请:#{library.try(:title)}#{text}"
end
else
logger.error "error type: 1"
end

@ -250,6 +250,7 @@ class User < Principal
has_many :ec_course_users
has_many :libraries, dependent: :destroy
#####
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }

@ -0,0 +1,32 @@
class Libraries::AgreeApplyService
Error = Class.new(StandardError)
attr_reader :library_apply, :library, :user
def initialize(library_apply, user)
@library_apply = library_apply
@library = library_apply.library
@user = user
end
def call
raise Error, '该状态下不能进行此操作' unless library_apply.may_agree?
ActiveRecord::Base.transaction do
library_apply.agree!
library_apply.library.publish!
# 将消息改为已处理
Tiding.where(container_id: library.id, container_type: 'Library', tiding_type: 'Apply', status: 0).update_all(status: 1)
notify_library_author!
end
end
private
def notify_library_author!
Tiding.create!(user_id: library.user_id, trigger_user_id: 1,
container_id: library.id, container_type: 'Library',
tiding_type: 'System', status: 1)
end
end

@ -0,0 +1,39 @@
class Libraries::RefuseApplyService
Error = Class.new(StandardError)
attr_reader :library_apply, :library, :user, :params
def initialize(library_apply, user, params)
@library_apply = library_apply
@library = library_apply.library
@user = user
@params = params
end
def call
reason = params[:reason].to_s.strip
raise Error, '原因不能为空' if reason.blank?
raise Error, '该状态下不能进行此操作' unless library_apply.may_refuse?
ActiveRecord::Base.transaction do
library_apply.reason = reason
library_apply.refused_at = Time.current
library_apply.refuse
library_apply.save!
library.refuse!
# 将消息改为已处理
Tiding.where(container_id: library.id, container_type: 'Library', tiding_type: 'Apply', status: 0).update_all(status: 1)
notify_library_author!
end
end
private
def notify_library_author!
Tiding.create!(user_id: library.user_id, trigger_user_id: 1,
container_id: library.id, container_type: 'Library',
tiding_type: 'System', status: 2, extra: library_apply.reason)
end
end

@ -0,0 +1,37 @@
class Libraries::SaveService
Error = Class.new(StandardError)
attr_reader :library, :user, :params
def initialize(library, user, params)
@library = library
@user = user
@params = params
end
def call
validate_params!
if library.new_record?
library.user_id = user.id
library.generate_uuid
end
attachment_ids = params.delete(:attachment_ids)
ActiveRecord::Base.transaction do
library.assign_attributes(params)
library.save!
Attachment.where(id: attachment_ids).update_all(container_id: library.id, container_type: 'Library')
end
library
end
private
def validate_params!
raise Error, '附件不能为空' if params[:attachment_ids].blank?
end
end

@ -0,0 +1,31 @@
class Libraries::SubmitService
Error = Class.new(StandardError)
attr_reader :library
def initialize(library)
@library = library
end
def call
raise Error, '该状态下不能提交审核' unless library.may_submit?
ActiveRecord::Base.transaction do
library.published_at = Time.current
library.submit
library.save!
library.library_applies.create!
send_library_apply_notify!
end
end
private
def send_library_apply_notify!
Tiding.create!(user_id: 1, trigger_user_id: library.user_id,
container_id: library.id, container_type: 'Library',
tiding_type: 'Apply', status: 0)
Trustie::Sms.send(mobile: '18711011226', send_type:'publish_library' , name: '管理员') rescue nil
end
end

@ -343,7 +343,7 @@ class UsersService
g = Gitlab.client
g.edit_user(@current_user.gid, :password => params[:new_password])
rescue Exception => e
logger.error "change users password failed! ===> #{e}"
Rails.logger.error "change users password failed! ===> #{e.message}"
end
end
#raise @current_user.errors.full_message

@ -0,0 +1,62 @@
<div class="librariesField">
<li>
<a href="javascript:void(0)" class="color-blue font-18" onclick="$('#_file').click();" data-tip-down="请选择文件上传">上传附件</a>
<!--<p class="color-grey-c">(单个文件<%#= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>以内)</p>-->
<p class="color-grey-c mt7">从我的电脑选择要上传的文档按住CTRL可以上传多份文档</p>
<div id="network_issue" class="fl ml10 color-red none">上传出现错误,请检查您的网络环境,并刷新页面重新上传。</div>
</li>
</div>
<div id="attachments_fields" class="attachments_fields">
<% if defined?(container) && container && container.saved_attachments %>
<% container.attachments.each_with_index do |attachment, i| %>
<span class="attachment clearfix" id="attachments_p<%= i %>">
<i class="iconfont icon-fujian mr5 color-green fl font-14" aria-hidden="true"></i>
<% size = judge_Chinese_num attachment.filename %>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden color-grey fl', :size => size, :style => 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;font-family: Consolas;', :readonly => 'readonly') %>
<span class="color-grey mr10 fl"><%= number_to_human_size attachment.filesize %></span>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span class="attachment clearfix" id="attachments_p<%= i %>">
<label class="panel-form-label fl">&nbsp;</label>
<i class="iconfont icon-fujian mr5 color-green fl font-14" aria-hidden="true"></i>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'hidden atta_input readonly color-grey fl', :style => 'border:none; max-width:980px;', :readonly => 'readonly') %>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt2') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% end %>
</div>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => ie8? ? '' : 'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this);',
:style => ie8? ? '' : 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js',:project =>nil),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:lebel_file_uploding => l(:lebel_file_uploding),
:delete_all_files => l(:text_are_you_sure_all)
} %>
<%= javascript_include_tag 'attachments' %>
<style>
.ui-widget-content{
/*height: 16px;*/
/*width: 200px;*/
top: 320px !important;
float: left;
margin: 5px 10px 0px 10px;
}
</style>

@ -1,7 +1,12 @@
<% none_edit = @team.try(:id).present? && @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<%= labelled_form_for @team, :html => {:id => 'competition_team_form', :multipart => true, :remote => true} do |f| %>
<input type="hidden" id="max_num" value="<%= @competition.max_num %>">
<input type="hidden" id="min_num" value="<%= @competition.min_num %>">
<% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %>
<% min_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:minimum) %>
<% max_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) %>
<input type="hidden" id="teacher_maximum" value="<%= teacher_staff.try(:maximum) || 0 %>">
<input type="hidden" id="teacher_minimum" value="<%= teacher_staff.try(:minimum) || 0 %>">
<input type="hidden" id="member_maximum" value="<%= max_member_staff || 0 %>">
<input type="hidden" id="member_minimum" value="<%= min_member_staff || 0 %>">
<input type="hidden" id="team_id" value="<%= @team.try(:id) %>">
<input type="hidden" name="com_id" value="<%= @competition.id %>">
@ -15,7 +20,8 @@
</div>
<p style="line-height: 27px;height: 27px"><span id="team_name_notice" class="color-orange-tip ml73 none"></span></p>
<div class="df pl20 pr20">
<% if teacher_staff.present? %>
<div class="df pl20 pr20">
<label class="ml10 mt3">导师:</label>
<div class="flex1 pr search-new">
<input type="text" class="input-100-35 fl" <%= @team_user.user_extensions.identity == 0 ? "disabled" : "" %> autocomplete="off" placeholder="请您输入老师姓名进行搜索" id="teacher_search_input"
@ -31,73 +37,82 @@
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="add_teacher()">添加导师</a>
</div>
<p style="line-height: 27px;height: 27px"><span id="teacher_notice" class="color-orange-tip ml73 none"></span></p>
<div class="df pl20 pr20">
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<div class="flex1 search-new">
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input">
<span class="search-span" style="background: #fff;"></span>
<input type="hidden" id="member_id" data-select="0">
<input type="hidden" id="member_name">
<input type="hidden" id="member_school">
<input type="hidden" id="member_student_id">
<a class="fl searchicon" style="top:0px;" onclick="search_non_member_user()"><i class="iconfont icon-sousuo fl"></i></a>
<ul class="pointerTeacher none" id="pointerStudent">
</ul>
<% end %>
<% if min_member_staff > 0 %>
<div class="df pl20 pr20">
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<div class="flex1 search-new">
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input">
<span class="search-span" style="background: #fff;"></span>
<input type="hidden" id="member_id" data-select="0">
<input type="hidden" id="member_name">
<input type="hidden" id="member_school">
<input type="hidden" id="member_student_id">
<a class="fl searchicon" style="top:0px;" onclick="search_non_member_user()"><i class="iconfont icon-sousuo fl"></i></a>
<ul class="pointerTeacher none" id="pointerStudent">
</ul>
</div>
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="<%= none_edit ? '' : 'add_member()' %>">添加成员</a>
</div>
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="<%= none_edit ? '' : 'add_member()' %>">添加成员</a>
</div>
<p style="line-height: 27px;height: 27px"><span id="member_notice" class="color-orange-tip ml73 none"></span></p>
<% end %>
<div class="bor-grey-e ml20 mr20 mt5" id="member_block">
<p class="pt10 pb10 clearfix bor-bottom-greyE personListLine">
<span class="t-c-1">姓名</span>
<span class="t-c-2">角色</span>
<span class="t-c-3">单位</span>
<span class="t-c-4">其他</span>
<span class="t-c-5">操作</span>
<div class="bor-grey-e ml20 mr20 mt5" id="member_block">
<p class="pt10 pb10 clearfix bor-bottom-greyE personListLine">
<span class="t-c-1">姓名</span>
<span class="t-c-2">角色</span>
<span class="t-c-3">单位</span>
<span class="t-c-4">其他</span>
<span class="t-c-5">操作</span>
</p>
<% if @team.try(:id).present? %>
<% creator_teacher = @team.user.user_extensions.identity == 0 %>
<p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li">
<span class="t-c-1"><%= @team.user.show_name %></span>
<span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-3"><%= @team.user.school_name %></span>
<span class="t-c-4"><%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span>
</p>
<% if @team.try(:id).present? %>
<p class="personListLine clearfix pt5 pb5 personListMember" id="create_li">
<span class="t-c-1"><%= @team.user.show_name %></span>
<span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-3"><%= @team.user.school_name %></span>
<span class="t-c-4"><%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span>
<% @team.teachers.includes(user: :user_extensions).each do |teacher| %>
<% next if teacher.user_id == @team.user_id %>
<p class="personListLine clearfix pt5 pb5 personListMember team-teacher team-teacher-<%= teacher.user.id %>">
<input type="hidden" name="teacher_ids[]" value="<%= teacher.user.id %>">
<span class="t-c-1"><%= teacher.user.show_name %></span>
<span class="t-c-2">导师</span>
<span class="t-c-3"><%= teacher.user.school_name %></span>
<span class="t-c-4">职称:<%= teacher.user.identity %></span>
<span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>
</p>
<% if @team.teacher.present? && @team.teacher != @team.user %>
<p class="personListLine clearfix pt5 pb5 personListMember">
<input type="hidden" name="teacher" value="<%= @team.teacher_id %>">
<span class="t-c-1"><%= @team.teacher.show_name %></span>
<span class="t-c-2">导师</span>
<span class="t-c-3"><%= @team.teacher.school_name %></span>
<span class="t-c-4">职称:<%= @team.teacher.identity %></span>
<span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>
</p>
<% end %>
<% @team.team_members.where(:role => 2, :is_teacher => 0).each do |team_user| %>
<p class="personListLine clearfix pt3 pb3 personListMember">
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<span class="t-c-1"><%= team_user.user.show_name %></span>
<span class="t-c-2">成员</span>
<span class="t-c-3"><%= team_user.user.school_name %></span>
<span class="t-c-4">学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %></span>
<span class="t-c-5">
<% unless none_edit %>
<span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span>
<% end %>
</span>
</p>
<% end %>
<% else %>
<p class="personListLine clearfix pt5 pb5 personListMember" id="create_li">
<span class="t-c-1"><%= @team_user.show_name %></span>
<span class="t-c-2"><%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-3"><%= @team_user.school_name %></span>
<span class="t-c-4"><%= @team_user.user_extensions.identity == 0 ? "职称:#{@team_user.identity}" : "学号:#{@team_user.user_extensions.student_id.present? ? @team_user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span>
<% end %>
<% @team.members.includes(user: :user_extensions).each do |team_user| %>
<% next if team_user.user_id == @team.user_id %>
<p class="personListLine clearfix pt3 pb3 personListMember team-member">
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<span class="t-c-1"><%= team_user.user.show_name %></span>
<span class="t-c-2">成员</span>
<span class="t-c-3"><%= team_user.user.school_name %></span>
<span class="t-c-4">学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %></span>
<span class="t-c-5">
<% unless none_edit %>
<span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span>
<% end %>
</span>
</p>
<% end %>
</div>
<% else %>
<% creator_teacher = @team_user.user_extensions.identity == 0 %>
<p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li">
<span class="t-c-1"><%= @team_user.show_name %></span>
<span class="t-c-2"><%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-3"><%= @team_user.school_name %></span>
<span class="t-c-4"><%= @team_user.user_extensions.identity == 0 ? "职称:#{@team_user.identity}" : "学号:#{@team_user.user_extensions.student_id.present? ? @team_user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span>
</p>
<% end %>
</div>
<p class="color-orange none ml20" id="competition_team_form_notice"></p>
<div class="clearfix edu-txt-center mt20">
@ -111,69 +126,81 @@
<script>
function submit_competition_team_form(){
if($("input[name='name']").val().trim() == ""){
$("#team_name_notice").html("请输入战队名").show();
} else{
var max_num = parseInt($("#max_num").val());
var min_num = parseInt($("#min_num").val());
if($("#member_block .personListMember").length > max_num || $("#member_block .personListMember").length < min_num){
$("#competition_team_form_notice").html("战队成员需为"+min_num+"-"+max_num+"人").show();
} else{
$("#team_name_notice").hide();
$("#competition_team_form_notice").hide();
$("#competition_team_form").submit();
hideModal();
}
$("#team_name_notice").html("请输入战队名").show();
return;
}
var teacherMaximum = parseInt($("#teacher_maximum").val());
var teacherMinimum = parseInt($("#teacher_minimum").val());
var memberMaximum = parseInt($("#member_maximum").val());
var memberMinimum = parseInt($("#member_minimum").val());
var teacherCount = $("#member_block .personListMember.team-teacher").length;
if (teacherMaximum != 0 && teacherCount > teacherMaximum || teacherMinimum != 0 && teacherCount < teacherMinimum) {
$("#competition_team_form_notice").html("战队导师需为"+teacherMinimum+"-"+teacherMaximum+"人,现为" + teacherCount + '人').show();
return;
}
var memberCount = $("#member_block .personListMember.team-member").length;
if (memberMaximum != 0 && memberCount > memberMaximum || memberMinimum != 0 && memberCount < memberMinimum) {
$("#competition_team_form_notice").html("战队成员需为"+memberMinimum+"-"+memberMaximum+"人,现为" + memberCount + '人').show();
return;
}
$("#team_name_notice").hide();
$("#competition_team_form_notice").hide();
$("#competition_team_form").submit();
hideModal();
}
function add_teacher(){
if($("#teacher_search_input").attr("disabled") != "disabled"){
if($("#teacher_name").val() == "" || $("#teacher_name").val() != $("#teacher_search_input").val()){
$("#teacher_id").attr("data-select", 0);
$("#teacher_notice").html("指导老师需从搜索下拉列表中选择").show();
} else{
if($("#teacher_id").attr("data-select") == 1){
$("#teacher_notice").html("该老师已添加").show();
} else{
$("#teacher_notice").hide();
$("input[name='teacher']").parent().remove();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember">' +
' <input type="hidden" name="teacher" value="'+$("#teacher_id").val()+'">' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-2">导师</span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
' <span class="t-c-4">职称:'+$("#teacher_title").val()+'</span>' +
' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' +
' </p>';
$(li).insertAfter($("#create_li"));
$("#teacher_id").attr("data-select", 1);
}
}
if($("#teacher_search_input").attr("disabled") != "disabled"){
if($("#teacher_name").val() == "" || $("#teacher_name").val() != $("#teacher_search_input").val()){
$("#teacher_id").attr("data-select", 0);
$("#teacher_notice").html("指导老师需从搜索下拉列表中选择").show();
return;
}
if($("#teacher_id").attr("data-select") == 1 || $(".team-teacher.team-teacher-" + $("#teacher_id").val()).length != 0){
$("#teacher_notice").html("该老师已添加").show();
return;
}
$("#teacher_notice").hide();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-teacher team-teacher-' + $("#teacher_id").val() + '">' +
' <input type="hidden" name="teacher_ids[]" value="'+$("#teacher_id").val()+'">' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-2">导师</span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
' <span class="t-c-4">职称:'+$("#teacher_title").val()+'</span>' +
' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' +
' </p>';
$(li).insertAfter($("#create_li"));
$("#teacher_id").attr("data-select", 1);
}
}
function add_member(){
$("#member_notice").hide();
if($("#member_name").val() == "" || $("#member_name").val() != $("#user_search_input").val()){
$("#member_id").attr("data-select", 0);
$("#member_notice").html("队员需从搜索下拉列表中选择").show();
} else{
if($("#member_id").attr("data-select") == 1){
$("#member_notice").html("该队员已添加").show();
} else{
$("#member_notice").hide();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember">' +
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
' <span class="t-c-2">成员</span>' +
' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
' <span class="t-c-4">学号:'+$("#member_student_id").val()+'</span>' +
' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' +
' </p>';
$("#member_block").append(li);
$("#member_id").attr("data-select", 1);
}
}
$("#member_notice").hide();
if($("#member_name").val() == "" || $("#member_name").val() != $("#user_search_input").val()){
$("#member_id").attr("data-select", 0);
$("#member_notice").html("队员需从搜索下拉列表中选择").show();
return;
}
if($("#member_id").attr("data-select") == 1 || $(".team-member.team-member-" + $("#member_id").val()).length != 0){
$("#member_notice").html("该队员已添加").show();
return;
}
$("#member_notice").hide();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-member team-member-' + $("#member_id").val() + '">' +
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
' <span class="t-c-2">成员</span>' +
' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
' <span class="t-c-4">学号:'+$("#member_student_id").val()+'</span>' +
' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' +
' </p>';
$("#member_block").append(li);
$("#member_id").attr("data-select", 1);
}
$("#user_search_input").on("keydown", function(event){

@ -1,4 +1,4 @@
<p class="pl30 color-orange-tip mt5 pb5 bor-bottom-greyE">只能指定1名指导老师,允许修改</p>
<p class="pl30 color-orange-tip mt5 pb5 bor-bottom-greyE">请选择指导老师,允许修改</p>
<% @teachers.each do |teacher| %>
<li class="clearfix">
<input type="hidden" value="<%= teacher.id %>">

@ -1,7 +1,5 @@
<% if @status == 0 %>
<% if @status == -1 %>
notice_box("<%= @message %>");
<% else %>
notice_box_redirect("<%= enroll_competition_path(@competition) %>", "创建成功");
<% elsif @status == 2 %>
notice_box_redirect("<%= enroll_competition_path(@competition) %>", "创建成功,请尽快填写指导老师");
<% elsif @status == 1 %>
notice_box("您已创建过战队,不能重复创建");
<% end %>
<% end %>

@ -1,13 +1,5 @@
<% if @status == 0 %>
notice_box_redirect("<%= enroll_competition_path(@competition) %>", "加入成功");
<% elsif @status == 1 %>
notice_box("战队邀请码错误");
<% elsif @status == 2 %>
notice_box("您已加入战队,不能重复加");
<% elsif @status == 3 %>
notice_box("战队成员已满,无法加入");
<% elsif @status == 4 %>
notice_box("战队已有指导老师,无法加入");
<% elsif @status == 5 %>
notice_box("非老师/学生身份无法加入战队");
<% if @status != -1 %>
notice_box_redirect("<%= enroll_competition_path(@competition) %>", "加入成功");
<% else %>
notice_box('<%= @message %>')
<% end %>

@ -1 +1,5 @@
notice_box_redirect("<%= enroll_competition_path(@competition) %>", "更新成功");
<% if @status != -1 %>
notice_box_redirect("<%= enroll_competition_path(@competition) %>", "更新成功");
<% else %>
notice_box("<%= @message %>")
<% end %>

@ -0,0 +1,102 @@
<% index = 0 %>
<p class="second_code_1" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></p>
<% index += 1%>
<p class="second_code_2" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></p>
<% index += 1 %>
<%
data = [
[
{
name: 'Java项目',
description: "Weka是基于Java的机器学习与数据挖掘平台汇集了最前沿的机器学习算法包括处理标准数据挖掘问题的几乎所有方法回归、分类、聚类、关联规则以及属性选择等是Java机器学习入门的首选平台。<br/><br/>本项目的Clusters目录中包含了K-Means、层次聚类等多种聚类算法以及相应的聚类效果评估方法的java实现",
task: '标注../weka/clusterers/目录下的所有代码文件。',
link_name: 'CSDN经典聚类算法',
link_url: 'javascript:void(0)'
},
{
name: 'C++项目',
description: "该项目是GitHub上最受欢迎的C++语言实现经典算法与数据结构的项目之一,内容涵盖排序、链表、树结构、图搜索、贪心算法等。学习这些算法的代码实现,可以深刻理解和掌握算法的核心思想,感受算法之美,代码之美,是人工智能时代的基础入门一课。<br/><br/>本项目的sort_search_problems目录涵盖了冒泡排序、快速排序等各类经典排序算法的C++实现。",
task: '标注../sort_search_problems目录下的所有代码文件及对应引用的../include目录中自定义的头文件。',
link_name: 'CSDN十大经典排序算法',
link_url: 'javascript:void(0)'
},
{
name: 'Python项目',
description: "该项目是GitHub上最受欢迎的Python语言实现经典算法的项目之一包含了前沿的神经网络和经典数据结构及算法的Python实现。项目具有兼顾经典和前沿的特点。学习经典算法的源码实现感受经典算法的思想之美、代码之美。<br/><br/>本项目的Sorts目录中包含了冒泡排序、快速排序等各类经典排序算法的Python实现。",
task: '标注../sorts/目录下的所有代码文件。',
link_name: 'CSDN十大经典排序算法',
link_url: 'javascript:void(0)'
},
],
[{},{},{}],
[{},{},{}]
]
%>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="second_code_<%= index + 1 %>" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;">
<%
first_section = stage.competition_stage_sections.first
second_section = stage.competition_stage_sections.second
%>
<div class="enter_panel" style="<%= i.zero? ? "height: 1212px" : ''%>">
<% if i.zero? %>
<p class="challenge_title"><%= stage.name %></p>
<% end %>
<ul class="clearfix challenge_sub_title">
<li class="fl">
<span class="mr20"><%= first_section.try(:name) %></span>
<span><%= format_time first_section.start_time %> ~ <%= com_end_time first_section.end_time %></span>
</li>
<li class="fr">
<span class="mr20"><%= second_section.try(:name) %></span>
<span><%= format_time second_section.try(:start_time) %> ~ <%= com_end_time second_section.try(:end_time) %></span>
</li>
</ul>
<p class="break_word font-18 challenge_describe">
标注说明:每个小组选择一种编程语言的题目,针对标注任务中指定的标注模块,要求对代码模块、模块中的代码文件, 以及文件中的函数必须进行标注,关键代码块、代码行及关键变量等由参赛者自由选择进行标注。 正式赛第一阶段的比赛在标注阶段就开放查看所有人的标注,请大家根据个人理解,写出自己的风格。我们将综合考虑标注的原创性、准确性、 完整性和多样性等不同的维度对标注质量进行评分。第一阶段比赛得分占正赛总比分的30%。
</p>
<ul class="mt30">
<% first_section.competition_entries.each_with_index do |entry, j| %>
<% row_data = data[i][j] %>
<li class="challenge_box">
<p class="challenge_b_t"><%= row_data[:name] || entry.name %></p>
<p class="enter_btn mb40 clearfix">
<%
is_start = Time.now > first_section.start_time
btn_url = is_start ? "#{entry.url}" : "javascript:void(0);"
%>
<a class="setNewBnt <%= is_start ? 'active' : '' %>"
href="<%= btn_url %>"
<%= Time.now > first_section.start_time ? 'target="_blank"' : "" %> ><%= entry.name %></a>
</p>
<% if row_data.present? %>
<p class="challenge_b_d">项目简介</p>
<p class="break-word challenge_b_des"><%= raw row_data[:description] %></p>
<p class="challenge_b_d">标注任务</p>
<p class="break-word challenge_b_des" style="color: #FC2F78;min-height: 60px"><%= row_data[:task] %></p>
<p class="challenge_b_d">经典算法解读:</p>
<ul class="clearfix algorithm">
<a href="<%= row_data[:link_url] %>" target="_blank"><%= row_data[:link_name] %></a>
</ul>
<p class="enter_btn clearfix">
<a href="<%= btn_url %>" target="_blank" class="setNewBnt <%= is_start ? 'active' : '' %>">点击进入代标注模块</a>
</p>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
<% index += 1 %>
<% end %>
<p class="second_code_6" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></p>
<% index += 1 %>
<p class="second_code_7" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></p>
<% index += 1 %>
<p class="second_code_8" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></p>

@ -0,0 +1,33 @@
<% index = 0 %>
<div class="second_1" style="background: url(<%= named_attachment_path(@images.first, @images.first.try(:filename)) %>) no-repeat top center;"></div>
<% index += 1 %>
<div class="second_2" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></div>
<% index += 1 %>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="second_3" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;">
<div class="enter_panel">
<% stage.competition_stage_sections.each do |section| %>
<ul class="mb40">
<p class="mb30 font-22 enter_title">
<span class="mr20 font-bd"><%= section.name %></span>
<span><%= format_time section.start_time %> ~ <%= com_end_time section.end_time %></span>
</p>
<li class="inline enter_btn">
<% "@urls[i][j][k]表示: 第i个比赛的第j个对象的第k个url入口" %>
<% section.competition_entries.each_with_index do |entry| %>
<a class="li-1" href="<%= Time.now > section.start_time ? "#{entry.url}" : "javascript:void(0);" %>" <%= Time.now > section.start_time ? 'target="_blank"' : "" %> ><%= entry.name %></a>
<% end %>
</li>
</ul>
<% end %>
</div>
</div>
<% index += 1 %>
<% end %>
<div class="second_6" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></div>
<% index += 1 %>
<div class="second_7" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></div>
<% index += 1 %>
<div class="second_8" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;"></div>

@ -5,19 +5,19 @@
<% @teams.each do |team| %>
<li class="clearfix">
<%= link_to image_tag(url_to_avatar(team.user), :width => "40", :height => "40", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @competition.max_num > 1 ? team.name : team.user.show_name %>"><%= @competition.max_num > 1 ? team.name : team.user.show_name %></span>
<% if @competition.max_num > 1 %>
<span class="fl mr40 mt10" style="width: 270px;">
<% if team.teacher_id.present? %>
<a href="<%= user_path(team.teacher) %>" class="fl" target="_blank" data-tip-down="指导老师:<%= team.teacher.show_name %>"><%= image_tag(url_to_avatar(team.teacher), :width => "26", :height => "26", :class => "radius fl mr4") %></a>
<% end %>
<% team.team_members.where("user_id != #{team.teacher_id.present? ? team.teacher_id : '-1'}")[0, 9].each do |member| %>
<%= link_to image_tag(url_to_avatar(member.user), :width => "20", :height => "20", :class => "radius fl mr4 mt3"), user_path(member.user), :title => member.user.show_name, :target => "_blank", :class => "fl", :alt => "用户头像" %>
<% end %>
<% if team.team_members.size > 9 %>
<span class="team-p-s mt3">...</span>
<% end %>
</span>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span>
<% if @maximum_staff > 1 %>
<span class="fl mr40 mt10" style="width: 270px;">
<% team.teachers.each do |teacher| %>
<%= link_to image_tag(url_to_avatar(teacher.user), width: 26, height: 26, class: 'radius fl mr4'), user_path(teacher.user), class: 'fl', target: '_blank', data: { 'tip-down' => "指导老师:#{teacher.user.show_name}" } %>
<% end %>
<% team.members.each do |member| %>
<%= link_to image_tag(url_to_avatar(member.user), :width => "20", :height => "20", :class => "radius fl mr4 mt3"), user_path(member.user), :title => member.user.show_name, :target => "_blank", :class => "fl", :alt => "用户头像" %>
<% end %>
<% if team.members.size > 9 %>
<span class="team-p-s mt3">...</span>
<% end %>
</span>
<% end %>
<span class="color-grey-6 fl edu-txt-left task-hide mt10" style="width: 180px;"><%= team.user.school_name %></span>
<span class="color-grey-9 fr mt10"><%= format_time team.created_at %></span>

@ -1,7 +1,7 @@
<div class="enroll-b">
<div class="enroll-t" style="background:url(<%= @competition.identifier == 'gcc-dev-2018' ? '/images/educoder/competition/dev.jpg' : '/images/educoder/competition/anon.jpg' %>) no-repeat top center;">
<div class="educontent">
<% if @competition.max_num > 1 %>
<% if @minimum_staff > 1 %>
<p class="clearfix edu-txt-right mb30">
<% unless User.current.logged? %>
<%= link_to "创建战队", signin_path, :remote => true, :class => "enroll-in-b enroll-in-b-green fr" %>
@ -59,7 +59,7 @@
<div class="educontent" style="width: 934px;">
<% if @is_enroll.present? %>
<div class="pb30">
<% if @competition.max_num > 1 %>
<% if @maximum_staff > 1 %>
<!--战队报名显示-->
<div class="clearfix mt30 pr88">
<% @is_enroll.each do |team| %>
@ -83,7 +83,7 @@
</span>
<span class="fl mr40 mt13 font-16">邀请码:<label class="color-orange"><%= team.invite_code %></label></span>
<% if @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if (User.current.admin? || User.current == team.user) && team.user_id != team.teacher_id %>
<% if User.current.admin? || User.current == team.user %>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr20" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<% end %>
<% else %>
@ -117,7 +117,7 @@
<a href="javascript:void(0);" class="fl task-btn task-btn-orange ml5 mb5" onclick="search_enroll_team();">搜索</a>
<span class="fl mb5 ml10 pr5 none">战队数:<span id="search_teams_count" class="color-orange"></span>个</span>
<span class="fl mb5 ml10 pr5 none">成员数:<span id="team_members_count" class="color-orange"></span>个</span>
<span class="fr mb5 pr5"><%= @competition.max_num > 1 ? "战队总数" : "报名人数" %><span class="color-orange"><%= @team_count %></span>个</span>
<span class="fr mb5 pr5"><%= @maximum_staff > 1 ? "战队总数" : "报名人数" %><span class="color-orange"><%= @team_count %></span>个</span>
<div class="cl"></div>
<%= render :partial => "competitions/team_list" %>
<% else %>

@ -7,5 +7,9 @@
<%= render :partial => "qg_competition" %>
<% elsif @competition.identifier == "gcc-annotation-2018" %>
<%= render :partial => "annotation_2018_competition" %>
<% elsif @competition.identifier == "gcc-dev-2019" %>
<%= render :partial => "qg_second_competition" %>
<% elsif @competition.identifier == "gcc-annotation-2019" %>
<%= render :partial => "gq_second_code_competition" %>
<% end %>
</div>

@ -200,7 +200,11 @@
}
</script>
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-radio fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" onclick="click_<%= exercise_choice.id %>(this);return false;" type="radio" <%= !@can_edit_excercise ? "disabled" : "" %> <%= answer_be_selected?(exercise_choice, User.current) ? "checked" : "" %>>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index + 1).to_s) %>&nbsp;&nbsp;<%= exercise_choice.choice_text %></label>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id">
<div class="fl">
<%= convert_to_char((index + 1).to_s) %>
</div><pre class="fl ml10"><%= exercise_choice.choice_text %></pre>
</label>
</li>
<% end %>
</div>
@ -243,7 +247,11 @@
}
</script>
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-checkbox fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" onclick="click_<%= exercise_choice.id %>(this);return false;" type="checkbox" <%= !@can_edit_excercise ? "disabled" : "" %> <%= answer_be_selected?(exercise_choice, User.current) ? "checked" : "" %>>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index + 1).to_s) %>&nbsp;&nbsp;<%= exercise_choice.choice_text %></label>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id">
<div class="fl">
<%= convert_to_char((index + 1).to_s) %>
</div><pre class="fl ml10"><%= exercise_choice.choice_text %></pre>
</label>
</li>
<% end %>
</div>

@ -153,7 +153,11 @@
id="exercise_<%= exercise_choice.id %>_exercise_choice_id" type="radio" disabled
<%= answer_be_selected?(exercise_choice, user) ? "checked" : "" %>>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index + 1).to_s) %>&nbsp;&nbsp;<%= exercise_choice.choice_text %></label>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id">
<div class="fl">
<%= convert_to_char((index + 1).to_s) %>
</div><pre class="fl ml10"><%= exercise_choice.choice_text %></pre>
</label>
</li>
<% end %>
</div>
@ -168,7 +172,11 @@
<% exercise_choices.each_with_index do |exercise_choice, index| %>
<li class="clearfix">
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-checkbox fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" type="checkbox" disabled <%= answer_be_selected?(exercise_choice, user) ? "checked" : "" %>>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index + 1).to_s) %>&nbsp;&nbsp;<%= exercise_choice.choice_text %></label>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id">
<div class="fl">
<%= convert_to_char((index + 1).to_s) %>
</div><pre class="fl ml10"><%= exercise_choice.choice_text %></pre>
</label>
</li>
<% end %>
</div>
@ -287,7 +295,7 @@
<a href="javascript:void(0)" onclick="toggle_comment_block(<%= exercise_question.id %>, <%= exercise_shixun_answer.id %>)" data-remote="true" class="mr15 color-blue">调分</a>
<% end %>
<% if game.present? && game.status == 2 && !is_answer_correct && game.answer_open %>
<% if game.present? && game.status == 2 && @exercise_user.end_at && game.end_time < @exercise_user.end_at && !is_answer_correct && game.answer_open %>
<span class="color-red mr5">(答案抄袭)</span>
<% end %>
<% score = exercise_shixun_answer.present? ? exercise_shixun_answer.try(:score) : 0 %>

@ -268,7 +268,11 @@
<% exercise_choices.each_with_index do |exercise_choice, index| %>
<div class="clearfix">
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-radio fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" type="radio">
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index + 1).to_s) %>&nbsp;&nbsp;<%= exercise_choice.choice_text %></label>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id">
<div class="fl">
<%= convert_to_char((index + 1).to_s) %>
</div><pre class="fl ml10"><%= exercise_choice.choice_text %></pre>
</label>
</div>
<% end %>
</div>
@ -281,7 +285,11 @@
<% exercise_choices.each_with_index do |exercise_choice, index| %>
<div class="clearfix">
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-checkbox fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" type="checkbox">
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index + 1).to_s) %>&nbsp;&nbsp;<%= exercise_choice.choice_text %></label>
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id">
<div class="fl">
<%= convert_to_char((index + 1).to_s) %>
</div><pre class="fl ml10"><%= exercise_choice.choice_text %></pre>
</label>
</div>
<% end %>
</div>

@ -16,7 +16,8 @@
</ul>
</div>
<div>
<p class="footer_con-p inline lineh-30"><span class="font-18 fl">©</span>&nbsp;2019&nbsp;EduCoder<span class="ml15 mr15">湘ICP备17009477号</span><a href="https://team.trustie.net" style="color: #888;" target="_blank">Trustie</a>&nbsp;&nbsp;&nbsp;&&nbsp;&nbsp;&nbsp;IntelliDE inside.</p>
<p class="footer_con-p inline lineh-30"><span class="font-18 fl">©</span>&nbsp;2019&nbsp;EduCoder<a style="color: #888;" target="_blank" href="http://beian.miit.gov.cn/" class="ml15 mr15">湘ICP备17009477号</a>
<a href="https://team.trustie.net" style="color: #888;" target="_blank">Trustie</a>&nbsp;&nbsp;&nbsp;&&nbsp;&nbsp;&nbsp;IntelliDE inside. <span class="ml15 mr15">版权所有 湖南智擎科技有限公司</span></p>
</div>
<div class="cl"></div>
</div>

@ -25,6 +25,7 @@
<%= link_to "认证", department_ecs_path(:school_id => User.current.ec_school) %>
</li>
<% end %>
<li class="<%= params[:controller] == "libraries" ? "active" : "" %>"><%= link_to '文库', libraries_path %></li>
</ul>
<div class="posi-search" id="posi-search" style="display: none">
<div class="search-all clearfix">

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8">
<title>
<%= h html_title %>
</title>
<meta name="description" content="高校智能课堂与综合实训平台"/>
<meta name="keywords" content="智能课堂,实训项目"/>
<%= csrf_meta_tag %>
<%= favicon %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'css/common', 'css/public', 'css/ketang', 'css/structure', 'prettify', 'css/courses', 'css/popup', 'css/syllabus', 'css/moduel', 'css/font-awesome', 'css/contest', 'css/font-awesome', 'css/edu-class', 'css/edu-popup', 'educoder/magic-check', 'css/edu-common', "css/edu-public", 'educoder/edu-main', 'educoder/edu-all' %>
<%= javascript_include_tag "avatars", "header", "attachments", 'prettify', "edu/application", 'jquery.datetimepicker.js', 'educoder/edu_application', 'educoder/edu_file' %>
<%= javascript_include_tag "/codemirror/lib/codemirror", "/codemirror/mode/javascript/javascript", "/codemirror/addon/hint/show-hint", "/codemirror/addon/hint/javascript-hint", "/codemirror/addon/selection/active-line", "/codemirror/addon/lint/javascript-lint", "/codemirror/addon/lint/css-lint", "/codemirror/addon/lint/lint", "/codemirror/addon/lint/json-lint", "/editormd/lib/codemirror/addon/lint/css-lint" %>
<%= stylesheet_link_tag "/codemirror/lib/codemirror" %>
<%= stylesheet_link_tag '/editormd/css/editormd' %>
<%= javascript_include_tag '/editormd/editormd', '/editormd/lib/marked.min.js', '/editormd/lib/prettify.min.js', '/editormd/lib/raphael.min.js', '/editormd/lib/underscore.min.js', '/editormd/lib/sequence-diagram.min.js',
'/editormd/lib/flowchart.min.js', '/editormd/lib/jquery.flowchart.min.js', '/editormd/editormd.js' %>
<%= yield :header_tags -%>
<!-- MathJax的配置 -->
<script type="text/javascript" src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showMathMenu: false,
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</head>
<!--add by huang-->
<body onload="prettyPrint();" style="height: 100%;background: #fff">
<div class="newContainer"> <!-- 页面全部内容 -->
<div class="newHeader" id="nHeader"> <!-- 头部 -->
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header' %>
<% else %>
<%= render :partial => 'layouts/unlogin_header' %>
<% end %>
</div>
<div class="cl"></div>
<div class="newMain clearfix">
<%= yield %>
<!-------------------侧边提示区域-------------------------->
<%= render :partial => 'users/returnTop_btn' %>
</div>
<!----------------------- 左侧导航栏 ----------------------------->
<%#= render :partial => 'layouts/public_left_info' %>
<%= render :partial => 'layouts/footer' %>
<div class="cl"></div>
<%#= render :partial => 'layouts/new_feedback' %>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<div id="ajax-notice" style="display: none; text-align: center; bottom: 200px; left: 50%; margin-left: -70px; background: #a1a1a1; width: 140px; height: 80px; position: absolute; z-index: 999999;">
<p id="ajax_notice_p" style="text-align: center; color: #fff; font-size: 18px; padding-top: 26px;">分数已保存</p>
</div>
<div id="ajax-modal" style="display:none;"></div>
<%= call_hook :view_layouts_base_body_bottom %>
</div>
</body>
<script>
</script>
</html>

@ -116,6 +116,7 @@
<li><%= link_to '单位审批', unit_managements_path %></li>
<li><%= link_to '实训发布', shixun_authorization_managements_path %></li>
<li><%= link_to '实训课程发布', subject_authorization_managements_path %></li>
<li><%= link_to '文库发布', library_applies_path(status: :pending) %></li>
</ul>
</li>
<li class="fl edu-admin-nav-li edu-position"><a href="javascript:void(0);" class="edu-admin-nav-a">认证+</a>

@ -0,0 +1,115 @@
<p class="lineh-25 font-22 mb20">上传文档</p>
<div class="library-form-container">
<%= form_for(@library) do |f| %>
<%= hidden_field_tag :apply_publish, false %>
<div class="edu-back-white">
<div class="padding30">
<p class="clearfix mb20">
<span class="upload_Title">标题</span>
<%= f.text_field :title, placeholder: '例如:软件工程教学案例', class: 'greyInput winput-240-35 mr20 fl' %>
<span class="color-grey-c font-12 fl mt5">简明扼要介绍文档&视频所包含的主要的内容</span>
</p>
<div>
<%= render partial: 'attachments/from_libraries', locals: { container: @library } %>
</div>
</div>
<div class="padding30 bor-top-greyE">
<div class="clearfix df">
<span class="upload_Title">描述</span>
<div class="flex1">
<div id="libraries_description">
<%= f.text_area :content %>
</div>
</div>
</div>
</div>
<div class="padding30 bor-top-greyE">
<li class="lineh-25 color-grey-6 font-18 mb20">审核说明</li>
<ul class="font-16">
<li>平台管理员将对每天新上传的文档进行审核,审核通过的文档将公开显示,否则将私有化或移除</li>
</ul>
</div>
<div class="padding30 bor-top-greyE">
<li class="lineh-25 color-grey-6 font-18 mb20">温馨提示</li>
<ul class="font-16">
<li>1.请勿上传已设置加密或只读的文档资源</li>
<li>2.可以上传教学积累和撰写的文档资料如教学案例、总结、心得等上传支持的文件最大容量100MB</li>
<li>3.上传涉及侵权内容的文档将会被移除。</li>
<li>4.为营造绿色网络环境,严禁上传违反国家关于互联网相关规定的内容</li>
<li>5.ChromeFirefoxSafariIE11及以上版本浏览器上传</li>
</ul>
</div>
</div>
<div class="operate mt20 mb20 clearfix">
<%= link_to '确认提交', 'javascript:void(0)', class: 'white-btn edu-blueback-btn changebtn mr20 fl apply-publish-btn' %>
<%= link_to '保存', 'javascript:void(0)', class: 'white-btn edu-blueline-btn changebtn mr20 fl submit-btn' %>
</div>
<% end %>
</div>
<script>
/* ------------------------------- 描述md ------------------------------*/
var editormd = editormd("libraries_description", {
width: "100%",
height: 210,
syncScrolling: "single",
//你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/",
tex: true,
watch:false,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]
},
toolbarCustomIcons: {
testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea: true,
autoFocus: false,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity: 0.6,
placeholder: "请输入参考答案",
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: "<%= upload_with_markdown_path(container_id: 0, container_type: 'MarkDown') %>" //url
});
$(function(){
var submitForm = function(){
var title = $("input[name='library[title]']").val();
var content = $("textarea[name='library[content]']").val();
if (!title || title.length == 0) {
alert('请输入标题');
return
}
if (!content || content.length == 0) {
alert('请输入描述');
return
}
if($('.attachments_fields .attachment').length == 0){
alert('请上传附件');
return
}
$('.library-form-container form').submit();
};
$('.apply-publish-btn').on('click', function(){
$('input[name="apply_publish"]').val(true);
submitForm();
});
$('.submit-btn').on('click', submitForm);
var message = '<%= flash[:message] %>';
if (message.length > 0) {
alert(message);
}
})
</script>

@ -0,0 +1,32 @@
<div class="library_list">
<% if @libraries.present? %>
<% @libraries.each do |library| %>
<li class="library_list_item">
<%= link_to image_tag(url_to_avatar(library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(library.user) %>
<div class="flex1">
<p class="task-hide font-16 mb15 lineh-20"><%= link_to library.title, library_path(library) %></p>
<p class="clearfix lineh-20">
<span class="color-grey-3 mr20"><%= link_to library.user.show_real_name, user_path(library.user) %></span>
<span class="color-grey-c mr20"><%= library.visited_count || 0 %> 浏览</span>
<% if params[:type] == 'mine' %>
<span class="color-grey-c mr20">上传时间:<%= library.created_at.strftime('%Y-%m-%d %H:%M') %></span>
<% else %>
<span class="color-grey-c mr20">发布时间:<%= library.published_at.try(:strftime, '%Y-%m-%d %H:%M') %></span>
<% end %>
</p>
</div>
</li>
<% end %>
<% else %>
<%= render :partial => "welcome/no_data" %>
<% end %>
</div>
<div class="mt30 mb50 edu-txt-center clearfix">
<!--这里放分页-->
<div class="inline pages_user_show">
<ul>
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>

@ -0,0 +1,8 @@
<div class="educontent mb50">
<p class="mt10 mb20 clearfix lineh-20">
<%= link_to '文库', libraries_path, class: 'color-grey-9' %> &gt;
<span class="color-grey-3">编辑</span>
</p>
<%= render partial: 'form' %>
</div>

@ -0,0 +1,51 @@
<div class="educontent">
<div class="edu-back-white mb30 mt30">
<p class="padding20-30 clearfix bor-bottom-greyE">
<span class="font-18 fl color-grey-3">文库</span>
<%= link_to '新建', new_library_path, class: 'fr color-blue font-16 mt3' %>
</p>
<div class="clearfix pt20 pl30 pr30">
<ul class="fl library_nav">
<li class="<%= params[:type] == 'mine' ? '' : 'active' %>">
<%= link_to '全部', libraries_path(search: params[:search]), remote: true %>
</li>
<li class="<%= params[:type] == 'mine' ? 'active' : '' %>">
<%= link_to '我的', libraries_path(search: params[:search], type: 'mine'), remote: true %>
</li>
</ul>
<div class="edu-position fr">
<%= hidden_field_tag(:type, params[:type]) %>
<input class="winput-240-30 panel-box-sizing" placeholder="输入文库标题、编号进行检索" type="text" id="search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey" id="search"><i class="fa fa-search"></i></a>
</div>
</div>
</div>
<div class="library-list-container">
<%= render partial: 'library_list' %>
</div>
</div>
<script>
$(function(){
$(".library_nav").on("click","li",function(){
$(".library_nav li").removeClass("active");
$(this).addClass("active");
});
var searchFunc = function() {
var search = $("#search_name").val();
var type = $("input[name='type']").val();
$.ajax({
url: "/libraries",
dataType: 'script',
data: {search: search, type: type}
});
};
$("#search").live("click", searchFunc);
$('#search_name').bind('keypress',function(event) {
if (event.keyCode == "13") {
searchFunc();
}
});
})
</script>

@ -0,0 +1,3 @@
$('input[name="type"]').val('<%= params[:type].to_s %>');
$('#search_name').val('<%= params[:search].to_s %>');
$('.library-list-container').html('<%= j render(partial: 'library_list') %>')

@ -0,0 +1,8 @@
<div class="educontent mb50">
<p class="mt10 mb20 clearfix lineh-20">
<%= link_to '文库', libraries_path, class: 'color-grey-9' %> &gt;
<span class="color-grey-3">新建</span>
</p>
<%= render partial: 'form' %>
</div>

@ -0,0 +1,14 @@
<div class="educontent edu-back-white mt20 successPage">
<div>
<img src="/images/educoder/success.png" width="100" class="mb30">
<div class="lineh-30 ed-txt-center font-24 color-grey-3 font-bd mb15">
<p>恭喜!</p>
<p>文档上传成功</p>
</div>
<p class="lineh-30 ed-txt-center font-16 color-grey-9 font-bd mb15">通过平台管理员审核后,即可公开显示</p>
<li class="inline">
<%= link_to '查看已上传文档', libraries_path(type: 'mine'), class: 'white-btn edu-blueline-btn changebtn mr20 fl' %>
<%= link_to '继续上传', new_library_path, class: 'white-btn edu-blueback-btn changebtn fl' %>
</li>
</div>
</div>

@ -0,0 +1,96 @@
<%
admin_or_self = User.current.admin? || @library.user_id == User.current.id
%>
<div class="educontent mb50">
<p class="mt10 mb20 clearfix lineh-20">
<%= link_to '文库', libraries_path, class: 'color-grey-9' %> &gt;
<span class="color-grey-3">详情</span>
</p>
<p class="lineh-25 mb20 clearfix">
<span class="font-22 fl mr10 task-hide" style="max-width: 800px"><%= @library.title %></span>
<% if admin_or_self %>
<% if @library.pending? %>
<span class="fl edu-filter-btn edu-activity-green mt5">草稿</span>
<% elsif @library.processing? %>
<span class="fl edu-filter-btn edu-activity-green mt5">审核中</span>
<% elsif @library.refused? %>
<span class="fl edu-filter-btn edu-activity-orange mt5">未通过</span>
<% end %>
<% end %>
<%= link_to('返回', libraries_path, class: 'fr color-grey-9 mt5') %>
</p>
<div class="edu-back-white">
<% if admin_or_self && !@library.published? && @library_applies.size > 0 %>
<div class="padding30">
<p class="mb10 clearfix">
<span class="color-grey-6 font-16 mr10">私有化原因</span>
<span class="color-grey-c font-12">(请按照提示修改,并在完成编辑后重新提交)</span>
<a href="javascript:void(0)" class="color-blue fr" at="0" onclick="getMore(this)">点击展开<i class="iconfont icon-xiajiantou color-blue font-14 ml5"></i></a>
</p>
<div class="private_reason">
<% @library_applies.each do |apply| %>
<li>
<p class="color-grey-9"><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></p>
<p class="lineh-25 font-16 break-word"><%= apply.reason %></p>
</li>
<% end %>
</div>
</div>
<% end %>
<div class="padding30 bor-top-greyE">
<p class="mb10 clearfix">
<span class="color-grey-6 font-16 mr10">详情</span>
<% if admin_or_self && @library.editable? %>
<%= link_to '编辑', edit_library_path(id: @library.id), class: 'white-btn edu-blueline-btn fr' %>
<% end %>
</p>
<div class="df mb20">
<%= link_to image_tag(url_to_avatar(@library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(@library.user) %>
<div class="flex1">
<li class="font-16"><%= @library.user.show_real_name %></li>
<li class="clearfix">
<span class="fl color-grey-9 mr20"><%= @library.user.school_name %></span>
<span class="fl color-grey-9"><%= @library.user.identity %></span>
<span class="fr">
<span class="fl color-grey-9 mr30">编码:<span class="color-grey-6"><%= @library.uuid %></span></span>
<% if @library.published? %>
<span class="fl color-grey-9">发布时间:<span class="color-grey-6"><%= @library.published_at.strftime('%Y-%m-%d %H:%M') %></span></span>
<% else %>
<span class="fl color-grey-9">上传时间:<span class="color-grey-6"><%= @library.created_at.strftime('%Y-%m-%d %H:%M') %></span></span>
<% end %>
</span>
</li>
</div>
</div>
<div>
<div class="break_full_word new_li" id="labraries_editorMd_content">
<textarea style="display:none;"><%= @library.content %></textarea>
</div>
<div class="mt10">
<%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %>
</div>
</div>
</div>
</div>
</div>
<script>
function getMore(item) {
var at=$(item).attr("at");
if(at=="0"){
$(item).html('点击收起<i class="iconfont icon-shangjiantou color-blue font-14 ml5"></i>');
$(item).attr("at","1");
$(".private_reason").css({maxHeight:"unset"});
}else{
$(item).html('点击展开<i class="iconfont icon-xiajiantou color-blue font-14 ml5"></i>');
$(item).attr("at","0");
$(".private_reason").css({maxHeight:"150px"});
}
}
var homeworkDescr = editormd.markdownToHTML("labraries_editorMd_content", {
htmlDecode: "style,script,iframe", // you can filter tags decode
taskList: true,
tex: true, // 默认不解析
flowChart: true, // 默认不解析
sequenceDiagram: true // 默认不解析
});
</script>

@ -68,13 +68,29 @@
<% end %>
<% if com_module.name == "报名" %>
<div class="fl ContentFillinthebox">
<input type="text" autocomplete="off" class="Other_boxinput" name="min_num" placeholder="1" value="<%= @competition.min_num %>"/> ~
<input type="text" autocomplete="off" class="Other_boxinput" name="max_num" placeholder="1" value="<%= @competition.max_num %>"/> 人
</div>
<div class="fl ml20">
<span>报名截止:</span>
<input type="text" class="winput-240-30" readonly placeholder="请选择截止时间" value="<%= format_time @competition.enroll_end_time %>" name="enroll_end_time" id="enroll_end_time"/>
<div class="fl">
<div class="ContentFillinthebox mb10">
<span>报名截止时间:</span>
<input type="text" class="winput-240-30" readonly placeholder="请选择截止时间" value="<%= format_time @competition.enroll_end_time %>" name="enroll_end_time" id="enroll_end_time"/>
</div>
<div class="competition-staff">
<div>报名要求:<i class="fa fa-plus-circle color-green font-16 ml10 add-competition-staff-btn"></i></div>
<div class="competition-staff-settings mb10 ml30">
<% @competition.competition_staffs.each do |staff| %>
<div class="competition-staff-row mb10">
<%= select_tag('competition_staffs[][category]', options_for_select(CompetitionStaff.category_options, staff.category), class: 'winput-120-30') %>
<input type="text" autocomplete="off" class="Other_boxinput" name="competition_staffs[][minimum]" required="required" value="<%= staff.minimum %>"/>
&nbsp;&nbsp;~&nbsp;&nbsp;
<input type="text" autocomplete="off" class="Other_boxinput" name="competition_staffs[][maximum]" required="required" value="<%= staff.maximum %>"/>
<span class="competition-staff-operate ml10">
<i class="fa fa-trash-o ml5 font-16 delete-icon"></i>
<i class="fa fa-plus-circle color-green font-16 ml10 add-icon"></i>
</span>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
<% if com_module.name != "首页" && com_module.name != "报名" && com_module.name != "通知公告" && com_module.name != "排行榜" %>
@ -149,6 +165,20 @@
</div>
</div>
<div class="competition-staff-row-example" style="display: none">
<div class="competition-staff-row mb10">
<%= select_tag('competition_staffs[][category]', options_for_select(CompetitionStaff.category_options, ''), class: 'winput-120-30') %>
<input type="text" autocomplete="off" class="Other_boxinput" name="competition_staffs[][minimum]" require="required" value="1"/>
&nbsp;&nbsp;~&nbsp;&nbsp;
<input type="text" autocomplete="off" class="Other_boxinput" name="competition_staffs[][maximum]" required="required" value="1"/>
<span class="competition-staff-operate ml10">
<i class="fa fa-trash-o ml5 font-16 delete-icon"></i>
<i class="fa fa-plus-circle color-green font-16 ml10 add-icon"></i>
</span>
</div>
</div>
<% content_for :header_tags do %>
@ -504,4 +534,17 @@
}
})
}
$(function(){
$('.add-competition-staff-btn').on('click', function(){
$('.competition-staff-settings').append($('.competition-staff-row-example').html());
});
$('.competition-staff-settings').on('click', '.add-icon', function(){
$('.competition-staff-settings').append($('.competition-staff-row-example').html());
});
$('.competition-staff-settings').on('click', '.delete-icon', function(){
$(this).parents('.competition-staff-row').remove();
});
})
</script>

@ -0,0 +1,78 @@
<% if @library_applies.present? %>
<% @library_applies.each do |apply| %>
<% user = apply.library.user %>
<% library = apply.library %>
<div class="admin-con-box apply-<%= apply.id %> clearfix">
<a href="<%= user_path(user) %>" target="_blank" class="fl with10 edu-ad-user">
<%= image_tag(url_to_avatar(user), :class => "fl with10 edu-ad-user", :alt => "头像", :width => "50", :height => "50" ) %>
</a>
<div class="fl with90">
<ul>
<li class="clearfix mb5">
<a href="<%= user_path(user) %>" class="fl"><%= user.try(:show_real_name) %></a>
<span class="fl ml30 font-12 mt3 color-grey"><%= time_from_now(apply.created_at) %></span>
<% if apply.pending? %>
<a href="javascript:void(0);" class="fr color-orange" onclick="reject_library_authentication_reason(this);" >拒绝</a>
<a href="javascript:void(0);" class="fr mr15 color-orange" data-remote="true" onclick="library_authorization_gree('<%= apply.id %>');">同意</a>
<% else %>
<a href="javascript:void(0);" class="<%= apply.agreed? ? 'task-btn-green' : '' %> task-btn fr"><%= apply.agreed? ? "已同意" : "已拒绝" %></a>
<% end %>
</li>
<li class="clearfix mb10">
<%= link_to library.title, library_path(library), :target => "_blank" %>
<br>
<%= library.content[0..100] %>
</li>
<% if apply.pending? %>
<div class="undis">
<li class="clearfix edu-form-border mb10">
<label class="edu-form-label fl">原因:</label>
<input type="text" class="task-form-90 task-height-40 panel-box-sizing fl edu-form-noborder" placeholder="我得说点儿什么最多200个字符">
</li>
<li class="clearfix">
<a href="javascript:void(0);" class="task-btn task-btn-orange fr" onclick="library_submit_reject_reason('<%= apply.id %>', this);" >确定</a>
<a href="javascript:void(0);" class="task-btn fr mr10" onclick="library_hide_reject_reason(this);" >取消</a>
</li>
</div>
<% else %>
<% if apply.refused? %>
<li>原因:<span class="color-orange"><%= apply.reason %></span></li>
<% end %>
<% end %>
</ul>
</div>
</div>
<% end %>
<div class="mt20 mb20" style="text-align:center;">
<div class="pages_user_show" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% else %>
<%= render :partial => "welcome/no_data" %>
<% end %>
<script type="text/javascript">
function library_authorization_gree(id){
$.ajax({
url: '/managements/library_applies/' + id + '/agree',
type: 'post',
success: function(data){
if (data && data.status != -1) {
$('#authentication_list .admin-con-box.apply-' + id).remove();
if($('#authentication_list .admin-con-box').length == 0){
location.reload();
}
} else {
alert(data.message);
}
}
})
}
</script>

@ -0,0 +1,120 @@
<div class="edu-class-container mb15">
<div class="edu-con-top clearfix">
<p class="ml15 fl color-grey">文库发布</p>
</div>
<div class="edu-con-bg01 mt15">
<div class="edu-tab clearfix mb20">
<ul id="edu-tab-nav" class="border-bottom-orange">
<li id="edu-tab-nav-1" class="new-tab-nav background-orange" onclick="HoverLi(1);">
<%= link_to "待审批", library_applies_path(status: :pending), class: 'tab_type', remote: true %>
</li>
<li id="edu-tab-nav-2" class="new-tab-nav" onclick="HoverLi(2);">
<%= link_to "已审批", library_applies_path(status: [:refused, :agreed]), class: 'tab_type', remote: true %>
</li>
</ul>
<div class="cl"></div>
<div id="edu-tab-con-1">
<div class="mt10">
<div class="edu-position fr task-form-30 mb10 mr15">
<input class="task-form-100 panel-box-sizing" placeholder="输入文库标题、编号进行检索" type="text" id="search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt10" id="search"><i class="fa fa-search"></i></a>
</div>
<div class="cl"></div>
<div id="authentication_list" class="auth_table">
<%= render :partial => "managements/library_applies/library_apply_list"%>
</div>
</div>
</div>
<div id="edu-tab-con-2" class="undis">
<div class="mt10">
<p class="fl task-form-60 mt8 ml15 clearfix">
<%= link_to "全部", library_applies_path(status: [:refused, :agreed]), :class => "edu-filter-cir-grey mr5 fl font-12 active", :id => "library_all_authentication", :remote => true %>
<%= link_to "同意", library_applies_path(status: :agreed), :class => "edu-filter-cir-grey mr5 fl font-12", :id => "library_agree_authentication", :remote => true %>
<%= link_to "拒绝", library_applies_path(status: :refused), :class => "edu-filter-cir-grey mr5 fl font-12", :id => "library_reject_authentication", :remote => true %>
</p>
<div class="edu-position fr task-form-30 mb10 fr mr15">
<input class="task-form-100 panel-box-sizing" placeholder="输入文库标题、编号进行检索" type="text" id="library_search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt10" id="library_search"><i class="fa fa-search"></i></a>
</div>
<div class="cl"></div>
<div id="library_authentication_list" class="auth_table">
</div>
</div>
</div>
<div class="cl"></div>
</div>
</div>
</div>
<script>
/* -------------------------- 拒绝 ------------------------------------ */
function reject_library_authentication_reason(nThis){
var reason = $(nThis).parent().parent().find('div');
reason.find("input").val("");
reason.toggle();
}
/* -------------------------- 取消 ------------------------------------ */
function library_hide_reject_reason(nThis){
var reason = $(nThis).parent().parent();
reason.find("input").val("");
reason.hide();
}
/* ------------------------- 提交拒绝原因 --------------------------------- */
function library_submit_reject_reason(id, nThis){
var nReason = $(nThis).parent().parent();
var reason = nReason.find("input").val();
if (reason == '') {
alert('请输入原因');
return;
}
$.ajax({
url: '/managements/library_applies/' + id + '/refuse',
type: 'post',
data: {reason: reason},
success: function(data){
if (data && data.status != -1) {
$('#authentication_list .admin-con-box.apply-' + id).remove();
if($('#authentication_list .admin-con-box').length == 0){
location.reload();
}
} else {
alert(data.message);
}
}
});
}
/* -------------------------- 按名字进行搜索(未审批) ----------------------------- */
$("#search").live("click", function(){
var iName = $("#search_name").val();
$.ajax({
url: "/managements/library_applies",
dataType: 'script',
data: { search: iName, status: 'pending' }
});
});
/* ------------------- 按名字进行搜索(已审批)-------------------- */
$("#library_search").live("click", function(){
var iName = $("#library_search_name").val();
var id = $("#library_all_authentication").parent().find(".active").attr("id");
var status = '';
if(id == "library_all_authentication"){
status = ['refused', 'agreed'];
}else if(id=="library_agree_authentication"){
status = 'agreed';
}else{
status = 'refused';
}
$.ajax({
url: "/managements/library_applies",
dataType: 'script',
data: { search: iName, status: status}
});
});
</script>

@ -0,0 +1,30 @@
var nTabIcon_1 = $("#edu-tab-con-1");
var nTabIcon_2 = $("#edu-tab-con-2");
var nTabNav_1 = $("#edu-tab-nav-1");
var nTabNav_2 = $("#edu-tab-nav-2");
var nAudit = $("#library_all_authentication").parent();
<% if params[:status].to_s == 'pending' %>
$("#authentication_list").html("<%= j( render :partial => "managements/library_applies/library_apply_list" ) %>");
nTabNav_1.addClass("background-orange");
nTabNav_2.removeClass("background-orange");
nTabIcon_1.show();
nTabIcon_2.hide();
<% else %>
$("#library_authentication_list").html("<%= j( render :partial => "managements/library_applies/library_apply_list" ) %>");
nTabNav_1.removeClass("background-orange");
nTabNav_2.addClass("background-orange");
nTabIcon_1.hide();
nTabIcon_2.show();
/* -------------------------- 未审批(全部、同意、拒绝点击时动态样式) ------------------------------ */
if(<%= params[:status].to_s == 'agreed' %>){
nAudit.find(".active").removeClass("active");
$("#library_agree_authentication").addClass("active");
}else if(<%= params[:status].to_s == 'refused' %>){
nAudit.find(".active").removeClass("active");
$("#library_reject_authentication").addClass("active");
}else{
nAudit.find(".active").removeClass("active");
$("#library_all_authentication").addClass("active");
}
<% end %>

@ -46,20 +46,20 @@
</div>
</tr>
<script>
$(document).ready(function(){
$.ajax({
url:"<%= repository_tree_changes_project_path(@project, :rev => @rev, :ent_path => ent_path, :gpid => @project.gpid) %>",
type: "GET",
data: "text",
success:function(data){
$('#changes_message_<%=tr_id %>').html(data.message)
$('#changes_author_<%=tr_id %>').html(data.author_name)
$('#changes_time_<%=tr_id %>').html(data.time)
}
});
});
</script>
<!-- <script>-->
<!-- $(document).ready(function(){-->
<!-- $.ajax({-->
<!-- url:"<%#= repository_tree_changes_project_path(@project, :rev => @rev, :ent_path => ent_path, :gpid => @project.gpid) %>",-->
<!-- type: "GET",-->
<!-- data: "text",-->
<!-- success:function(data){-->
<!-- $('#changes_message_<%#=tr_id %>').html(data.message)-->
<!-- $('#changes_author_<%#=tr_id %>').html(data.author_name)-->
<!-- $('#changes_time_<%#=tr_id %>').html(data.time)-->
<!-- }-->
<!-- });-->
<!-- });-->
<!-- </script>-->
<% end %>

@ -71,7 +71,7 @@
<div class="down-select" id="shixun_small_language_option" style="padding: 2px 0px">
<% @small_type.try(:each) do |type| %>
<p data-shixun-value="<%= type.id %>">
<input type="checkbox" class="magic-checkbox" id="mirror_<%= type.id %>" value="<%= type.type_name %>"/>
<input type="checkbox" class="magic-checkbox" id="mirror_<%= type.id %>" value="<%= type.type_name %>" <%= @shixun.child_mirror_ids.include?(type.id) ? "checked" : ""%>/>
<label style="top:0px" for="mirror_<%= type.id %>"><%= type.type_name %></label>
</p>
<% end %>
@ -294,335 +294,416 @@
</div>
</div>
<% end %>
<% if User.current.admin? || User.cuurent.business? %>
<div class="edu-back-white padding40-20 mb20">
<p class="color-grey-6 font-16 mb30">服务配置</p>
<% @shixun.shixun_service_configs.each do |config| %>
<p class="color-grey-6 font-16 mt30"><%= config.mirror_repository.try(:type_name) %></p>
<input type="hidden" name="mirror_id[]" value="<%= config.mirror_repository.try(:id) %>'">
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="cpu_limit[]" value="<%= config.cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
<div class="edu-back-white padding40-20 mb20">
<p class="color-grey-6 font-16 mb30">服务配置</p>
<% @shixun.shixun_service_configs.each do |config| %>
<div id="<%= config.mirror_repository.try(:id) %>" >
<p class="color-grey-6 font-16 mt30" id="shixun_scenario_type_name"><%= config.mirror_repository.try(:type_name) %></p>
<input type="hidden" name="mirror_id[]" id="shixun_scenario_type_name_id" value="<%= config.mirror_repository.try(:id) %>">
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" <%= User.current.admin? ? "" : "readonly" %> name="cpu_limit[]" value="<%= config.cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" value="<%= config.lower_cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="<%= config.lower_cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" value="<%= config.memory_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="<%= config.memory_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" value="<%= config.request_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="<%= config.request_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
</div>
</div>
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">磁盘限制(K)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="resource_limit[]" value="<%#= config.resource_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<% end %>
<div id='result'></div>
</div>
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">磁盘限制(K)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="resource_limit[]" value="<%#= config.resource_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<% end %>
<div class="clearfix mt30">
<a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a>
<%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %>
</div>
<% end %>
</div>
<script id="t:edit-setting-list" type="text/html">
<!if(list.length>0) { !>
<!for(var i=0;i
<list.length
;i++){!>
<div id=<!=list[i]!>>
<p class="color-grey-6 font-16 mt30" id="shixun_scenario_type_name">
<!=listname[i]!>
</p>
<input type="hidden" name="mirror_id[]" value=<!=list[i]!>>
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="cpu_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="1" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<% end %>
<div class="clearfix mt30">
<a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a>
<%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="0.1" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<% end %>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="1024" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="10" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
</div>
</div>
<script>
//配置-信息提交
function submit_edit_shixun(id) {
if (regex_shixun_name() && regex_public_unit() && regex_tech_platform()) {
if (script_Codemirror.getValue().trim() == "") {
$("#test_script_code").show();
$(document).scrollTop(parseInt($("#test_script_code").offset().top) - 150);
return;
} else {
$("#test_script_code").hide();
}
if ($("#shixun_exec_time").val() == "")
return;
$("#edit_shixun_" + id).submit();
}
}
function get_mirror_script() {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
var script_id = $("#shixun_scenario").val();
$.ajax({
url: "<%= get_script_contents_shixun_path(@shixun) %>",
data: {script_id: script_id},
success: function (data) {
script_Codemirror.setValue(data.contents);
$("#script_description").html(data.description);
notice_box("评测脚本生成成功!");
},
error: function () {
notice_box("获取脚本失败!")
}
})
}
//自定义模板弹框
function define_temp() {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
}
//下拉框
$("[select-for]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-for]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
var $select, hideValue, textValue, $parent;
$("[select-for] .down-select p").live("click", function () {
$select = $(this).parents(".down-select");
hideValue = $(this).attr("data-shixun-value");
textValue = $(this).html().trim();
$parent = $(this).parent();
var parentId = $(this).parent().attr("id");
if (parentId != "shixun_scenario_option") {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
}
if (parentId == "shixun_language_option") {
var mirror_id = $("#shixun_main_language").val();
$.ajax({
url: "<%= get_mirror_script_shixuns_path %>",
data: {mirror_id: mirror_id},
success: function (data) {
var lens = data.length;
var htmlContents = "";
$("#shixun_scenario").val("");
$("#shixun_scenario_name").val("");
for (var i = 0; i < lens; i++) {
htmlContents += "<p data-shixun-value=\"" + data[i].mirror_script.id + "\" " + "title=\"" + data[i].mirror_script.script_type + "\">" + data[i].mirror_script.script_type + "</p>"
}
$("#shixun_scenario_option").html(htmlContents);
},
error: function () {
notice_box("获取技术平台失败!")
}
});
}
if (parentId == "shixun_scenario_option") {
op_confirm_tip("原有脚本将被新的脚本覆盖,无法撤销<br/>是否确认执行覆盖操作", "get_mirror_script");
}
});
$("input[name='webssh']").on("click", function () {
if ($(this).val() == 2) {
$("#multi_webssh").parent().show();
} else {
$("#multi_webssh").parent().hide();
$("#multi_webssh").attr("checked", false);
}
});
/*----------------------------选择镜像小类别--------------*/
$("[select-more]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-more]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
$("[select-more] .down-select p input").bind("click", function () {
var all = $(this).parents(".down-select");
var arr = "";
var idarr = [];
for (var i = 0; i < all.find("input").length; i++) {
if (all.find("input").eq(i).is(':checked')) {
arr += ";" + (all.find("input").eq(i).attr("value"));
idarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
}
}
$("input[name='small_type']").val(idarr);
$(this).parents().prev("input").val(arr.substring(1));
//$(this).parents(".down-select").hide();
});
$(function () {
//选择自定义脚本
$("#diy_script").click(function () {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
});
$("#webssh").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#vnc").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#can_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#unlock_test_set").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#code_hidden").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#forbid_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#hide_code").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#task_pass").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#scope-down-list").find("li").live("click", function () {
var ul = $(this).parent("ul");
var div = $(this).parents("#unit-input-part");
var value = $(this).html();
ul.siblings("#for_part_search").val(value);
var width = value.length * 2;
var label = "<label class=\"fl unit-part mb10\"><input type='text' size='" + width + "' id='scope_partment' name='scope_partment[]' readonly value='" + value + "'><span class=\"color-orange03 ml5 eud-pointer\">×</span></label>";
div.before(label);
ul.siblings("#for_part_search").attr("data-value-was", value);
$("#person-unit").hide();
$("#scope-down-list").hide();
});
$(".unit-part").find("span").live("click", function () {
$(this).parents(".unit-part").remove();
});
if ($("#public-part").is(":checked")) {
$("#person-unit").show();
$("#person-unit").find("input").val("");
<!}!>
<!}else{!><!}!>
</script>
<script>
//配置-信息提交
function submit_edit_shixun(id) {
if (regex_shixun_name() && regex_public_unit() && regex_tech_platform()) {
if (script_Codemirror.getValue().trim() == "") {
$("#test_script_code").show();
$(document).scrollTop(parseInt($("#test_script_code").offset().top) - 150);
return;
} else {
$("#test_script_code").hide();
}
if ($("#shixun_exec_time").val() == "")
return;
$("#edit_shixun_" + id).submit();
}
}
function get_mirror_script() {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
var script_id = $("#shixun_scenario").val();
$.ajax({
url: "<%= get_script_contents_shixun_path(@shixun) %>",
data: {script_id: script_id},
success: function (data) {
script_Codemirror.setValue(data.contents);
$("#script_description").html(data.description);
notice_box("评测脚本生成成功!");
},
error: function () {
notice_box("获取脚本失败!")
}
})
}
//自定义模板弹框
function define_temp() {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
}
//下拉框
$("[select-for]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-for]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
var $select, hideValue, textValue, $parent;
$("[select-for] .down-select p").live("click", function () {
$select = $(this).parents(".down-select");
hideValue = $(this).attr("data-shixun-value");
textValue = $(this).html().trim();
$("#shixun_scenario_type_name").html(textValue)
$parent = $(this).parent();
var parentId = $(this).parent().attr("id");
if (parentId != "shixun_scenario_option") {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
}
if (parentId == "shixun_language_option") {
var mirror_id = $("#shixun_main_language").val();
$("#shixun_scenario_type_name_id").val(mirror_id)
$.ajax({
url: "<%= get_mirror_script_shixuns_path %>",
data: {mirror_id: mirror_id},
success: function (data) {
var lens = data.length;
var htmlContents = "";
$("#shixun_scenario").val("");
$("#shixun_scenario_name").val("");
for (var i = 0; i < lens; i++) {
htmlContents += "<p data-shixun-value=\"" + data[i].mirror_script.id + "\" " + "title=\"" + data[i].mirror_script.script_type + "\">" + data[i].mirror_script.script_type + "</p>"
}
$("#shixun_scenario_option").html(htmlContents);
},
error: function () {
notice_box("获取技术平台失败!")
}
});
}
if (parentId == "shixun_scenario_option") {
op_confirm_tip("原有脚本将被新的脚本覆盖,无法撤销<br/>是否确认执行覆盖操作", "get_mirror_script");
}
});
$("input[name='webssh']").on("click", function () {
if ($(this).val() == 2) {
$("#multi_webssh").parent().show();
} else {
$("#multi_webssh").parent().hide();
$("#multi_webssh").attr("checked", false);
}
});
/*----------------------------选择镜像小类别--------------*/
$("[select-more]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-more]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
$("[select-more] .down-select p input").bind("click", function () {
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var all = $(this).parents(".down-select");
var arr = "";
var arrs = [];
var idarr = [];
var noidarr=[];
for (var i = 0; i < all.find("input").length; i++) {
if (all.find("input").eq(i).is(':checked')) {
arr += ";" + (all.find("input").eq(i).attr("value"));
arrs.push(all.find("input").eq(i).attr("value"))
idarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
}else{
noidarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
}
}
for(var i=0; i<noidarr.length; i++){
$("#"+noidarr[i]).remove();
}
var data = {
"listname": arrs,
"list": idarr,
"admin":<%= User.current.admin? %>
};
var htmlidarr = bt('t:edit-setting-list', data);
document.getElementById('result').innerHTML = htmlidarr;
$("input[name='small_type']").val(idarr);
$(this).parents().prev("input").val(arr.substring(1));
//$(this).parents(".down-select").hide();
});
$(function () {
//选择自定义脚本
$("#diy_script").click(function () {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
});
$("#webssh").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#vnc").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#can_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#unlock_test_set").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#code_hidden").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#forbid_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#hide_code").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#task_pass").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#scope-down-list").find("li").live("click", function () {
var ul = $(this).parent("ul");
var div = $(this).parents("#unit-input-part");
var value = $(this).html();
ul.siblings("#for_part_search").val(value);
var width = value.length * 2;
var label = "<label class=\"fl unit-part mb10\"><input type='text' size='" + width + "' id='scope_partment' name='scope_partment[]' readonly value='" + value + "'><span class=\"color-orange03 ml5 eud-pointer\">×</span></label>";
div.before(label);
ul.siblings("#for_part_search").attr("data-value-was", value);
$("#person-unit").hide();
$("#scope-down-list").hide();
});
$(".unit-part").find("span").live("click", function () {
$(this).parents(".unit-part").remove();
});
if ($("#public-part").is(":checked")) {
$("#person-unit").show();
$("#person-unit").find("input").val("");
// $(".unit-part").remove();
$("#unit-all").show();
}
$("input[name='public_degree']").live("click", function () {
var item = $(this).attr("id");
if ($(this).is(":checked") && item == "public-part") {
$("#person-unit").show();
$("#person-unit").find("input").val("");
//$(".unit-part").remove();
$("#unit-all").show();
} else {
$("#unit-all").hide();
}
});
$("body").on("click", function (e) {
//alert($(e.target).attr("id"));
if ($(e.target).attr("id") != "person-unit") {
$("#scope-down-list").hide();
}
});
//设置编辑时显示的单位
$(".unit-part input").each(function () {
$(this).attr("size", parseInt($(this).val().length) * 2);
})
});
//申请新建
function post_apply() {
var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>";
pop_box_new(html, 460, 416);
}
var setting_editormd = editormd("setting_introduction", {
width: "100%",
height: 210,
syncScrolling: "single",
//你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/",
tex: true,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]
},
toolbarCustomIcons: {
testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
onload: function () {
$("#setting_introduction [type=\"latex\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("```latex");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("```");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line - 1, 0);
});
$("#setting_introduction [type=\"inline\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("$$$$");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch - 2);
setting_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea: true,
autoFocus: false,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity: 0.6,
placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息",
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
});
md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in");
var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), {
lineNumbers: true,
theme: "default",
// extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
indentUnit: 4, //代码缩进为一个tab的距离
matchBrackets: true,
autoRefresh: true,
smartIndent: true,//智能换行
styleActiveLine: true,
lint: true
});
script_Codemirror.setSize("auto", "600px");
// 非管理员只能查看
</script>
$("#unit-all").show();
}
$("input[name='public_degree']").live("click", function () {
var item = $(this).attr("id");
if ($(this).is(":checked") && item == "public-part") {
$("#person-unit").show();
$("#person-unit").find("input").val("");
//$(".unit-part").remove();
$("#unit-all").show();
} else {
$("#unit-all").hide();
}
});
$("body").on("click", function (e) {
//alert($(e.target).attr("id"));
if ($(e.target).attr("id") != "person-unit") {
$("#scope-down-list").hide();
}
});
//设置编辑时显示的单位
$(".unit-part input").each(function () {
$(this).attr("size", parseInt($(this).val().length) * 2);
})
});
//申请新建
function post_apply() {
var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>";
pop_box_new(html, 460, 416);
}
var setting_editormd = editormd("setting_introduction", {
width: "100%",
height: 210,
syncScrolling: "single",
//你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/",
tex: true,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]
},
toolbarCustomIcons: {
testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
onload: function () {
$("#setting_introduction [type=\"latex\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("```latex");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("```");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line - 1, 0);
});
$("#setting_introduction [type=\"inline\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("$$$$");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch - 2);
setting_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea: true,
autoFocus: false,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity: 0.6,
placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息",
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
});
md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in");
var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), {
lineNumbers: true,
theme: "default",
// extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
indentUnit: 4, //代码缩进为一个tab的距离
matchBrackets: true,
autoRefresh: true,
smartIndent: true,//智能换行
styleActiveLine: true,
lint: true
});
script_Codemirror.setSize("auto", "600px");
// 非管理员只能查看
</script>

@ -0,0 +1,7 @@
'zh':
competition_staff:
category:
all: 不限
teacher: 教师
student: 学生
profession: 专业人士

@ -0,0 +1,8 @@
'zh':
activerecord:
models:
library: '文库'
attributes:
library:
title: '标题'
content: '描述'

@ -730,6 +730,15 @@ RedmineApp::Application.routes.draw do ## oauth相关
get :school_data_grow, controller: 'managements::schools', action: 'data_grow'
get :school_data_contrast, controller: 'managements::schools', action: 'data_contrast'
get :school_statistics_xlsx, controller: 'managements::schools', action: 'statistics_xlsx'
scope module: :managements do
resources :library_applies, only: [:index] do
member do
post :agree
post :refuse
end
end
end
end
end
# Enable Grack support
@ -2649,6 +2658,10 @@ RedmineApp::Application.routes.draw do ## oauth相关
resource :sso, only: [:show, :create]
resources :libraries do
get :publish_success, on: :collection
end
get '/:sub_dir_name', :to => 'org_subfields#show', :as => 'show_subfield_without_id'
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|

@ -0,0 +1,18 @@
class CreateLibraries < ActiveRecord::Migration
def change
create_table :libraries do |t|
t.references :user
t.string :title
t.text :content
t.string :uuid, unique: true
t.string :status
t.integer :visited_count, default: 0
t.datetime :published_at
t.timestamps
end
add_index :libraries, :published_at
end
end

@ -0,0 +1,14 @@
class CreateLibraryApplies < ActiveRecord::Migration
def change
create_table :library_applies do |t|
t.references :library
t.string :status
t.string :reason
t.datetime :refused_at
t.timestamps
end
add_index :library_applies, :refused_at
end
end

@ -1,5 +1,8 @@
class AddLimitForShixuns < ActiveRecord::Migration
def up
if !Challenge.first.has_attribute?(:exec_time)
add_column :challenges, :exec_time, :integer, :default => 120
end
Shixun.find_each do |shixun|
shixun.challenges.update_all(:exec_time => shixun.exec_time)
shixun.mirror_repositories.each do |mirror|

@ -0,0 +1,15 @@
class ModifyRequestLimitForShixunServiceConfig < ActiveRecord::Migration
def up
ShixunServiceConfig.find_each do |config|
# repertoire_id = 5 代表的是大数据的镜像
if config.mirror_repository.repertoire_id != 5
config.update_column(:request_limit, 10)
else
puts("####---#{config.mirror_repository.name}")
end
end
end
def down
end
end

@ -0,0 +1,13 @@
class CreateCompetitionStaffs < ActiveRecord::Migration
def change
create_table :competition_staffs do |t|
t.references :competition
t.integer :position
t.string :category
t.integer :minimum
t.integer :maximum
t.timestamps
end
end
end

@ -57,6 +57,9 @@ module Trustie
elsif send_type == "training_pay"
params['text'] = "【计算机实践教学】亲爱的#{user_name}老师您已经成功报名参与了11月24日--25日在深圳大学举办的全国软件工程实践教学案例与应用研讨会请准时参加。如有任何参会问题请致电咨询会务联系人汤老师13099740868"
Rails.logger.info "#{params['text']}"
elsif send_type == 'publish_library'
params['text'] = "【Edu实训】亲爱的#{name},有新的文库发布申请,请尽快处理"
Rails.logger.info "#{params['text']}"
end
http = Net::HTTP.new(send_tpl_sms_uri.host, send_tpl_sms_uri.port)

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

@ -104,4 +104,8 @@ a:hover.edu-admin-nav-a,.active a.edu-admin-nav-a{color: #5faee3;}
/*超级管理员----技术体系*/
.createsystem{cursor: pointer;width: 100%;height: 70px;line-height: 70px;border:1px dashed #FF7500;color: #FF7500;text-align: center;margin:15px 0px 20px 0px;border-radius: 4px;}
.infoul li{list-style-type: disc}
.infoul li{list-style-type: disc}
/* 竞赛配置 */
.competition-staff-settings .competition-staff-row .competition-staff-operate .add-icon { display: none; }
.competition-staff-settings .competition-staff-row:last-child .competition-staff-operate .add-icon { display: inline; }

@ -602,7 +602,7 @@ p .activity-item:first-child{border-top: 1px solid #eee;}
#competition-content img,#competition-db-content img,#ccfPage img{vertical-align: bottom;}
#hnpage1{background: url('/images/educoder/competition/logo_1.jpg') no-repeat top center;min-height: 820px;}
#competition-header{background: linear-gradient(to right, #29bd8b , #13dc98);height: 60px;width: 100%;padding-right: 40px;box-sizing: border-box;position: fixed;top: 0px;left: 0px;width: 100%;z-index: 1000;}
#competition-header{background:#24292D;height: 60px;width: 100%;padding-right: 40px;box-sizing: border-box;position: fixed;top: 0px;left: 0px;width: 100%;z-index: 1000;}
.nav-game{position: relative;}
.nav-game li{position: relative;float: left;width: 110px;height: 60px;line-height: 60px;text-align: center;box-sizing: border-box}
.nav-game li a{color:#fff;font-size: 16px;}
@ -639,6 +639,83 @@ a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important;
.position-shixun{position: absolute;z-index: 2;bottom: 40px;text-align: center;width: 100%}
.ccf-position-shixun .shixun-btn,.position-shixun .shixun-btn,.ccf-position-shixun-2 .shixun-btn{display: block;float: left;width: 160px;text-align:center;letter-spacing: 1px;height: 40px;line-height: 40px;color:#fff!important;margin:0px 20px;background: linear-gradient(to right, #ff8634 , #ff9d5b);box-shadow: 6px 4px 11px #f7ece4;}
/*第二次竞赛-全国*/
.second_1{min-height: 832px;}
.second_2{min-height: 446px;}
.second_3{min-height: 595px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_4{min-height: 610px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_5{min-height: 617px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_6{min-height: 1053px;}
.second_7{min-height: 1096px;}
.second_8{min-height: 727px;}
.second_code_1{min-height: 791px;}
.second_code_2{min-height: 436px;}
.second_code_3{min-height: 1460px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_code_4{min-height: 724px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_code_5{min-height: 718px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_code_6{min-height: 1060px;}
.second_code_7{min-height: 1116px;}
.second_code_8{min-height: 711px;}
.challenge_title{
color: #41ABEF;font-size: 30px;font-weight: bold;text-align: center;letter-spacing: 1px;line-height: 60px;margin-bottom: 20px;
}
.challenge_sub_title{margin-bottom: 20px;}
.challenge_sub_title li span{color: #0B8298;font-size: 22px;font-weight: bold}
.challenge_sub_title li span:last-child{font-weight: 400!important;font-size: 20px!important;}
.enter_panel{
width: 1200px;margin:0px auto;height: 360px;text-align: center;padding:20px;box-sizing: border-box;
}
.enter_title{
color: #0B8298;
}
.enter_btn a{
float: left;width: 300px;height: 60px;background: #ccc;color: #fff!important;margin:0px 35px;line-height: 60px;
font-size: 22px;font-weight: bold;border-radius: 2px;
}
.enter_btn a.active{
background: #DAECFC;color: #2BC4C6!important;
}
.setNewBnt{width: 100%!important;margin:0px!important;}
.enter_btn a.active:hover{background: #2CDAD4;color: #fff!important;}
.challenge_describe{
color: #51B2C4;text-align: left;line-height: 22px;
}
li.challenge_box{
border:1px solid #ABDCF1;background: #F1F8FD;padding:40px 20px;border-radius: 4px;width: 32%;margin-right: 2%;
box-sizing: border-box;float: left;
}
.challenge_box .challenge_b_t{
font-size: 30px;color: #0E8B87;line-height: 30px;margin-bottom: 30px;
}
.challenge_b_d{
color: #0B8298;font-size: 20px;line-height: 20px;text-align: left;font-weight: bold;margin-bottom: 40px;padding-left: 3px;
}
.challenge_b_des{
line-height: 20px;color: #0B8298;font-size: 18px;text-align: left;text-align:justify;margin-bottom: 40px;min-height: 220px;
}
li.challenge_box:last-child{
margin-right: 0px;
}
.algorithm{margin-bottom: 40px;}
.algorithm a{display: block;text-align: left;color: #23A8FD;position: relative;float: left;font-size: 18px;line-height: 22px;}
.algorithm a:after{position: absolute;left: 0px;bottom: -2px;background:#23A8FD;width: 100%;height: 1px;content: ''; }
@media screen and (max-width: 1600px) {
@ -698,7 +775,7 @@ a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important;
.personListLine > span{float: left;text-align: center;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}
.t-c-1{width: 120px;}
.t-c-2{width: 150px;text-align: left!important;}
.t-c-3{width: 210px;}
.t-c-3{width: 210px;min-height:20px;}
.t-c-4{width: 200px;}
.t-c-5{width: 80px;}
/*东北赛区*/
@ -3249,4 +3326,40 @@ line-height: 16px;display: inline-block;color: rgba(65, 140, 205, 1) !important;
position:absolute;
top: 12px;
right: 20px;
}
/*文库*/
.library_nav li{
float: left;cursor: pointer;margin-right: 30px;position: relative;color: #05101A;height: 40px;line-height: 20px;
font-size: 16px;
}
.library_nav li.active,.library_nav li:hover{
color: #4cacff;
}
.library_nav li.active:after{
position: absolute;content: '';background: #4cacff;color: #4cacff;width: 100%;height: 2px;bottom: 0px;left:0px;
}
.library_list{
margin-bottom: 30px;
}
.library_list_item{
background: #fff;padding:30px;margin-bottom: 15px;display: flex;
}
.upload_Title{
position: relative;margin-right: 30px;float: left;line-height: 35px;font-size: 16px;
}
.upload_Title:before{
position: absolute;left: -10px;top:2px;content: '*';color: #FE4F4C;
}
.librariesField{
width: 100%;background: #F2F9FF;justify-content: center;align-items: center;display: -webkit-flex;text-align: center;
height: 120px;border-radius: 4px;border:1px dashed #4cacff;
}
.private_reason{overflow: hidden;max-height:150px;}
.private_reason li{margin-bottom: 10px;}
.successPage{
justify-content: center;align-items: center;display: -webkit-flex;height: 570px;text-align: center;margin-bottom: 50px;
}
.changebtn{
width: 127px;font-size: 16px;height: 40px; line-height: 40px;
}

@ -180,7 +180,7 @@ a.decoration{text-decoration: underline}
/*定位*/
.pr{position: relative}
.df {display:flex;display: -webkit-flex;display: -ms-flex;}
.flex1{flex: 1;}
.flex1{flex: 1;width: 0}
/*去掉IE input框输入时自带的清除按钮*/
input::-ms-clear{display:none;}
/*自定义滚动条宽度*/
@ -529,6 +529,10 @@ a.edu-blueback-btn{padding: 0px 10px;background: #4CACFF;color: #fff!important;b
a.edu-blueline-btn{padding: 0px 10px;color: #4CACFF!important;border: 1px solid #4CACFF;}
a.edu-blueback-btn:hover{background-color: #459BE6;}
a.edu-blueline-btn:hover{border:1px solid #459BE6;color: #459BE6!important;}
input.edu-blueback-btn{padding: 0px 10px;background: #4CACFF;color: #fff!important;border: 1px solid #4CACFF;}
input.edu-blueline-btn{padding: 0px 10px;color: #4CACFF!important;border: 1px solid #4CACFF;}
input.edu-blueback-btn:hover{background-color: #459BE6;}
input.edu-blueline-btn:hover{border:1px solid #459BE6;color: #459BE6!important;}
a.edu-orangeback-btn{background-color: #ff7500;color: #fff!important;border:1px solid #FF7500}
a.edu-orangeback-btn:hover{background-color: #F06200;}

Loading…
Cancel
Save