From 1579a86f9fbabe0741d8237b6e01fb0cd9f61f42 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 23 Mar 2016 17:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E5=B8=88=E7=BB=99=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E5=93=81=E6=89=93=E5=88=86=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=86=8D=E6=AC=A1=E7=BC=96=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E8=A6=81=E7=BB=99=E8=80=81=E5=B8=88=E5=92=8C=E5=8A=A9=E6=95=99?= =?UTF-8?q?=E5=8F=91=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 9 ++++++++ app/controllers/users_controller.rb | 1 + app/helpers/application_helper.rb | 14 ++++++++++++ app/views/users/_user_message_course.html.erb | 22 +++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index a698823e5..9cdb1fc07 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -63,6 +63,13 @@ class StudentWorkController < ApplicationController homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0 end end + + #修改作品提示消息更新 + student_work_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, StudentWork.name, 0) + student_work_messages.each do |message| + message.update_attribute(:viewed, true) + end + # 作品打分消息状态更新 studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0) studentworks_scores.each do |studentworks_score| @@ -369,6 +376,8 @@ class StudentWorkController < ApplicationController @work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@work) if @work.save + #如果学生作品被打分后修改,应该给老师提示 + send_message_to_teacher(@work) if @homework.homework_type == 3 @student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d05867427..d9a0709b9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -717,6 +717,7 @@ class UsersController < ApplicationController end student_work.save + send_message_to_teacher(student_work) homework.update_attributes(:updated_at => Time.now) update_course_activity(homework.class,homework.id) update_user_activity(homework.class,homework.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3a5cdb1a1..1d1a68c72 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2137,6 +2137,20 @@ module ApplicationHelper end + #如果学生作品被打分后修改,应该给老师提示 + def send_message_to_teacher student_work + if StudentWork === student_work + if student_work.student_works_scores.any? + course = student_work.homework_common.course + course.members.map(&:user_id).uniq.each do|user_id| + if User.find(user_id).allowed_to?(:as_teacher, course) + student_work.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course.id, :viewed => false, :status => 1) + end + end + end + end + end + private def wiki_helper diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 7de1ce417..45d833a9a 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -424,6 +424,28 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + + + <% if ma.course_message_type == "StudentWork" && ma.status == 1 %> + + <% end %> <% if ma.course_message_type == "Course" %>