普通作业和编程作业在题库发送后,编辑并进行发布,没有自动创建作品列表
复制班级功能里,勾选“作业”,同上 对应方法:在作业的发布时间点(不用考虑作业是通过何种途径生成的),除了发布作业外,应该为该作业自动创建完整的作品列表(分组作业除外)
This commit is contained in:
parent
68dd0a52d2
commit
b8dc444cc7
|
@ -94,8 +94,10 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
status = false
|
||||
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
|
||||
homework_detail_manual.comment_status = 1
|
||||
status = true
|
||||
end
|
||||
eval_start = homework_detail_manual.evaluation_start
|
||||
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
|
||||
|
@ -145,6 +147,10 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework_detail_programing.save if @homework_detail_programing
|
||||
@homework_detail_group.save if @homework_detail_group
|
||||
|
||||
if @homework.homework_type != 3 && homework_detail_manual.comment_status == 1 && status
|
||||
create_works_list @homework
|
||||
end
|
||||
|
||||
if params[:is_manage] == "1"
|
||||
redirect_to manage_or_receive_homeworks_user_path(User.current.id)
|
||||
elsif params[:is_manage] == "2"
|
||||
|
|
|
@ -1115,23 +1115,8 @@ class UsersController < ApplicationController
|
|||
homework_detail_programing.save if homework_detail_programing
|
||||
homework_detail_group.save if homework_detail_group
|
||||
|
||||
if homework.homework_type != 3
|
||||
students = homework.course.student
|
||||
if !homework.course.nil? && !students.empty?
|
||||
name = homework.name
|
||||
name_str = name + "的作品提交"
|
||||
str = ""
|
||||
students.each do |student|
|
||||
if str != ""
|
||||
str += ","
|
||||
end
|
||||
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
|
||||
end
|
||||
#('#{name}的作品提交',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')
|
||||
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
|
||||
#StudentWork.create(:name => "#{name}的作品提交", :homework_common_id => homework.id, :user_id => student.student_id)
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
end
|
||||
if homework.homework_type != 3 && homework_detail_manual.comment_status == 1
|
||||
create_works_list homework
|
||||
end
|
||||
|
||||
if params[:quotes] && !params[:quotes].blank?
|
||||
|
|
|
@ -3436,3 +3436,20 @@ def course_syllabus_option user = User.current
|
|||
end
|
||||
type
|
||||
end
|
||||
|
||||
def create_works_list homework
|
||||
students = homework.course.student
|
||||
if !homework.course.nil? && !students.empty?
|
||||
name = homework.name
|
||||
name_str = name + "的作品提交"
|
||||
str = ""
|
||||
students.each do |student|
|
||||
if str != ""
|
||||
str += ","
|
||||
end
|
||||
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
|
||||
end
|
||||
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,22 @@ namespace :homework_publishtime do
|
|||
homework_detail_manual = homework.homework_detail_manual
|
||||
if homework_detail_manual.comment_status == 0
|
||||
homework_detail_manual.update_column('comment_status', 1)
|
||||
if homework.homework_type != 3
|
||||
students = homework.course.student
|
||||
if !homework.course.nil? && !students.empty?
|
||||
name = homework.name
|
||||
name_str = name + "的作品提交"
|
||||
str = ""
|
||||
students.each do |student|
|
||||
if str != ""
|
||||
str += ","
|
||||
end
|
||||
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
|
||||
end
|
||||
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
end
|
||||
end
|
||||
course = homework.course
|
||||
course.members.each do |m|
|
||||
homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => nil)
|
||||
|
|
Loading…
Reference in New Issue