|
|
@ -927,18 +927,10 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
unless params[:category_id].blank?
|
|
|
|
unless params[:category_id].blank?
|
|
|
|
@category = @course.course_second_categories.find_by(id: params[:category_id], category_type: "shixun_homework")
|
|
|
|
@category = @course.course_second_categories.find_by(id: params[:category_id], category_type: "shixun_homework")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
shixuns.each do |shixun|
|
|
|
|
begin
|
|
|
|
homework = HomeworksService.new.create_homework shixun, @course, @category, current_user
|
|
|
|
shixuns.each do |shixun|
|
|
|
|
@homework_ids << homework.id
|
|
|
|
homework = HomeworksService.new.create_homework shixun, @course, @category, current_user
|
|
|
|
CreateStudentWorkJob.perform_later(homework.id)
|
|
|
|
@homework_ids << homework.id
|
|
|
|
|
|
|
|
CreateStudentWorkJob.perform_later(homework.id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception("创建失败")
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -1019,29 +1011,21 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
|
|
|
|
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
|
|
|
|
|
|
|
|
|
|
|
|
course_module = @course.course_modules.find_by(module_type: "shixun_homework")
|
|
|
|
course_module = @course.course_modules.find_by(module_type: "shixun_homework")
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
subjects.each do |subject|
|
|
|
|
begin
|
|
|
|
|
|
|
|
subjects.each do |subject|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subject.stages.each do |stage|
|
|
|
|
subject.stages.each do |stage|
|
|
|
|
|
|
|
|
|
|
|
|
# 为实训作业创建与stage同名的子目录
|
|
|
|
# 为实训作业创建与stage同名的子目录
|
|
|
|
category = CourseSecondCategory.find_by(name: stage.name, course_id: @course.id, category_type: "shixun_homework") ||
|
|
|
|
category = CourseSecondCategory.find_by(name: stage.name, course_id: @course.id, category_type: "shixun_homework") ||
|
|
|
|
CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework",
|
|
|
|
CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework",
|
|
|
|
course_module_id: course_module.id, position: course_module.course_second_categories.count + 1)
|
|
|
|
course_module_id: course_module.id, position: course_module.course_second_categories.count + 1)
|
|
|
|
|
|
|
|
|
|
|
|
# 去掉不对当前用户的单位公开的实训,已发布的实训
|
|
|
|
# 去掉不对当前用户的单位公开的实训,已发布的实训
|
|
|
|
stage.shixuns.where.not(shixuns: {id: none_shixun_ids}).unhidden.each do |shixun|
|
|
|
|
stage.shixuns.where.not(shixuns: {id: none_shixun_ids}).unhidden.each do |shixun|
|
|
|
|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
|
|
|
|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
|
|
|
|
@homework_ids << homework.id
|
|
|
|
@homework_ids << homework.id
|
|
|
|
CreateStudentWorkJob.perform_later(homework.id)
|
|
|
|
CreateStudentWorkJob.perform_later(homework.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception("创建失败")
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1070,7 +1054,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
charge_group_ids = @course.charge_group_ids(current_user)
|
|
|
|
charge_group_ids = @course.charge_group_ids(current_user)
|
|
|
|
publish_groups = charge_group_ids & params[:group_ids] if params[:group_ids]
|
|
|
|
publish_groups = charge_group_ids & params[:group_ids] if params[:group_ids]
|
|
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
# ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
homeworks.each do |homework|
|
|
|
|
homeworks.each do |homework|
|
|
|
|
# 作业未发布时
|
|
|
|
# 作业未发布时
|
|
|
@ -1141,7 +1125,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
tip_exception("发布失败")
|
|
|
|
tip_exception("发布失败")
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def end_groups
|
|
|
|
def end_groups
|
|
|
@ -1170,9 +1154,9 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
charge_group_ids = @course.charge_group_ids(current_user)
|
|
|
|
charge_group_ids = @course.charge_group_ids(current_user)
|
|
|
|
end_groups = charge_group_ids & params[:group_ids] if params[:group_ids]
|
|
|
|
end_groups = charge_group_ids & params[:group_ids] if params[:group_ids]
|
|
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
homeworks.each do |homework|
|
|
|
|
homeworks.each do |homework|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
homework_detail_manual = homework.homework_detail_manual
|
|
|
|
homework_detail_manual = homework.homework_detail_manual
|
|
|
|
|
|
|
|
|
|
|
|
# 分组设置
|
|
|
|
# 分组设置
|
|
|
@ -1187,7 +1171,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
none_end_settings.update_all(end_time: time)
|
|
|
|
none_end_settings.update_all(end_time: time)
|
|
|
|
student_works = homework.student_works.where(user_id: course_students.where(course_group_id: none_end_settings.
|
|
|
|
student_works = homework.student_works.where(user_id: course_students.where(course_group_id: none_end_settings.
|
|
|
|
pluck(:course_group_id)).pluck(:user_id)).has_committed if homework.homework_type == "practice"
|
|
|
|
pluck(:course_group_id)).pluck(:user_id)).has_committed if homework.homework_type == "practice"
|
|
|
|
|
|
|
|
|
|
|
|
homework.end_time = homework.max_group_end_time
|
|
|
|
homework.end_time = homework.max_group_end_time
|
|
|
|
if homework.end_time > time && homework_detail_manual.try(:comment_status) > 1
|
|
|
|
if homework.end_time > time && homework_detail_manual.try(:comment_status) > 1
|
|
|
@ -1210,40 +1194,40 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if homework.allow_late
|
|
|
|
student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if homework.allow_late
|
|
|
|
|
|
|
|
|
|
|
|
=begin
|
|
|
|
=begin
|
|
|
|
student_works.where("work_status != 0").includes(:myshixun).each do |student_work|
|
|
|
|
student_works.where("work_status != 0").includes(:myshixun).each do |student_work|
|
|
|
|
unless student_work.myshixun.is_complete?
|
|
|
|
unless student_work.myshixun.is_complete?
|
|
|
|
student_work.update_attributes(work_status: 2, late_penalty: homework.late_penalty)
|
|
|
|
student_work.update_attributes(work_status: 2, late_penalty: homework.late_penalty)
|
|
|
|
student_work.late_penalty = homework.late_penalty
|
|
|
|
student_work.late_penalty = homework.late_penalty
|
|
|
|
end
|
|
|
|
|
|
|
|
HomeworksService.new.set_shixun_final_score student_work, student_work.myshixun, homework_detail_manual.answer_open_evaluation,
|
|
|
|
|
|
|
|
homework_challenge_settings
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
HomeworksService.new.set_shixun_final_score student_work, student_work.myshixun, homework_detail_manual.answer_open_evaluation,
|
|
|
|
|
|
|
|
homework_challenge_settings
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
student_works.where("work_status = 0").each do |student_work|
|
|
|
|
student_works.where("work_status = 0").each do |student_work|
|
|
|
|
myshixun = Myshixun.where(shixun_id: shixun.id, user_id: student_work.user_id).first
|
|
|
|
myshixun = Myshixun.where(shixun_id: shixun.id, user_id: student_work.user_id).first
|
|
|
|
if myshixun.present?
|
|
|
|
if myshixun.present?
|
|
|
|
student_work.update_attributes(work_status: (myshixun.is_complete? ? 1 : 2),
|
|
|
|
student_work.update_attributes(work_status: (myshixun.is_complete? ? 1 : 2),
|
|
|
|
late_penalty: myshixun.is_complete? ? 0 : homework.late_penalty,
|
|
|
|
late_penalty: myshixun.is_complete? ? 0 : homework.late_penalty,
|
|
|
|
commit_time: myshixun.created_at, myshixun_id: myshixun.id)
|
|
|
|
commit_time: myshixun.created_at, myshixun_id: myshixun.id)
|
|
|
|
student_work.late_penalty = myshixun.is_complete? ? 0 : homework.late_penalty
|
|
|
|
student_work.late_penalty = myshixun.is_complete? ? 0 : homework.late_penalty
|
|
|
|
HomeworksService.new.set_shixun_final_score student_work, myshixun, homework_detail_manual.answer_open_evaluation,
|
|
|
|
HomeworksService.new.set_shixun_final_score student_work, myshixun, homework_detail_manual.answer_open_evaluation,
|
|
|
|
homework_challenge_settings
|
|
|
|
homework_challenge_settings
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
=end
|
|
|
|
=end
|
|
|
|
|
|
|
|
|
|
|
|
# 更新所有学生的效率分(重新取homework确保是更新后的)
|
|
|
|
# 更新所有学生的效率分(重新取homework确保是更新后的)
|
|
|
|
HomeworkEndUpdateScoreJob.perform_later(homework.id) if !homework.allow_late && homework.end_time <= time
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
homework.save!
|
|
|
|
homework.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
normal_status(0, "更新成功")
|
|
|
|
HomeworkEndUpdateScoreJob.perform_later(homework.id) if !homework.allow_late && homework.end_time <= time
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception("操作失败")
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
normal_status(0, "更新成功")
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception("操作失败")
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|