dev_local
huang 6 years ago
commit 08d362731a

@ -141,6 +141,7 @@ class AccountController < ApplicationController
@resubmit = "#{code}" @resubmit = "#{code}"
@agreement = Help.first @agreement = Help.first
@cooperation = Cooperation.all @cooperation = Cooperation.all
@url = params[:url]
@com_coop_img = CooImg.where(:img_type => 'com_coop').order("position asc") @com_coop_img = CooImg.where(:img_type => 'com_coop').order("position asc")
@edu_coop_img = CooImg.where(:img_type => 'edu_coop').order("position asc") @edu_coop_img = CooImg.where(:img_type => 'edu_coop').order("position asc")
@ -208,7 +209,7 @@ class AccountController < ApplicationController
end end
def insert_suggest def insert_suggest
content = "<p>[#{params[:question_kind]}]</p>" + params[:description] content = "<p>[#{params[:question_kind]}]</p>" + "<p>问题页面网址:#{params[:url]}</p>" + params[:description]
PrivateMessage.create(:user_id => User.current.id, :target_id => 1, :sender_id => User.current.id, :receiver_id => 1, :content => content, :send_time => Time.now, :status => 1) PrivateMessage.create(:user_id => User.current.id, :target_id => 1, :sender_id => User.current.id, :receiver_id => 1, :content => content, :send_time => Time.now, :status => 1)
PrivateMessage.create(:user_id => 1, :target_id => User.current.id, :sender_id => User.current.id, :receiver_id => 1, :content => content, :send_time => Time.now, :status => 0) PrivateMessage.create(:user_id => 1, :target_id => User.current.id, :sender_id => User.current.id, :receiver_id => 1, :content => content, :send_time => Time.now, :status => 0)
redirect_to message_detail_user_path(User.current, :user_id => 1) redirect_to message_detail_user_path(User.current, :user_id => 1)

