|
|
@ -927,19 +927,11 @@ 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
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
shixuns.each do |shixun|
|
|
|
|
shixuns.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
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception("创建失败")
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 选用实训课程
|
|
|
|
# 选用实训课程
|
|
|
@ -1019,8 +1011,6 @@ 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
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
subjects.each do |subject|
|
|
|
|
subjects.each do |subject|
|
|
|
|
|
|
|
|
|
|
|
|
subject.stages.each do |stage|
|
|
|
|
subject.stages.each do |stage|
|
|
|
@ -1038,12 +1028,6 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception("创建失败")
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def publish_groups
|
|
|
|
def publish_groups
|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
|
|
# 分组设置
|
|
|
|
# 分组设置
|
|
|
@ -1233,11 +1217,12 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
=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
|
|
|
|
|
|
|
|
HomeworkEndUpdateScoreJob.perform_later(homework.id) if !homework.allow_late && homework.end_time <= time
|
|
|
|
|
|
|
|
end
|
|
|
|
normal_status(0, "更新成功")
|
|
|
|
normal_status(0, "更新成功")
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
uid_logger(e.message)
|
|
|
|
uid_logger(e.message)
|
|
|
@ -1245,7 +1230,6 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_public
|
|
|
|
def set_public
|
|
|
|
tip_exception("仅公开课堂才能公开作业") if @course.is_public == 0
|
|
|
|
tip_exception("仅公开课堂才能公开作业") if @course.is_public == 0
|
|
|
|