班级测验发布时发送消息通知

This commit is contained in:
cxt 2017-03-24 20:45:11 +08:00
parent b6bf0aafb1
commit 69690d57a4
1 changed files with 7 additions and 6 deletions

View File

@ -14,9 +14,11 @@ class ExerciseController < ApplicationController
exercise.update_column('exercise_status', 2)
course = exercise.course
course.members.each do |m|
if m.user_id != exercise.user_id
exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
end
end
if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?)
render_403
@ -41,10 +43,12 @@ class ExerciseController < ApplicationController
publish_exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
course = exercise.course
if m.user_id != exercise.user_id
course.members.each do |m|
exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
end
end
unless User.current.member_of_course?(@course) || User.current.admin?
render_403
@ -441,9 +445,6 @@ class ExerciseController < ApplicationController
@exercise.exercise_status = 2
@exercise.publish_time = Time.now
if @exercise.save
@exercise.course.members.each do |m|
@exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2)
end
#redirect_to exercise_index_url(:course_id=> @course.id)
respond_to do |format|
format.js