@ -16,7 +16,7 @@ class HomeworkCommonController < ApplicationController
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment, before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,
:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works, :start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
:open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation, :open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation,
:cancel_publish, :move_to_category] :cancel_publish, :move_to_category,:homework_setting]
# before_filter :member_of_course, :only => [:index,:setting] # before_filter :member_of_course, :only => [:index,:setting]
@ -282,93 +282,94 @@ class HomeworkCommonController < ApplicationController
end end
def homework_setting def homework_setting
if @homework.homework_detail_manual.try(:comment_status) == 0 && @course.course_groups.count > 1 ActiveRecord::Base.transaction do
@homework.unified_setting = params[:unified_setting] ? true :false if @homework.homework_detail_manual.try(:comment_status) == 0 && @course.course_groups.count > 1
end @homework.unified_setting = params[:unified_setting] ? true :false
end
if @homework.unified_setting if @homework.unified_setting
params_publish_time = params[:homework_publish_time] params_publish_time = params[:homework_publish_time]
params_end_time = params[:homework_end_time] params_end_time = params[:homework_end_time]
# params_archive_time = params[:homework_archive_time] # params_archive_time = params[:homework_archive_time]
min_publish_time = params_publish_time min_publish_time = params_publish_time
max_end_time = params_end_time max_end_time = params_end_time
else else
# 获取最小发布时间和最大截止时间赋值给homework # 获取最小发布时间和最大截止时间赋值给homework
params_publish_time = params[:homework_publish_time_group] params_publish_time = params[:homework_publish_time_group]
params_end_time = params[:homework_end_time_group] params_end_time = params[:homework_end_time_group]
# params_archive_time = params[:homework_archive_time_group] # params_archive_time = params[:homework_archive_time_group]
min_publish_time = @homework.publish_time ? (format_time @homework.publish_time).to_s : "" min_publish_time = @homework.publish_time ? (format_time @homework.publish_time).to_s : ""
max_end_time = @homework.end_time ? (format_time @homework.end_time).to_s : "" max_end_time = @homework.end_time ? (format_time @homework.end_time).to_s : ""
if params[:homework_end_time_group] if params[:homework_end_time_group]
max_end_time = "" max_end_time = ""
params[:homework_end_time_group].each_with_index do |end_time, index| params[:homework_end_time_group].each_with_index do |end_time, index|
if end_time != "" if end_time != ""
if max_end_time == "" || end_time > max_end_time if max_end_time == "" || end_time > max_end_time
max_end_time = end_time max_end_time = end_time
end
end end
end end
end end
end
if params[:homework_publish_time_group] if params[:homework_publish_time_group]
params[:homework_publish_time_group].each_with_index do |publish_time, index| params[:homework_publish_time_group].each_with_index do |publish_time, index|
if publish_time != "" if publish_time != ""
if min_publish_time == "" || publish_time < min_publish_time if min_publish_time == "" || publish_time < min_publish_time
min_publish_time = publish_time min_publish_time = publish_time
end
end end
end end
end end
end end
end
# 不统一设置且分班数大于一则更新分组设置 # 不统一设置且分班数大于一则更新分组设置
if !@homework.unified_setting && @course.course_groups.count > 1 if !@homework.unified_setting && @course.course_groups.count > 1
@course.course_groups.each_with_index do |group, index| @course.course_groups.each_with_index do |group, index|
homework_group_setting = @homework.homework_group_settings.where(:course_group_id => group.id).first homework_group_setting = @homework.homework_group_settings.where(:course_group_id => group.id).first
unless homework_group_setting unless homework_group_setting
homework_group_setting = HomeworkGroupSetting.create(:homework_common_id => @homework.id, :course_group_id => group.id, :course_id => @course.id) homework_group_setting = HomeworkGroupSetting.create(:homework_common_id => @homework.id, :course_group_id => group.id, :course_id => @course.id)
end
end end
end group_id = []
group_id = [] @homework.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").joins(:course_group).reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each_with_index do |setting, index|
@homework.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").joins(:course_group).reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each_with_index do |setting, index| if params[:homework_publish_time_group] && min_publish_time != ""
if params[:homework_publish_time_group] && min_publish_time != "" if params[:homework_publish_time_group][index] && params[:homework_publish_time_group][index] != ""
if params[:homework_publish_time_group][index] && params[:homework_publish_time_group][index] != "" setting.update_column(:publish_time, params[:homework_publish_time_group][index])
setting.update_column(:publish_time, params[:homework_publish_time_group][index]) end
elsif params[:homework_publish_time_group] && min_publish_time == ""
setting.update_column(:publish_time, Time.now)
group_id << setting.course_group_id
end end
elsif params[:homework_publish_time_group] && min_publish_time == ""
setting.update_column(:publish_time, Time.now)
group_id << setting.course_group_id
end end
end
@homework.homework_group_settings.where("end_time is null or end_time > '#{Time.now}'").joins(:course_group).reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each_with_index do |setting, index| @homework.homework_group_settings.where("end_time is null or end_time > '#{Time.now}'").joins(:course_group).reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each_with_index do |setting, index|
if params[:homework_end_time_group] && max_end_time != "" if params[:homework_end_time_group] && max_end_time != ""
if params[:homework_end_time_group][index] && params[:homework_end_time_group][index] != "" if params[:homework_end_time_group][index] && params[:homework_end_time_group][index] != ""
setting.update_column(:end_time, params[:homework_end_time_group][index]) setting.update_column(:end_time, params[:homework_end_time_group][index])
end
elsif params[:homework_end_time_group] && max_end_time == ""
setting.update_column(:end_time, Time.at(((1.month.since.to_i)/3600.0).ceil * 3600))
end end
elsif params[:homework_end_time_group] && max_end_time == ""
setting.update_column(:end_time, Time.at(((1.month.since.to_i)/3600.0).ceil * 3600))
end end
# 统一设置则删除分组设置
elsif @homework.unified_setting
@homework.homework_group_settings.destroy_all
end end
# 统一设置则删除分组设置
elsif @homework.unified_setting
@homework.homework_group_settings.destroy_all
end
# homework 的记录更新 # homework 的记录更新
# 发布时间不为空 # 发布时间不为空
if params_publish_time && min_publish_time != "" if params_publish_time && min_publish_time != ""
@homework.publish_time = min_publish_time @homework.publish_time = min_publish_time
@homework.end_time = max_end_time @homework.end_time = max_end_time
# @homework.archive_time = params_archive_time if params_archive_time # @homework.archive_time = params_archive_time if params_archive_time
if @homework.publish_time < Time.now and @homework_detail_manual.comment_status == 0 if @homework.publish_time < Time.now and @homework_detail_manual.comment_status == 0
@homework_detail_manual.comment_status = 1 @homework_detail_manual.comment_status = 1
create_homework_user = 1 create_homework_user = 1
if @homework.course_acts.size == 0 if @homework.course_acts.size == 0
@homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id) @homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id)
end
end end
end
=begin =begin
if @homework.archive_time < Time.now && @homework_detail_manual.comment_status < 6 if @homework.archive_time < Time.now && @homework_detail_manual.comment_status < 6
@homework_detail_manual.comment_status = 6 @homework_detail_manual.comment_status = 6
@ -376,22 +377,22 @@ class HomeworkCommonController < ApplicationController
@homework_detail_manual.comment_status = 5 @homework_detail_manual.comment_status = 5
end end
=end =end
# 发布时间未设置 则按当前时间立即发布 # 发布时间未设置 则按当前时间立即发布
elsif params_publish_time && min_publish_time == "" elsif params_publish_time && min_publish_time == ""
@homework_detail_manual.comment_status = 1 @homework_detail_manual.comment_status = 1
@homework.publish_time = Time.now @homework.publish_time = Time.now
@homework.unified_setting = 1 @homework.unified_setting = 1
@homework.end_time = Time.at(((1.month.since.to_i)/3600.0).ceil * 3600) @homework.end_time = Time.at(((1.month.since.to_i)/3600.0).ceil * 3600)
# @homework.archive_time = Time.at(((2.months.since.to_i)/3600.0).ceil * 3600) # @homework.archive_time = Time.at(((2.months.since.to_i)/3600.0).ceil * 3600)
create_homework_user = 1 create_homework_user = 1
if @homework.course_acts.size == 0 if @homework.course_acts.size == 0
@homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id) @homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id)
end end
# 已发布的作业,只更新截止时间和结束时间 # 已发布的作业,只更新截止时间和结束时间
else else
@homework.end_time = max_end_time if params_end_time @homework.end_time = max_end_time if params_end_time
# @homework.archive_time = params_archive_time if params_archive_time # @homework.archive_time = params_archive_time if params_archive_time
=begin =begin
if @homework.archive_time < Time.now && @homework_detail_manual.comment_status < 6 if @homework.archive_time < Time.now && @homework_detail_manual.comment_status < 6
@ -400,189 +401,190 @@ class HomeworkCommonController < ApplicationController
@homework_detail_manual.comment_status = 5 @homework_detail_manual.comment_status = 5
end end
=end =end
end end
if params[:homework_allow_late] == '1' if params[:homework_allow_late] == '1'
@homework.allow_late = true @homework.allow_late = true
if @homework.late_penalty != params[:homework_late_penalty].to_i if @homework.late_penalty != params[:homework_late_penalty].to_i
@homework.student_works.where(:work_status => 2).each do |work| @homework.student_works.where(:work_status => 2).each do |work|
work.late_penalty = params[:homework_late_penalty].to_i work.late_penalty = params[:homework_late_penalty].to_i
work.save work.save
end
end end
@homework.late_penalty = params[:homework_late_penalty].to_i
else
@homework.allow_late = false
@homework.late_penalty = 0
end end
@homework.late_penalty = params[:homework_late_penalty].to_i
else
@homework.allow_late = false
@homework.late_penalty = 0
end
anonymous_comment = @homework.anonymous_comment anonymous_comment = @homework.anonymous_comment
absence_penalty = @homework_detail_manual.absence_penalty absence_penalty = @homework_detail_manual.absence_penalty
appeal_penalty = @homework_detail_manual.appeal_penalty appeal_penalty = @homework_detail_manual.appeal_penalty
if @homework_detail_manual.comment_status < 3 if @homework_detail_manual.comment_status < 3
if params[:homework_anonymous_comment] if params[:homework_anonymous_comment]
@homework.anonymous_comment = 0 @homework.anonymous_comment = 0
@homework_detail_manual.evaluation_start = params[:homework_evaluation_start] if params[:homework_evaluation_start] @homework_detail_manual.evaluation_start = params[:homework_evaluation_start] if params[:homework_evaluation_start]
@homework_detail_manual.evaluation_end = params[:homework_evaluation_end] if params[:homework_evaluation_end]
@homework_detail_manual.evaluation_num = params[:homework_evaluation_num] if params[:homework_evaluation_num]
@homework_detail_manual.absence_penalty = params[:homework_absence_penalty] if params[:homework_absence_penalty]
else
@homework.anonymous_comment = 1
@homework_detail_manual.evaluation_start = nil
@homework_detail_manual.evaluation_end = nil
@homework_detail_manual.evaluation_num = 0
@homework_detail_manual.absence_penalty = 0
end
else
@homework_detail_manual.evaluation_end = params[:homework_evaluation_end] if params[:homework_evaluation_end] @homework_detail_manual.evaluation_end = params[:homework_evaluation_end] if params[:homework_evaluation_end]
@homework_detail_manual.evaluation_num = params[:homework_evaluation_num] if params[:homework_evaluation_num] @homework_detail_manual.evaluation_num = params[:homework_evaluation_num] if params[:homework_evaluation_num]
@homework_detail_manual.absence_penalty = params[:homework_absence_penalty] if params[:homework_absence_penalty] @homework_detail_manual.absence_penalty = params[:homework_absence_penalty] if params[:homework_absence_penalty]
end
if anonymous_comment != @homework.anonymous_comment
@homework_detail_manual.te_proportion = 1
@homework_detail_manual.ta_proportion = 0
@homework_detail_programing.ta_proportion = 0 if @homework_detail_programing
end
if @homework_detail_manual.comment_status < 4
if @homework.anonymous_comment == 0 && params[:homework_anonymous_appeal]
@homework.anonymous_appeal = 1
@homework_detail_manual.appeal_time = params[:homework_appeal_time] if params[:homework_appeal_time]
@homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] if params[:homework_appeal_penalty]
else
@homework.anonymous_appeal = 0
@homework_detail_manual.appeal_time = nil
@homework_detail_manual.appeal_penalty = 0
end
else else
@homework.anonymous_comment = 1
@homework_detail_manual.evaluation_start = nil
@homework_detail_manual.evaluation_end = nil
@homework_detail_manual.evaluation_num = 0
@homework_detail_manual.absence_penalty = 0
end
else
@homework_detail_manual.evaluation_end = params[:homework_evaluation_end] if params[:homework_evaluation_end]
@homework_detail_manual.evaluation_num = params[:homework_evaluation_num] if params[:homework_evaluation_num]
@homework_detail_manual.absence_penalty = params[:homework_absence_penalty] if params[:homework_absence_penalty]
end
if anonymous_comment != @homework.anonymous_comment
@homework_detail_manual.te_proportion = 1
@homework_detail_manual.ta_proportion = 0
@homework_detail_programing.ta_proportion = 0 if @homework_detail_programing
end
if @homework_detail_manual.comment_status < 4
if @homework.anonymous_comment == 0 && params[:homework_anonymous_appeal]
@homework.anonymous_appeal = 1
@homework_detail_manual.appeal_time = params[:homework_appeal_time] if params[:homework_appeal_time] @homework_detail_manual.appeal_time = params[:homework_appeal_time] if params[:homework_appeal_time]
@homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] if params[:homework_appeal_penalty] @homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] if params[:homework_appeal_penalty]
else
@homework.anonymous_appeal = 0
@homework_detail_manual.appeal_time = nil
@homework_detail_manual.appeal_penalty = 0
end
else
@homework_detail_manual.appeal_time = params[:homework_appeal_time] if params[:homework_appeal_time]
@homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] if params[:homework_appeal_penalty]
end
if absence_penalty != @homework_detail_manual.absence_penalty && @homework_detail_manual.comment_status >= 4
all_dis_eva = StudentWorksEvaluationDistribution.where(:student_work_id => @homework.student_works.map(&:id))
has_sw_count = all_dis_eva.select("distinct user_id").count
anon_count = all_dis_eva.count / has_sw_count
@homework.student_works.where("work_status != 0").each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).count - student_work.user.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :reviewer_role => 3).count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.save
end end
end if absence_penalty != @homework_detail_manual.absence_penalty && @homework_detail_manual.comment_status >= 4
if appeal_penalty != @homework_detail_manual.appeal_penalty && @homework_detail_manual.comment_status >= 4 all_dis_eva = StudentWorksEvaluationDistribution.where(:student_work_id => @homework.student_works.map(&:id))
@homework.student_works.each do |student_work| has_sw_count = all_dis_eva.select("distinct user_id").count
appeal_penalty_count = student_work.user.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :appeal_status => 3).count anon_count = all_dis_eva.count / has_sw_count
student_work.appeal_penalty = appeal_penalty_count > 0 ? appeal_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.save
end
end
# 助教评分模式有变更 则更新学生分数
if params[:homework_ta_mode] && @homework_detail_manual.ta_mode.to_i != params[:homework_ta_mode].to_i
@homework_detail_manual.ta_mode = params[:ta_mode].to_i
@homework_detail_manual.save
if @homework_detail_manual.ta_mode == 1
@homework.student_works.where("work_status != 0").each do |student_work| @homework.student_works.where("work_status != 0").each do |student_work|
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{student_work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") absence_penalty_count = student_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).count - student_work.user.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :reviewer_role => 3).count
student_work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.save student_work.save
end end
else end
@homework.student_works.where("work_status != 0").each do |student_work| if appeal_penalty != @homework_detail_manual.appeal_penalty && @homework_detail_manual.comment_status >= 4
ts_score = StudentWorksScore.where("student_work_id = #{student_work.id} AND reviewer_role = 2 AND score IS NOT NULL").order("created_at DESC") @homework.student_works.each do |student_work|
student_work.teaching_asistant_score = ts_score.first.nil? ? nil : ts_score.first.score appeal_penalty_count = student_work.user.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :appeal_status => 3).count
student_work.appeal_penalty = appeal_penalty_count > 0 ? appeal_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.save student_work.save
end end
end end
end
# 最终成绩组成 # 助教评分模式有变更 则更新学生分数
if params[:homework_final_mode] && params[:homework_final_mode].to_i != @homework_detail_manual.final_mode if params[:homework_ta_mode] && @homework_detail_manual.ta_mode.to_i != params[:homework_ta_mode].to_i
@homework_detail_manual.final_mode = params[:homework_final_mode].to_i @homework_detail_manual.ta_mode = params[:ta_mode].to_i
if params[:homework_final_mode].to_i == 0 @homework_detail_manual.save
@homework_detail_manual.te_proportion = params[:te_proportion] if @homework_detail_manual.ta_mode == 1
@homework_detail_manual.ta_proportion = params[:ta_proportion] @homework.student_works.where("work_status != 0").each do |student_work|
@homework_detail_programing.ta_proportion = params[:sy_proportion] if @homework_detail_programing ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{student_work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@homework_detail_programing.save if @homework_detail_programing student_work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
end student_work.save
@homework_detail_manual.save if @homework_detail_manual end
@homework.save else
@homework = HomeworkCommon.find @homework.id @homework.student_works.where("work_status != 0").each do |student_work|
@homework.student_works.where("work_status != 0").each do |student_work| ts_score = StudentWorksScore.where("student_work_id = #{student_work.id} AND reviewer_role = 2 AND score IS NOT NULL").order("created_at DESC")
# set_final_score @homework,student_work student_work.teaching_asistant_score = ts_score.first.nil? ? nil : ts_score.first.score
student_work.save student_work.save
end
end
end end
elsif params[:homework_final_mode] && @homework_detail_manual.final_mode == 0
if (params[:te_proportion] && params[:te_proportion].to_s != @homework_detail_manual.te_proportion.to_s) || (params[:ta_proportion] && params[:ta_proportion].to_s != @homework_detail_manual.ta_proportion.to_s) || (@homework_detail_programing && @homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s)
@homework_detail_manual.te_proportion = params[:te_proportion]
@homework_detail_manual.ta_proportion = params[:ta_proportion]
@homework_detail_programing.ta_proportion = params[:sy_proportion] if @homework_detail_programing
# 最终成绩组成
if params[:homework_final_mode] && params[:homework_final_mode].to_i != @homework_detail_manual.final_mode
@homework_detail_manual.final_mode = params[:homework_final_mode].to_i
if params[:homework_final_mode].to_i == 0
@homework_detail_manual.te_proportion = params[:te_proportion]
@homework_detail_manual.ta_proportion = params[:ta_proportion]
@homework_detail_programing.ta_proportion = params[:sy_proportion] if @homework_detail_programing
@homework_detail_programing.save if @homework_detail_programing
end
@homework_detail_manual.save if @homework_detail_manual @homework_detail_manual.save if @homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing
@homework.save @homework.save
@homework = HomeworkCommon.find @homework.id @homework = HomeworkCommon.find @homework.id
@homework.student_works.where("work_status != 0").each do |student_work| @homework.student_works.where("work_status != 0").each do |student_work|
# set_final_score @homework,student_work # set_final_score @homework,student_work
student_work.save student_work.save
end end
elsif params[:homework_final_mode] && @homework_detail_manual.final_mode == 0
if (params[:te_proportion] && params[:te_proportion].to_s != @homework_detail_manual.te_proportion.to_s) || (params[:ta_proportion] && params[:ta_proportion].to_s != @homework_detail_manual.ta_proportion.to_s) || (@homework_detail_programing && @homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s)
@homework_detail_manual.te_proportion = params[:te_proportion]
@homework_detail_manual.ta_proportion = params[:ta_proportion]
@homework_detail_programing.ta_proportion = params[:sy_proportion] if @homework_detail_programing
@homework_detail_manual.save if @homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing
@homework.save
@homework = HomeworkCommon.find @homework.id
@homework.student_works.where("work_status != 0").each do |student_work|
# set_final_score @homework,student_work
student_work.save
end
end
end end
end
if @homework.homework_type == 4 if @homework.homework_type == 4
@homework.work_efficiency = params[:work_efficiency] ? 1 : 0 @homework.work_efficiency = params[:work_efficiency] ? 1 : 0
if params[:eff_score] != @homework.eff_score if params[:eff_score] != @homework.eff_score
@homework.eff_score = params[:eff_score] @homework.eff_score = params[:eff_score]
score_change = true score_change = true
end end
if @homework_detail_manual.answer_open_evaluation != params[:answer_open_evaluation].to_i if @homework_detail_manual.answer_open_evaluation != params[:answer_open_evaluation].to_i
@homework_detail_manual.answer_open_evaluation = params[:answer_open_evaluation].to_i @homework_detail_manual.answer_open_evaluation = params[:answer_open_evaluation].to_i
score_change = true score_change = true
end end
if @homework_detail_manual.shixun_evaluation != params[:shixun_evaluation].to_i if @homework_detail_manual.shixun_evaluation != params[:shixun_evaluation].to_i
@homework_detail_manual.shixun_evaluation = params[:shixun_evaluation].to_i @homework_detail_manual.shixun_evaluation = params[:shixun_evaluation].to_i
score_change = true score_change = true
end end
if params[:challenge] if params[:challenge]
score_change = true score_change = true
params[:challenge].each_with_index do |challenge_id, index| params[:challenge].each_with_index do |challenge_id, index|
setting = @homework.homework_challenge_settings.where(:challenge_id => challenge_id).first setting = @homework.homework_challenge_settings.where(:challenge_id => challenge_id).first
if setting if setting
setting.update_attributes(:score => params[:score][index]) setting.update_attributes(:score => params[:score][index])
else else
HomeworkChallengeSetting.create(:homework_common_id => @homework.id, :challenge_id => challenge_id, :shixun_id => @homework.homework_commons_shixuns.shixun_id, :score => params[:score][index]) HomeworkChallengeSetting.create(:homework_common_id => @homework.id, :challenge_id => challenge_id, :shixun_id => @homework.homework_commons_shixuns.shixun_id, :score => params[:score][index])
end
end end
@homework.homework_challenge_settings.where("challenge_id not in (#{params[:challenge].join(',')})").destroy_all
end end
@homework.homework_challenge_settings.where("challenge_id not in (#{params[:challenge].join(',')})").destroy_all @homework.score_open = params[:homework_score_open] ? 1 : 0
end @homework.save!
@homework.score_open = params[:homework_score_open] ? 1 : 0 if score_change
@homework.save! homework_challenge_settings = HomeworkChallengeSetting.where(:homework_common_id => @homework.id)
if score_change @homework.student_works.where("work_status != 0").each do |student_work|
homework_challenge_settings = HomeworkChallengeSetting.where(:homework_common_id => @homework.id) set_shixun_final_score student_work, @homework_detail_manual.answer_open_evaluation, homework_challenge_settings
@homework.student_works.where("work_status != 0").each do |student_work| end
set_shixun_final_score student_work, @homework_detail_manual.answer_open_evaluation, homework_challenge_settings # 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => @homework.id).first
end end
# 更新所有学生的效率分 else
update_student_eff_score HomeworkCommon.where(:id => @homework.id).first @homework.work_public = params[:homework_work_public] ? 1 : 0
@homework.score_open = params[:homework_score_open] ? 1 : 0
@homework.answer_public = params[:homework_answer_public] ? 1 : 0
@homework.comment_public = params[:homework_comment_public] ? 1 : 0
@homework.save!
end end
else @homework_detail_manual.save
@homework.work_public = params[:homework_work_public] ? 1 : 0 if create_homework_user.present?
@homework.score_open = params[:homework_score_open] ? 1 : 0 if group_id.present? && group_id.size != 0
@homework.answer_public = params[:homework_answer_public] ? 1 : 0 if group_id.size == @course.course_groups.count
@homework.comment_public = params[:homework_comment_public] ? 1 : 0 create_works_tiding @homework, @course.student
@homework.save! else
end members = @course.members.where(:course_group_id => group_id)
@homework_detail_manual.save create_works_tiding @homework, members
if create_homework_user.present? end
if group_id.present? && group_id.size != 0
if group_id.size == @course.course_groups.count
create_works_tiding @homework, @course.student
else else
members = @course.members.where(:course_group_id => group_id) create_works_tiding @homework, @course.student
create_works_tiding @homework, members
end end
else
create_works_tiding @homework, @course.student
end end
end end
redirect_to student_work_index_path(:homework => @homework.id) redirect_to student_work_index_path(:homework => @homework.id)
@ -929,60 +931,62 @@ class HomeworkCommonController < ApplicationController
end end
def publish_homework def publish_homework
if @homework.homework_detail_manual.try(:comment_status) == 0 ActiveRecord::Base.transaction do
if params[:group_ids] if @homework.homework_detail_manual.try(:comment_status) == 0
if @course.course_groups.where(:id => params[:group_ids].split(",")).count == @course.course_groups.count if params[:group_ids]
@homework.homework_group_settings.destroy_all if @course.course_groups.where(:id => params[:group_ids].split(",")).count == @course.course_groups.count
@homework.update_attribute("unified_setting", true) @homework.homework_group_settings.destroy_all
# 发消息 @homework.update_attribute("unified_setting", true)
create_works_tiding @homework, @course.student # 发消息
else create_works_tiding @homework, @course.student
@homework.update_attribute("unified_setting", false) else
@course.course_groups.each do |group| @homework.update_attribute("unified_setting", false)
homework_group_setting = @homework.homework_group_settings.where(:course_group_id => group.id).first @course.course_groups.each do |group|
unless homework_group_setting homework_group_setting = @homework.homework_group_settings.where(:course_group_id => group.id).first
HomeworkGroupSetting.create(:homework_common_id => @homework.id, :course_group_id => group.id, :course_id => @course.id, :publish_time => @homework.publish_time, :end_time => @homework.end_time) unless homework_group_setting
HomeworkGroupSetting.create(:homework_common_id => @homework.id, :course_group_id => group.id, :course_id => @course.id, :publish_time => @homework.publish_time, :end_time => @homework.end_time)
end
end end
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(",")).update_all(:publish_time => Time.now)
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(","), :end_time => nil).update_all(:end_time => Time.at(((1.month.since.to_i)/3600.0).ceil * 3600))
# 发消息
members = @course.members.where(:course_group_id => params[:group_ids].split(","))
create_works_tiding @homework, members
end end
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(",")).update_all(:publish_time => Time.now) else
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(","), :end_time => nil).update_all(:end_time => Time.at(((1.month.since.to_i)/3600.0).ceil * 3600)) @homework.homework_group_settings.destroy_all
# 发消息 create_works_tiding @homework, @course.student
members = @course.members.where(:course_group_id => params[:group_ids].split(","))
create_works_tiding @homework, members
end end
else @homework.update_attribute("publish_time", Time.now)
@homework.homework_group_settings.destroy_all
create_works_tiding @homework, @course.student
end
@homework.update_attribute("publish_time", Time.now)
if @homework.end_time.nil? if @homework.end_time.nil?
@homework.update_attribute("end_time", Time.at(((1.month.since.to_i)/3600.0).ceil * 3600)) @homework.update_attribute("end_time", Time.at(((1.month.since.to_i)/3600.0).ceil * 3600))
elsif HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").count > 0 elsif HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").count > 0
@homework.update_attribute("end_time", HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").map(&:end_time).max) @homework.update_attribute("end_time", HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").map(&:end_time).max)
end end
=begin =begin
if @homework.archive_time.nil? if @homework.archive_time.nil?
@homework.update_attribute("archive_time", Time.at(((2.months.since.to_i)/3600.0).ceil * 3600)) @homework.update_attribute("archive_time", Time.at(((2.months.since.to_i)/3600.0).ceil * 3600))
end end
=end =end
@homework.homework_detail_manual.update_attribute('comment_status', 1) @homework.homework_detail_manual.update_attribute('comment_status', 1)
if @homework.course_acts.size == 0 if @homework.course_acts.size == 0
@homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id) @homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id)
end
else
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(",")).update_all(:publish_time => Time.now)
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(","), :end_time => nil).update_all(:end_time => Time.at(((1.month.since.to_i)/3600.0).ceil * 3600))
if HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").count > 0
@homework.update_attribute("end_time", HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").map(&:end_time).max)
end
# 发消息
members = @course.members.where(:course_group_id => params[:group_ids].split(","))
create_works_tiding @homework, members
end end
else if @homework.end_time > Time.now && @homework.homework_detail_manual.try(:comment_status) > 1
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(",")).update_all(:publish_time => Time.now) @homework.homework_detail_manual.update_attribute("comment_status", 1)
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(","), :end_time => nil).update_all(:end_time => Time.at(((1.month.since.to_i)/3600.0).ceil * 3600))
if HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").count > 0
@homework.update_attribute("end_time", HomeworkGroupSetting.where("homework_common_id = #{@homework.id} and end_time is not null").map(&:end_time).max)
end end
# 发消息
members = @course.members.where(:course_group_id => params[:group_ids].split(","))
create_works_tiding @homework, members
end
if @homework.end_time > Time.now && @homework.homework_detail_manual.try(:comment_status) > 1
@homework.homework_detail_manual.update_attribute("comment_status", 1)
end end
redirect_to student_work_index_path(:homework => @homework.id) redirect_to student_work_index_path(:homework => @homework.id)
end end
@ -1032,7 +1036,8 @@ class HomeworkCommonController < ApplicationController
def end_homework def end_homework
time = Time.now time = Time.now
student_works = @homework.student_works.where("0=1") student_works = @homework.student_works.where("0=1")
# if @homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > time ActiveRecord::Base.transaction do
# if @homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > time
if params[:group_ids] if params[:group_ids]
# @homework.homework_group_settings.where(:course_group_id => params[:group_id]).where("publish_time > '#{Time.now}' or publish_time is null").update_all(:publish_time => time) # @homework.homework_group_settings.where(:course_group_id => params[:group_id]).where("publish_time > '#{Time.now}' or publish_time is null").update_all(:publish_time => time)
@homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(",")).update_all(:end_time => time) @homework.homework_group_settings.where(:course_group_id => params[:group_ids].split(",")).update_all(:end_time => time)
@ -1069,7 +1074,9 @@ class HomeworkCommonController < ApplicationController
# 更新所有学生的效率分 # 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => @homework.id).first update_student_eff_score HomeworkCommon.where(:id => @homework.id).first
end end
# end # end
end
redirect_to student_work_index_path(:homework => @homework.id) redirect_to student_work_index_path(:homework => @homework.id)
end end

