diff --git a/app/models/exercise.rb b/app/models/exercise.rb index c91e59fd9..6b437cbd8 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -8,15 +8,25 @@ class Exercise < ActiveRecord::Base has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过 # 课程消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy - after_create :acts_as_course_message + after_save :acts_as_course_message def acts_as_course_message if self.course - if self.exercise_status == 2 #未发布 + if self.exercise_status == 2 && self.course_messages.where(:status => 2).blank? #已发布 + self.delay.send_exercise_message_delay #self.course.members.each do |m| - self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2) + #self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2) #end - # else - # self.course_messages.destroy_all 这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的 + else + #self.course_messages.destroy_all #这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的 + end + end + end + + #测验通知delay + def send_exercise_message_delay + self.course.members.each do |m| + if m.user_id != self.user_id + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false ,:status=>2) end end end diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 3ff82243a..73ef03909 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -153,7 +153,7 @@ <%= render :partial => 'exercise/total_questions_score', :locals => {:exercise => exercise, :current_score => current_score} %> -
@@ -74,6 +72,10 @@ bt.LEFT_DELIMITER = ''; + <% if not_allow_select %> + $("#input_boxes_div .InputBox").on('focus', modify_input_notice); + <% end %> + $("#programHomework").on('click', 'a.test_icon_add', function () { var html = bt('t:test-answer-list', null); $(this).parent('.mt10').after(html); @@ -90,6 +92,9 @@ } } $(inputs[inputs.length - 1]).focus(); + <% if not_allow_select %> + $("#input_boxes_div .InputBox").on('focus', modify_input_notice); + <% end %> }); $("#programHomework").on('click', 'a.test_icon_remove', function () { $(this).parent('.mt10').remove(); @@ -152,4 +157,9 @@ } } <% end %> + + function modify_input_notice(){ + $("#modify_inputs_notice").html("修改测试集后请通知学生重新提交作品"); + $("#modify_inputs_notice").show(); + } \ No newline at end of file