@ -451,15 +451,12 @@ class MyshixunsController < ApplicationController
# 只有评测中的game才会创建和更新代码评测中的信息 # 只有评测中的game才会创建和更新代码评测中的信息
logger.info("##################game: #{game.status}") logger.info("##################game: #{game.status}")
logger.info("##################retry_status: #{game.retry_status}") logger.info("##################retry_status: #{game.retry_status}")
if game.status == 1 || game.status == 2 && game.retry_status == 1 if game.status == 1 || game.status == 2
if msg.blank? if msg.blank?
RunCodeMessage.create!(:game_id => game_id, :status => 1, :message => message) RunCodeMessage.create!(:game_id => game_id, :status => 1, :message => message)
else else
msg.update_attributes(:status => (msg.status + 1), :message => message) msg.update_attributes(:status => (msg.status + 1), :message => message)
end end
else
# 评测完成,初始化评测信息的状态
msg.update_attributes(:status => 0, :message => nil) if msg.present?
end end
render :json => {:data => "success"} render :json => {:data => "success"}
end end

@ -242,14 +242,56 @@ class SubjectsController < ApplicationController
memberships = params[:membership][:user_ids] memberships = params[:membership][:user_ids]
memberships.each do |member| memberships.each do |member|
user = User.find(member) user = User.find(member)
SubjectMember.create!(:user_id => member, :subject_id => @subject.id, :role => 2) SubjectMember.create!(:user_id => member, :subject_id => @subject.id, :role => 2,
:position => @subject.subject_members.size + 1)
end end
end end
end end
def delete_member def delete_member
member = @subject.subject_members.where(:user_id => params[:mem_id]).first if User.current.admin?
member.destroy if member ActiveRecord::Base.transaction do
member = @subject.subject_members.where(:id => params[:mem_id]).first
if member.present? && member.role != 1
@subject.subject_members.where("position > #{member.position}").update_all("position = position - 1")
member.destroy
end
end
else
render_403
end
end
def up_member_position
if User.current.member_of_subject?(@subject)
ActiveRecord::Base.transaction do
member = @subject.subject_members.where(:id => params[:mem_id]).first
raise "不能再上移了" if member.position == 1
up_member = @subject.subject_members.where(:position => member.position - 1).first
up_member.update_attribute(:position, member.position)
member.update_attribute(:position, member.position - 1)
end
else
render_403
end
end
def down_member_position
if User.current.member_of_subject?(@subject)
ActiveRecord::Base.transaction do
begin
member = @subject.subject_members.where(:id => params[:mem_id]).first
raise "不能再下移了" if member.position == @subject.subject_members.count
down_member = @subject.subject_members.where(:position => member.position + 1).first
down_member.update_attribute(:position, member.position)
member.update_attribute(:position, member.position + 1)
rescue Exception => e
raise ActiveRecord::Rollback
end
end
else
render_403
end
end end
def statistics def statistics

@ -2559,6 +2559,15 @@ class UsersController < ApplicationController
end end
end end
@objects_count = @objects.size @objects_count = @objects.size
# 用户访问自己主页的"我管理的"列表,且是第一页才显示新建入口
page = params[:page] ? params[:page].to_i : 1
@new_icon = @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) && page == 1
# 用户进自己主页的全部列表时有个新建入口,加一个"new"view层的第一页需要shift这样翻页就没问题啦
@objects = @objects.to_a
@objects.unshift("new") if @new_icon
@objects = paginateHelper @objects, 16 @objects = paginateHelper @objects, 16
respond_to do |format| respond_to do |format|

@ -28,6 +28,169 @@ class WelcomeController < ApplicationController
skip_before_filter :check_authentication, :only => [:index] skip_before_filter :check_authentication, :only => [:index]
require 'simple_xlsx_reader' require 'simple_xlsx_reader'
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
def local_init
LocalShixun.delete_all
LocalMirrorRepository.delete_all
LocalShixunTagRepertoire.delete_all
LocalChallenge.delete_all
LocalTestSet.delete_all
LocalChallengeTag.delete_all
render :json => {status: 0, message: "success"}
end
def shixun_to_local
identifiers = params[:identifiers].split(",")
shixuns = Shixun.where(identifier: identifiers)
# 不重复导入
ActiveRecord::Base.transaction do
begin
shixuns.each do |shixun|
if LocalShixun.where(shixun_id: shixun.id).blank?
local_shixun = LocalShixun.create!(name: shixun.name, description: shixun.description, user_id: User.current.id, status: 0,
trainee: shixun.trainee, webssh: shixun.webssh, multi_webssh: shixun.multi_webssh,
can_copy: shixun.can_copy, identifier: generate_identifier, shixun_id: shixun.id,
use_scope: shixun.use_scope, visits: 1, evaluate_script: shixun.evaluate_script)
# 同步镜像
if shixun.mirror_repositories.present?
shixun.mirror_repositories.each do |mirror|
LocalMirrorRepository.create!(:local_shixun_id => local_shixun.id, :mirror_repository_id => mirror.id)
end
end
# 同步技术标签
shixun.shixun_tag_repertoires.each do |str|
LocalShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :local_shixun_id => local_shixun.id)
end
# 不需要同步版本库,版本库应该是从本地导入到线上的时候由线上版本创建的
# 同步复制关卡
if shixun.challenges.present?
shixun.challenges.each do |challenge|
new_challenge = LocalChallenge.new
new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id", "test_set_score")
new_challenge.local_shixun_id = local_shixun.id
new_challenge.save!
# 评测题,选择题暂时不考虑
# 同步测试集
if challenge.test_sets.present?
challenge.test_sets.each do |test_set|
new_test_set = LocalTestSet.new
new_test_set.attributes = test_set.attributes.dup.except("id","challenge_id")
new_test_set.local_challenge_id = new_challenge.id
new_test_set.save!
end
end
# 同步关卡标签
challenge_tags = ChallengeTag.where("challenge_id =? and challenge_choose_id is null", challenge.id)
if challenge_tags.present?
challenge_tags.each do |challenge_tag|
LocalChallengeTag.create!(:local_challenge_id => new_challenge.id, :name => challenge_tag.try(:name))
end
end
end
end
end
end
render :json => {status: 0, message: "同步成功"}
rescue Exception => e
logger.error("shixun_local_in ##{e.message}")
render :json => {status: -1, message: "同步失败,#{e.message}"}
raise ActiveRecord::Rollback
end
end
end
def local_to_shixun
ActiveRecord::Base.transaction do
shixun_list = []
LocalShixun.find_each do |local_shixun|
identifier = generate_identifier
shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id,
trainee: local_shixun.trainee, webssh: local_shixun.webssh, multi_webssh: local_shixun.multi_webssh,
can_copy: local_shixun.can_copy, identifier: identifier, reset_time: Time.now,
modify_time: Time.now, use_scope: local_shixun.use_scope, visits: 1, evaluate_script: local_shixun.evaluate_script)
m = ShixunMember.new(:user_id => User.current.id, :role => 1)
shixun.shixun_members << m
# 同步镜像
local_mirrors = LocalMirrorRepository.where(local_shixun_id: local_shixun.id)
if local_mirrors.present?
local_mirrors.each do |local_mirror|
ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => local_mirror.mirror_repository_id)
end
end
# 同步技术标签
local_shixun_tags = LocalShixunTagRepertoire.where(local_shixun_id: local_shixun.id)
if local_shixun_tags.present?
local_shixun_tags.each do |str|
ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => shixun.id)
end
end
# 创建版本库
repository = Repository.new
repository.shixun = shixun
repository.type = 'Repository::Gitlab'
repository.identifier = shixun.identifier.downcase
repository.project_id = -1
repository.save!
s = Trustie::Gitlab::Sync.new
s.create_shixun(shixun, repository)
raise "版本库创建失败" if shixun.gpid.blank? # 若和gitlab没同步成功则抛出异常
g = Gitlab.client
shixun.update_column(:git_url, g.project(shixun.gpid).path_with_namespace)
# 同步关卡信息
local_challenges = LocalChallenge.where(local_shixun_id: local_shixun.id)
if local_challenges.present?
local_challenges.each do |local_challenge|
new_challenge = Challenge.new
new_challenge.attributes = local_challenge.attributes.dup.except("id","local_shixun_id","user_id", "test_set_score")
new_challenge.user_id = User.current.id
new_challenge.shixun_id = shixun.id
new_challenge.save!
# 同步测试集
local_test_sets = LocalTestSet.where(local_challenge_id: local_challenge.id)
if local_test_sets.present?
local_test_sets.each do |local_test_set|
new_test_set = TestSet.new
new_test_set.attributes = local_test_set.attributes.dup.except("id","challenge_id")
new_test_set.challenge_id = new_challenge.id
new_test_set.save!
end
end
# 同步关卡标签
local_challenge_tags = LocalChallengeTag.where(local_challenge_id: local_challenge.id)
if local_challenge_tags.present?
local_challenge_tags.each do |local_challenge_tag|
ChallengeTag.create!(:challenge_id => new_challenge.id, :name => local_challenge_tag.try(:name))
end
end
end
end
shixun_list << shixun.identifier
end
render :json => {status: 0, message: "success", identifier: shixun_list}
end
end
# 生成表示码
def generate_identifier
code = DCODES.sample(8).join
return generate_identifier if Shixun.where(identifier: code).present?
code
end
def index def index
images = PortalImage.where(status: true).order("position asc") images = PortalImage.where(status: true).order("position asc")

@ -0,0 +1,3 @@
class LocalChallenge < ActiveRecord::Base
end

@ -0,0 +1,3 @@
class LocalChallengeTag < ActiveRecord::Base
end

@ -0,0 +1,3 @@
class LocalMirrorRepository < ActiveRecord::Base
end

@ -0,0 +1,3 @@
class LocalShixun < ActiveRecord::Base
end

@ -0,0 +1,2 @@
class LocalShixunTagRepertoire < ActiveRecord::Base
end

@ -0,0 +1,3 @@
class LocalTestSet < ActiveRecord::Base
end

@ -66,4 +66,10 @@ class School < ActiveRecord::Base
dep = departments.where("identifier is not null").first dep = departments.where("identifier is not null").first
url = dep.present? ? "/colleges/#{dep.identifier}/statistics" : "" url = dep.present? ? "/colleges/#{dep.identifier}/statistics" : ""
end end
def course_act_time
CourseActivity.find_by_sql("SELECT max(ca.updated_at) as max_update FROM course_activities ca left join courses on ca.course_id =
courses.id LEFT JOIN user_extensions ON courses.tea_id=user_extensions.user_id WHERE
user_extensions.`school_id` = #{self.id}").first.try(:max_update)
end
end end

@ -1,4 +1,4 @@
class ShixunTagRepertoire < ActiveRecord::Base class ShixunTagRepertoire < ActiveRecord::Base
# attr_accessible :title, :body # attr_accessible :title, :body
belongs_to :shixun belongs_to :shixun
belongs_to :tag_repertoire belongs_to :tag_repertoire

@ -2,7 +2,7 @@ class Subject < ActiveRecord::Base
#status :0 编辑中 1 审核中 2 发布 #status :0 编辑中 1 审核中 2 发布
# belongs_to :user # belongs_to :user
has_many :users, :through => :subject_members has_many :users, :through => :subject_members
has_many :subject_members, :dependent => :destroy, :order => "subject_members.id ASC" has_many :subject_members, :dependent => :destroy, :order => "subject_members.position asc"
has_many :career_stages, :through => :career_stage_subjects has_many :career_stages, :through => :career_stage_subjects
has_many :career_stage_subjects, :dependent => :destroy has_many :career_stage_subjects, :dependent => :destroy

@ -65,7 +65,7 @@ class GamesService
# power判断用户是否有权限查看隐藏测试集(TPM管理员平台认证的老师花费金币查看者) -1 表示不能解锁 0 表示需要付费解锁 1表示可以看 # power判断用户是否有权限查看隐藏测试集(TPM管理员平台认证的老师花费金币查看者) -1 表示不能解锁 0 表示需要付费解锁 1表示可以看
# myshixun_manager # myshixun_manager
myshixun_manager = shixun_manager(shixun, current_user) || (current_user.is_certification_teacher && shixun.test_set_permission) myshixun_manager = shixun_manager(shixun, current_user) || (current_user.is_certification_teacher)
power = (myshixun_manager || game.test_sets_view ) ? 1 : (shixun.test_set_permission ? 0 : -1) power = (myshixun_manager || game.test_sets_view ) ? 1 : (shixun.test_set_permission ? 0 : -1)
# 选择题和编程题公共部分 # 选择题和编程题公共部分
@ -862,7 +862,7 @@ class GamesService
Rails.logger.warn("last_output is #{latest_output}") Rails.logger.warn("last_output is #{latest_output}")
# power判断用户是否有权限查看隐藏测试集(TPM管理员平台认证的老师花费金币查看者) # power判断用户是否有权限查看隐藏测试集(TPM管理员平台认证的老师花费金币查看者)
power = (shixun_manager(shixun, current_user) || (current_user.is_certification_teacher && shixun.test_set_permission)) ? 1 : (shixun.test_set_permission ? 0 : -1) power = (shixun_manager(shixun, current_user) || (current_user.is_certification_teacher)) ? 1 : (shixun.test_set_permission ? 0 : -1)
# 测试集统计及处理 # 测试集统计及处理
unless qurey_test_sets.blank? unless qurey_test_sets.blank?
check_power = (power == 1 || game.test_sets_view) check_power = (power == 1 || game.test_sets_view)

@ -1,6 +1,6 @@
<%= stylesheet_link_tag 'css/public','css/common'%> <%= stylesheet_link_tag 'css/public','css/common'%>
<%= content_for(:header_tags) do %> <%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<% end %> <% end %>
<div xmlns="http://www.w3.org/1999/html"> <div xmlns="http://www.w3.org/1999/html">
<div class="edu-back-white ml15 pt20 pb20 clearfix pl30 pr30 mb30"> <div class="edu-back-white ml15 pt20 pb20 clearfix pl30 pr30 mb30">
@ -15,79 +15,94 @@
<div class="color-orange mt15 mb15"> <div class="color-orange mt15 mb15">
<span class="mr5">*</span> <span class="mr5">*</span>
<a href="https://trustie.educoder.net/help?index=5" class="color-orange">看看帮助中心是否有你想要的答案</a></div> <a href="https://trustie.educoder.net/help?index=5" class="color-orange">看看帮助中心是否有你想要的答案</a></div>
<%= form_for('new_form',:url => insert_suggest_path(), :html =>{:id => "insert_suggest"}, :method => :post) do |f| %> <%= form_for('new_form',:url => insert_suggest_path(), :html =>{:id => "insert_suggest"}, :method => :post) do |f| %>
<div class="mt10"> <div class="mt10">
<span class="mr5 color-orange font-16">*</span><span class="font-16">问题分类</span> <span class="mr5 color-orange font-16">*</span><span class="font-16">问题分类</span>
<div class="font-14 mt10 mb10 ml20 color-dark-grey"> <div class="font-14 mt10 mb10 ml20 color-dark-grey">
<label class="mr40"> <label class="mr40">
<input type="radio" value="登录注册" class="mr5 magic-radio" name="question_kind" id ="type_1" checked> <input type="radio" value="登录注册" class="mr5 magic-radio" name="question_kind" id ="type_1" checked>
<label for="type_1" style="display: inline-block">登录注册</label> <label for="type_1" style="display: inline-block">登录注册</label>
</label> </label>
<label class="mr40"> <label class="mr40">
<input type="radio" value="信息认证" class="mr5 magic-radio" name="question_kind" id ="type_2"> <input type="radio" value="信息认证" class="mr5 magic-radio" name="question_kind" id ="type_2">
<label for="type_2" style="display: inline-block">信息认证</label> <label for="type_2" style="display: inline-block">信息认证</label>
</label> </label>
<label class="mr40"> <label class="mr40">
<input type="radio" value="实训编程" class="mr5 magic-radio" name="question_kind" id ="type_3"> <input type="radio" value="实训编程" class="mr5 magic-radio" name="question_kind" id ="type_3">
<label for="type_3" style="display: inline-block">实训编程</label> <label for="type_3" style="display: inline-block">实训编程</label>
</label> </label>
<label class="mr40"> <label class="mr40">
<input type="radio" value="实训课程" class="mr5 magic-radio" name="question_kind" id ="type_4"> <input type="radio" value="实训课程" class="mr5 magic-radio" name="question_kind" id ="type_4">
<label for="type_4" style="display: inline-block">实训课程</label> <label for="type_4" style="display: inline-block">实训课程</label>
</label> </label>
<label class="mr40"> <label class="mr40">
<input type="radio" value="课堂" class="mr5 magic-radio" name="question_kind" id ="type_5"> <input type="radio" value="课堂" class="mr5 magic-radio" name="question_kind" id ="type_5">
<label for="type_5" style="display: inline-block">课堂</label> <label for="type_5" style="display: inline-block">课堂</label>
</label> </label>
<label class="mr40"> <label class="mr40">
<input type="radio" value="其他" class="mr5 magic-radio" name="question_kind" id ="type_6"> <input type="radio" value="其他" class="mr5 magic-radio" name="question_kind" id ="type_6">
<label for="type_6" style="display: inline-block">其他</label> <label for="type_6" style="display: inline-block">其他</label>
</label> </label>
</div> </div>
</div> </div>
<div class="clearfix mt10"> <div class="clearfix mt10">
<span class="mr5 color-orange font-16">*</span><span class="font-16">问题描述</span> <span class="mr5 color-orange font-16">*</span><span class="font-16">问题页面网址</span>
<div class="font-14 mt10 ml20 clearfix"> <div class="font-14 mt10 ml20 clearfix">
<!--<div id="hidden_div_block_1"> <input type="text" class="width100 radius4" id="url_content" name ="url" value="<%= @url %>" style="height: 40px;" placeholder="反馈平台问题,请同时填写对应的问题页面链接,以便平台能够及时跟踪解决,谢谢">
</div>
<p class="color-orange ml20 mt5 undis" id="new_memo_url_notice"><i class="fa fa-exclamation-circle mr5"></i>网址不能为空</p>
</div>
<div class="clearfix mt10">
<span class="mr5 color-orange font-16">*</span><span class="font-16">问题描述</span>
<div class="font-14 mt10 ml20 clearfix">
<!--<div id="hidden_div_block_1">
<textarea style="display: none" id="hidden_textarea_1" name ="description"></textarea> <textarea style="display: none" id="hidden_textarea_1" name ="description"></textarea>
</div> </div>
<%#= hidden_field_tag :asset_id, params[:asset_id],:required => false,:style => 'display:none' %>--> <%#= hidden_field_tag :asset_id, params[:asset_id],:required => false,:style => 'display:none' %>-->
<textarea class="width100 radius4" id="description" name ="description" style="height: 150px;" placeholder="反馈平台问题,请同时填写对应的问题页面链接,以便平台能够及时跟踪解决,谢谢"></textarea> <textarea class="width100 radius4" id="description" name ="description" style="height: 150px;" placeholder="反馈平台问题,请同时填写对应的问题页面链接,以便平台能够及时跟踪解决,谢谢"></textarea>
</div> </div>
<p class="color-orange ml20 mt5 undis" id="new_memo_content_notice"><i class="fa fa-exclamation-circle mr5"></i>内容不能为空</p> <p class="color-orange ml20 mt5 undis" id="new_memo_content_notice"><i class="fa fa-exclamation-circle mr5"></i>内容不能为空</p>
<!--<div class="mt10">--> <!--<div class="mt10">-->
<!--<span class="font-16 ml20">联系方式</span>--> <!--<span class="font-16 ml20">联系方式</span>-->
<!--<div class="font-14 mt10 mb10 ml20 color-dark-grey">--> <!--<div class="font-14 mt10 mb10 ml20 color-dark-grey">-->
<!--<input type="phone" class="font-14 pl10" style="width:89%;height: 40px" placeholder="请留下您的联系方式" name = 'phone'/>--> <!--<input type="phone" class="font-14 pl10" style="width:89%;height: 40px" placeholder="请留下您的联系方式" name = 'phone'/>-->
<!--</div>--> <!--</div>-->
<!--</div>--> <!--</div>-->
<a href="javascript:void(0);" class="defalutSubmitbtn fl ml20 mt10" onclick="insert_suggest()">提交</a> <a href="javascript:void(0);" class="defalutSubmitbtn fl ml20 mt10" onclick="insert_suggest()">提交</a>
<% end %>
</div> </div>
<% end %>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
/*sd_create_editor_from_data(1,null,"100%", "Issue");*/ /*sd_create_editor_from_data(1,null,"100%", "Issue");*/
//var suggest_ke; //var suggest_ke;
/*KindEditor.ready(function(K){ /*KindEditor.ready(function(K){
$("#hidden_div_block_1").each(function(){ $("#hidden_div_block_1").each(function(){
var params = {}; var params = {};
params.kindutil = K; params.kindutil = K;
params.div_form = $(this); params.div_form = $(this);
params.placeholder = "请填写具体内容,帮助我们了解您的建议与意见"; params.placeholder = "请填写具体内容,帮助我们了解您的建议与意见";
params.textarea = $("textarea[name='description']",params.div_form); params.textarea = $("textarea[name='description']",params.div_form);
params.height = 300; params.height = 300;
if(params.textarea.data('init') == undefined) { if(params.textarea.data('init') == undefined) {
memo_content_editor = init_exercise_quetison_editor(params); memo_content_editor = init_exercise_quetison_editor(params);
//suggest_ke = memo_content_editor; //suggest_ke = memo_content_editor;
//new_quetion_editor = params.editor; //new_quetion_editor = params.editor;
params.textarea.data('init', 1); params.textarea.data('init', 1);
//params.editor. //params.editor.
} }
}); });
});*/ });*/
function regexContent() { function regexContent() {
if($("#url_content").val()==""){
$("#new_memo_url_notice").show();
return false;
}
else {
$("#new_memo_url_notice").hide();
}
// KE输入框类被添加了元素导致isEmpty方法失效 // KE输入框类被添加了元素导致isEmpty方法失效
if($("#description").val()==""){ if($("#description").val()==""){
$("#new_memo_content_notice").show(); $("#new_memo_content_notice").show();

@ -27,7 +27,7 @@
<script> <script>
$.ajax({ $.ajax({
url:'<%= help_path() %>', url:'<%= help_path() %>',
data: {index: '<%= @index %>'}, data: {index: '<%= @index %>', url: '<%= @url %>'},
type: 'post', type: 'post',
dataType: 'script' dataType: 'script'
}) })

@ -297,6 +297,7 @@
$("#test_file_name").show(); $("#test_file_name").show();
}else{ }else{
$("#challenge_shixun_update").submit(); $("#challenge_shixun_update").submit();
// location.reload();
} }
} }
</script> </script>

@ -1,7 +1,8 @@
$("#task_pass_page").html("<%= j( render :partial => "single_or_multiple_question_show") %>"); $("#task_pass_page").html("<%= j( render :partial => "single_or_multiple_question_show") %>");
var html = '<a href="<%= show_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.id) %>" data-remote="true"><%= @challenge_choose.position %>.<%= @challenge_choose.category == 1 ? "单选题" : "多选题" %></a>' var html = '<a href="<%= show_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.id) %>" data-remote="true"><%= @challenge_choose.position %>.<%= @challenge_choose.category == 1 ? "单选题" : "多选题" %></a>'
$(".active").html(html); $(".click_active.active").html(html);
if($(".add_choose_type").length == 0 && $(".click_active").length < 11){ if($(".add_choose_type").length == 0 && $(".click_active").length < 11){
var html_1 ='<a href="<%= new_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" data-remote="true" data-tip-down="新增选择题" class="add_choose_type" onclick="addChooseType(this);">+</a>'; var html_1 ='<a href="<%= new_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" data-remote="true" data-tip-down="新增选择题" class="add_choose_type" onclick="addChooseType(this);">+</a>';
$(".active").after(html_1); $(".click_active.active").after(html_1);
} }
$(window).scrollTop(0);

@ -1,23 +1,25 @@
<p class="clearfix edu-back-white"> <p class="clearfix edu-back-white">
<span class="column-No">序号</span> <span class="column-No">序号</span>
<span class="column-2">单位名称</span> <span class="column-1">单位名称</span>
<span class="column-2">教师</span> <span class="column-1">教师</span>
<span class="column-2">学生</span> <span class="column-1">学生</span>
<span class="column-2">课堂</span> <span class="column-2">课堂</span>
<span class="column-2">发布实训</span> <span class="column-2">发布实训</span>
<span class="column-2">实训报告</span> <span class="column-2">实训报告</span>
<span class="column-2">最新课堂动态时间</span>
<span class="column-2 fr">使用详情</span> <span class="column-2 fr">使用详情</span>
</p> </p>
<ul class="minH-560 edu-back-white pb20 courselist"> <ul class="minH-560 edu-back-white pb20 courselist">
<% @schools.each_with_index do |school, index| %> <% @schools.each_with_index do |school, index| %>
<li class="clearfix bor-bottom-greyE" id="major_list"> <li class="clearfix bor-bottom-greyE" id="major_list">
<span class="column-No major_index"><%= index + 1 %></span> <span class="column-No major_index"><%= index + 1 %></span>
<span class="column-2"><%= school.name %></span> <span class="column-1"><%= school.name %></span>
<span class="column-2"><%= school.teacher_count %></span> <span class="column-1"><%= school.teacher_count %></span>
<span class="column-2"><%= school.student_count %></span> <span class="column-1"><%= school.student_count %></span>
<span class="column-2"><%= school.course_count %></span> <span class="column-2"><%= school.course_count %></span>
<span class="column-2"><%= school.shixun_count %></span> <span class="column-2"><%= school.shixun_count %></span>
<span class="column-2"><%= school.shixun_report_count %></span> <span class="column-2"><%= school.shixun_report_count %></span>
<span class="column-2"><%= school.course_act_time.present? ? format_time(school.course_act_time) : "--" %></span>
<span class="column-2 fr"> <span class="column-2 fr">
<% if school.statistic_url != "" %> <% if school.statistic_url != "" %>
<a href="<%= school.statistic_url %>" target="_blank" class="color-blue">查看</a> <a href="<%= school.statistic_url %>" target="_blank" class="color-blue">查看</a>

@ -1,14 +1,45 @@
<p class="font-16 clearfix">教学团队</p> <p class="font-16 clearfix">教学团队</p>
<% @subject.subject_members.each do |member| %> <% @subject.subject_members.each do |member| %>
<% if member.user %> <% if member.user %>
<div class="teacherTeamItem clearfix df"> <div class="teacherTeamItem clearfix">
<a href="<%= user_path(member.user) %>" target="_blank" class="fl">
<%= image_tag(url_to_avatar(member.user), :width =>"80", :height => "80", :class => "radius", :alt=>"头像") %>
</a> <p class="clearfix title-line">
<div class="fl ml15 flex1">
<a href="<%= user_path(member.user) %>" target="_blank" class="fl">
<%= image_tag(url_to_avatar(member.user), :width =>"80", :height => "80", :class => "radius", :alt=>"头像") %>
</a>
<span class="font-18 font-bd"></span>
<span class="fr">
<% if User.current.admin? && member.role != 1 %>
<a class="fl mr20 mt4" data-tip-down="删除" onclick="delete_confirm_box_2('<%= delete_member_subject_path(@subject, :mem_id => member.id) %>', '确定要删除该成员吗?');">
<img src="/images/educoder/icon/del.svg" class="fl mt4 ml4">
</a>
<% end %>
<% if User.current.member_of_subject?(@subject) && member.position > 1 %>
<a data-method="POST" class="fl ring-op-green mr25 mt7" data-remote="true" href="<%= up_member_position_subject_path(@subject, :mem_id => member.id) %>">
<img src="/images/educoder/icon/moveup.svg" data-tip-down="向上移动" class="fl mt2 ml4">
</a>
<% end %>
<% if User.current.member_of_subject?(@subject) && member.position < @subject.subject_members.size %>
<a data-method="POST" class="fl ring-op-green mr25 mt7" data-remote="true" href="<%= down_member_position_subject_path(@subject, :mem_id => member.id) %>">
<img src="/images/educoder/icon/movedown.svg" data-tip-down="向下移动" class="fl mt2 ml4">
</a>
<% end %>
</span>
</p>
<div class=" ml15">
<p class="mb10 mt5"><%= member.user.try(:show_name) %></p> <p class="mb10 mt5"><%= member.user.try(:show_name) %></p>
<div class="clearfix ml3"> <div class="clearfix ml3">
<p class="color-grey-9 font-12 fl"> <p class="color-grey-9 font-12">
<!-- <span class="mr10"><%#= member.user.school_name %></span>--> <!-- <span class="mr10"><%#= member.user.school_name %></span>-->
<span><%= member.user.identity == "学生" ? "" : member.user.identity %></span> <span><%= member.user.identity == "学生" ? "" : member.user.identity %></span>
</p> </p>

@ -0,0 +1 @@
$("#subject_members").html("<%= j(render :partial => 'subject_members') %>");

@ -0,0 +1 @@
$("#subject_members").html("<%= j(render :partial => 'subject_members') %>");

@ -15,6 +15,35 @@
<div class="educontent"> <div class="educontent">
<!--我的课堂--> <!--我的课堂-->
<div class="square-list clearfix"> <div class="square-list clearfix">
<% if @new_icon %>
<!--课堂新建入口-->
<div class="square-Item">
<div class="substance substancepad" >
<a href="/courses/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建课堂
</span>
</div>
</div>
</div>
<% @objects.shift %>
<% end %>
<%#= render :partial => "users/course_item", :locals => {:objects => @objects} %> <%#= render :partial => "users/course_item", :locals => {:objects => @objects} %>
<% @objects.each do |object| %> <% @objects.each do |object| %>
<% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) %> <% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) %>
@ -68,5 +97,37 @@
</div> </div>
</div> </div>
<% else %> <% else %>
<%= render :partial => "welcome/no_data" %>
<div class="pr padding20-30 clearfix secondNav educontent">
<% if @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) %>
<!--课堂新建入口-->
<div class="square-Item squarebox">
<div class="substance substancepad" >
<a href="/courses/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建课堂
</span>
</div>
</div>
</div>
<% end %>
<%= render :partial => "welcome/no_data" %>
</div>
<% end %> <% end %>

@ -15,6 +15,36 @@
<div class="educontent"> <div class="educontent">
<!--我的项目--> <!--我的项目-->
<div class="square-list clearfix"> <div class="square-list clearfix">
<% if @new_icon %>
<!--新建项目新建入口-->
<div class="square-Item">
<div class="substance substancepad" >
<a href="/projects/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建项目
</span>
</div>
</div>
</div>
<% @objects.shift %>
<% end %>
<% @objects.each do |object| %> <% @objects.each do |object| %>
<% allow_visit = object.is_public || User.current.admin? || User.current.member_of?(object) %> <% allow_visit = object.is_public || User.current.admin? || User.current.member_of?(object) %>
<div class="square-Item" onclick="open_project(<%= object.id %>, <%= allow_visit %>)" style="cursor: pointer;"> <div class="square-Item" onclick="open_project(<%= object.id %>, <%= allow_visit %>)" style="cursor: pointer;">
@ -67,5 +97,37 @@
</div> </div>
</div> </div>
<% else %> <% else %>
<%= render :partial => "welcome/no_data" %>
<div class="pr padding20-30 clearfix secondNav educontent">
<% if @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) %>
<!--实训新建入口-->
<div class="square-Item squarebox">
<div class="substance substancepad" >
<a href="/projects/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建项目
</span>
</div>
</div>
</div>
<% end %>
<%= render :partial => "welcome/no_data" %>
</div>
<% end %> <% end %>

@ -34,6 +34,36 @@
<div class="educontent"> <div class="educontent">
<!--我的实训--> <!--我的实训-->
<div class="square-list clearfix"> <div class="square-list clearfix">
<% if @new_icon %>
<!--实训新建入口-->
<div class="square-Item">
<div class="substance substancepad" >
<a href="/shixuns/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建实训
</span>
</div>
</div>
</div>
<% @objects.shift %>
<% end %>
<% @objects.each do |object| %> <% @objects.each do |object| %>
<div class="square-Item"> <div class="square-Item">
<% if object.tag_repertoires.first.present? %> <% if object.tag_repertoires.first.present? %>
@ -71,5 +101,36 @@
</div> </div>
</div> </div>
<% else %> <% else %>
<div class="pr padding20-30 clearfix secondNav educontent">
<% if @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) %>
<!--实训新建入口-->
<div class="square-Item squarebox">
<div class="substance substancepad" >
<a href="/shixuns/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建实训
</span>
</div>
</div>
</div>
<% end %>
<%= render :partial => "welcome/no_data" %> <%= render :partial => "welcome/no_data" %>
</div>
<% end %> <% end %>

@ -49,6 +49,7 @@
<div class="cl"></div> <div class="cl"></div>
<div class="clearfix mt10"> <div class="clearfix mt10">
<div nhname='toolbar_container_<%= @target_user.id%>' class="mb10 clearfix fl"></div> <div nhname='toolbar_container_<%= @target_user.id%>' class="mb10 clearfix fl"></div>
<span class="fl ml5 color-orange none font-12" id="new_message_notice_<%= @target_user.id %>">在问题反馈时,请同时发送问题发生页的网址链接,以便我们高效的为您服务</span>
<a id="new_message_submit_btn_<%= @target_user.id%>" style="display: none" href="javascript:void(0)" class="fr task-btn task-btn-orange">回复</a> <a id="new_message_submit_btn_<%= @target_user.id%>" style="display: none" href="javascript:void(0)" class="fr task-btn task-btn-orange">回复</a>
</div> </div>

@ -22,6 +22,37 @@
<div class="educontent"> <div class="educontent">
<!--我的实训路径--> <!--我的实训路径-->
<div class="square-list clearfix"> <div class="square-list clearfix">
<% if @new_icon %>
<!--实训路径新建入口-->
<div class="square-Item">
<div class="substance substancepad" >
<a href="/paths/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建实训课程
</span>
</div>
</div>
</div>
<% @objects.shift %>
<% end %>
<% @objects.each_with_index do |object, index| %> <% @objects.each_with_index do |object, index| %>
<div class="square-Item"> <div class="square-Item">
<% if object.status < 2 && !User.current.member_of_subject?(object) %> <% if object.status < 2 && !User.current.member_of_subject?(object) %>
@ -56,5 +87,33 @@
</div> </div>
</div> </div>
<% else %> <% else %>
<%= render :partial => "welcome/no_data" %> <div class="pr padding20-30 clearfix secondNav educontent">
<% if @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) %>
<!--实训新建入口-->
<div class="square-Item squarebox">
<div class="substance substancepad" >
<a href="/paths/new">
<div class="substancenenew">
<div class="leftten"></div>
<div class="topten"></div>
</div>
</a>
</div>
<div class="edu-txt-center course-bottom">
<div class="inline color-grey-6">
<span class="fl ml10 mr10 squareIconSpan substancefont">
新建实训课程
</span>
</div>
</div>
</div>
<% end %>
<%= render :partial => "welcome/no_data" %>
</div>
<% end %> <% end %>

@ -6,7 +6,7 @@
</div> </div>
<div class="feedback" tooltips="意见反馈"> <div class="feedback" tooltips="意见反馈">
<a target="_blank" class="color_white inline" href="<%= help_path(:index => 6) %>"> <a target="_blank" class="color_white inline" href="<%= help_path(:index => 6, :url => request.url) %>">
<i class="iconfont icon-yijianfankui color-white font-22 fl"></i> <i class="iconfont icon-yijianfankui color-white font-22 fl"></i>
</a> </a>
</div> </div>

@ -281,6 +281,10 @@ RedmineApp::Application.routes.draw do ## oauth相关
end end
get 'welcome/ccf' => 'welcome#ccf' get 'welcome/ccf' => 'welcome#ccf'
get 'welcome/shixun_to_local' => 'welcome#shixun_to_local'
get 'welcome/local_to_shixun' => 'welcome#local_to_shixun'
get 'welcome/local_init' => 'welcome#local_init'
# get 'competitions/home' => 'competitions#home' # get 'competitions/home' => 'competitions#home'
# get 'competitions/hn' => 'competitions#index' # get 'competitions/hn' => 'competitions#index'
# get 'competitions/db' => 'competitions#db' # get 'competitions/db' => 'competitions#db'
@ -339,6 +343,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'add_collaborators', :via => [:get, :post] match 'add_collaborators', :via => [:get, :post]
post 'add_subject_members' post 'add_subject_members'
delete 'delete_member' delete 'delete_member'
post 'up_member_position'
post 'down_member_position'
end end
collection do collection do

@ -1,12 +1,12 @@
class MigrateHomeworkCommonEndTimes < ActiveRecord::Migration class MigrateHomeworkCommonEndTimes < ActiveRecord::Migration
def up def up
homework_commons = HomeworkCommon.where("id < 21549") # homework_commons = HomeworkCommon.where("id < 21549")
homework_commons.find_each do |homework| # homework_commons.find_each do |homework|
sql = "update homework_commons set end_time = (select max(end_time) from # sql = "update homework_commons set end_time = (select max(end_time) from
homework_seconds where id = #{homework.id}) where id = #{homework.id}" # homework_seconds where id = #{homework.id}) where id = #{homework.id}"
#
ActiveRecord::Base.connection.execute(sql) # ActiveRecord::Base.connection.execute(sql)
end # end
end end
def down def down

@ -1,11 +1,11 @@
class MigrateHomeworkCommonEndTime2 < ActiveRecord::Migration class MigrateHomeworkCommonEndTime2 < ActiveRecord::Migration
def up def up
homework_commons = HomeworkCommon.where("id >= 21549") # homework_commons = HomeworkCommon.where("id >= 21549")
homework_commons.each do |homework| # homework_commons.each do |homework|
if homework.publish_time.nil? # if homework.publish_time.nil?
homework.update_column('end_time', nil) # homework.update_column('end_time', nil)
end # end
end # end
end end
def down def down

@ -0,0 +1,11 @@
class AddPositionToSubjectMembers < ActiveRecord::Migration
def change
add_column :subject_members, :position, :integer, :default => 1
Subject.all.each do |subject|
subject.subject_members.reorder("id asc").each_with_index do |member, index|
member.update_column('position', index + 1)
end
end
end
end

@ -0,0 +1,47 @@
class CreateLocalShixuns < ActiveRecord::Migration
def change
create_table :local_shixuns do |t|
t.string :name
t.text :description
t.integer :user_id
t.integer :gpid
t.integer :visits
t.integer :status
t.string :language
t.text :authentication
t.string :identifier
t.text :propaedeutics
t.integer :trainee
t.integer :major_id
t.integer :webssh
t.boolean :homepage_show
t.boolean :hidden
t.integer :fork_from
t.boolean :can_copy
t.datetime :modifiy_tim
t.datetime :reset_time
t.integer :closer_id
t.datetime :end_time
t.string :git_url
t.boolean :vnc
t.integer :myshixuns_count
t.integer :challenges_count
t.integer :use_scope
t.text :evaluate_script
t.integer :mirror_script_id
t.string :image_text
t.boolean :code_hidden
t.boolean :task_pass
t.integer :exec_time
t.string :test_set_permission
t.boolean :sigle_training
t.boolean :hide_code
t.boolean :multi_webssh
t.integer :excute_time
t.integer :averge_star
t.integer :forbid_copy
t.timestamps
end
end
end

@ -0,0 +1,10 @@
class CreateLocalMirrorRepositories < ActiveRecord::Migration
def change
create_table :local_mirror_repositories do |t|
t.integer :local_shixun_id
t.integer :mirror_repository_id
t.timestamps
end
end
end

@ -0,0 +1,10 @@
class CreateLocalShixunTagRepertoires < ActiveRecord::Migration
def change
create_table :local_shixun_tag_repertoires do |t|
t.integer :tag_repertoire_id
t.integer :local_shixun_id
t.timestamps
end
end
end

@ -0,0 +1,29 @@
class CreateLocalChallenges < ActiveRecord::Migration
def change
create_table :local_challenges do |t|
t.integer :local_shixun_id
t.string :subject
t.integer :status
t.integer :position
t.text :task_pass
t.text :answer
t.integer :score
t.integer :visits
t.string :path
t.integer :evaluation_way
t.integer :difficulty
t.string :exec_path
t.integer :code_line
t.integer :st
t.text :web_route
t.text :picture_path
t.text :expect_picture_path
t.integer :challenge_tags_count
t.datetime :modify_time
t.string :original_picture_path
t.integer :show_type
t.timestamps
end
end
end

@ -0,0 +1,14 @@
class CreateLocalTestSets < ActiveRecord::Migration
def change
create_table :local_test_sets do |t|
t.text :input
t.text :output
t.integer :local_challenge_id
t.integer :is_public
t.integer :result
t.integer :position
t.timestamps
end
end
end

@ -0,0 +1,10 @@
class CreateLocalChallengeTags < ActiveRecord::Migration
def change
create_table :local_challenge_tags do |t|
t.string :name
t.integer :local_challenge_id
t.timestamps
end
end
end

@ -0,0 +1,5 @@
class AddTestSetScoreToLocalChallenge < ActiveRecord::Migration
def change
add_column :local_challenges, :test_set_score, :integer
end
end

@ -0,0 +1,5 @@
class AddShixunIdToLocalShixun < ActiveRecord::Migration
def change
add_column :local_shixuns, :shixun_id, :integer
end
end

@ -0,0 +1,5 @@
class AddScoreToLocalTestSets < ActiveRecord::Migration
def change
add_column :local_test_sets, :score, :integer
end
end

@ -379,6 +379,7 @@ function sd_create_editor_from_message_data(id){
params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form); params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
params.cancel_btn = $("#new_message_cancel_btn_" + id); params.cancel_btn = $("#new_message_cancel_btn_" + id);
params.submit_btn = $("#new_message_submit_btn_" + id); params.submit_btn = $("#new_message_submit_btn_" + id);
params.notice_msg = $("#new_message_notice_" + id);
params.height = height; params.height = height;
params.width = width; params.width = width;
if (params.textarea.data('init') == undefined) { if (params.textarea.data('init') == undefined) {
@ -432,6 +433,7 @@ function sd_create_message_editor(params){
params.toolbar_container.hide(); params.toolbar_container.hide();
this.resize("100%", "30px"); this.resize("100%", "30px");
params.submit_btn.hide(); params.submit_btn.hide();
params.notice_msg.hide();
} }
$('#mini_comment_section').height('auto'); $('#mini_comment_section').height('auto');
@ -457,6 +459,7 @@ function sd_create_message_editor(params){
$(".private-list").css("max-height",$("#dialogPanel").height()); $(".private-list").css("max-height",$("#dialogPanel").height());
params.submit_btn.show(); params.submit_btn.show();
params.notice_msg.show();
$('#mini_comment_section').height('240px') $('#mini_comment_section').height('240px')
}, },

@ -61,10 +61,10 @@ $(function(){
loadProvince(); loadProvince();
if($("#name_loggin_input").length > 0 && $("#name_loggin_input").val().trim() != ""){ //if($("#name_loggin_input").length > 0 && $("#name_loggin_input").val().trim() != ""){
$("#psd_login_btn").addClass("edu-back-blue"); $("#psd_login_btn").addClass("edu-back-blue");
$("#psd_login_btn").attr("disabled", false); $("#psd_login_btn").attr("disabled", false);
} //}
}); });
$(window).resize(function(){ $(window).resize(function(){

File diff suppressed because it is too large Load Diff

@ -3,6 +3,22 @@
body{font-size:14px; line-height:2.0;background:#fafafa!important;font-family: "微软雅黑","宋体"; color:#05101a;height: 100%;position: relative; body{font-size:14px; line-height:2.0;background:#fafafa!important;font-family: "微软雅黑","宋体"; color:#05101a;height: 100%;position: relative;
} }
html,body{height:100%;} html,body{height:100%;}
/*滚动条样式*/
body::-webkit-scrollbar {/*滚动条整体样式*/
width: 8px; /*高宽分别对应横竖滚动条的尺寸*/
height: 8px;
}
body::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
border-radius: 5px;
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
background: #47494d;
}
body::-webkit-scrollbar-track {/*滚动条里面轨道*/
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
border-radius: 0;
background: rgba(0,0,0,0.1);
}
body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td,span{ margin:0; padding:0;} body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td,span{ margin:0; padding:0;}
table,input,textarea,select,button {outline: none;border-radius: 3px; font-family: "微软雅黑","宋体"; font-size:14px;line-height:1.9;border:1px solid #eaeaea;background: #FFFFff; color:#05101A;} table,input,textarea,select,button {outline: none;border-radius: 3px; font-family: "微软雅黑","宋体"; font-size:14px;line-height:1.9;border:1px solid #eaeaea;background: #FFFFff; color:#05101A;}
textarea{resize: none;} textarea{resize: none;}
@ -170,7 +186,7 @@ input::-ms-clear{display:none;}
/*自定义滚动条宽度*/ /*自定义滚动条宽度*/
::-webkit-scrollbar {width:7px;height:10px;background-color: #F5F5F5; } ::-webkit-scrollbar {width:7px;height:10px;background-color: #F5F5F5; }
::-webkit-scrollbar-track {-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);background-color: #F5F5F5;} ::-webkit-scrollbar-track {-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);background-color: #F5F5F5;}
::-webkit-scrollbar-thumb {-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);background-color: #dadada;} ::-webkit-scrollbar-thumb {-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);background-color: #b5b5b5;border-radius: 78px;}
.newContainer{ min-height:100%; height: auto !important; height: 100%; /*IE6不识别min-height*/position: relative;} .newContainer{ min-height:100%; height: auto !important; height: 100%; /*IE6不识别min-height*/position: relative;}

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :local_challenge_tag do
name "MyString"
local_challenge_id 1
end
end

@ -0,0 +1,25 @@
FactoryGirl.define do
factory :local_challenge do
local_shixun_id 1
subject "MyString"
status 1
position 1
task_pass ""
answer ""
score 1
visits 1
path "MyString"
evaluation_way 1
difficulty 1
exec_path "MyString"
code_line 1
st 1
web_route "MyText"
picture_path "MyText"
expect_picture_path "MyText"
challenge_tags_count 1
modify_time "2019-04-12 14:27:18"
original_picture_path "MyString"
show_type 1
end
end

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :local_mirror_repository do
local_shixun_id 1
mirror_repository_id 1
end
end

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :local_shixun_tag_repertoire do
tag_repertoire_id 1
local_shixun_id 1
end
end

@ -0,0 +1,37 @@
FactoryGirl.define do
factory :local_shixun do
name "MyString"
description "MyText"
user_id 1
gpid 1
visits 1
status 1
language "MyString"
authentication false
identifier "MyString"
propaedeutics "MyText"
trainee 1
major_id 1
webssh 1
homepage_show false
hidden false
fork_from 1
can_copy false
modifiy_tim "2019-04-12 09:21:34"
reset_time ""
closer_id 1
end_time "2019-04-12 09:21:34"
git_url "MyString"
vnc false
myshixuns_count 1
challenges_count 1
use_scope 1
evaluate_script ""
mirror_script_id 1
image_text "MyString"
code_hidden false
task_pass false
exec_time 1
test_set "MyString"
end
end

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :local_test_set do
input ""
output ""
local_challenge_id 1
is_public 1
result 1
position 1
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalChallenge, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalChallengeTag, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalMirrorRepository, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalShixun, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalShixunTagRepertoire, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalTestSet, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save