From 2f2ad38cdf7d9dcc0a2ba21f962e3c5cea02762d Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Fri, 16 Oct 2015 09:30:44 +0800
Subject: [PATCH 1/7] =?UTF-8?q?1.=E7=94=A8=E6=88=B7=E8=A2=AB=E6=8B=89?=
=?UTF-8?q?=E5=85=A5=E9=A1=B9=E7=9B=AE=EF=BC=8C=E5=8F=91=E9=80=81=E7=9B=B8?=
=?UTF-8?q?=E5=BA=94=E6=B6=88=E6=81=AF=E7=BB=99=E8=AF=A5=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=EF=BC=9B=202.=E7=94=A8=E6=88=B7=E8=A2=AB=E7=A7=BB=E5=87=BA?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE=EF=BC=8C=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=E7=BB=99=E8=AF=A5=E7=94=A8=E6=88=B7=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/members_controller.rb | 7 +++-
app/controllers/projects_controller.rb | 8 ++++
app/views/users/_user_message_forge.html.erb | 42 ++++++++++++++++++++
3 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index 6271a6832..6bb61e6a1 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -81,8 +81,12 @@ class MembersController < ApplicationController
user_ids.each do |user_id|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
- ## added by nie
+ #给新成员发送加入项目的消息,发送者id放在ForgeMessage的forge_message_id字段中,
+ #forge_message_type设置为JoinProject
+ forge_join = ForgeMessage.new(:user_id =>user_id, :forge_message_id=>User.current.id,:project_id => @project.id,:forge_message_type=>"JoinProject", :viewed => false)
+ forge_join.save
+ ## added by nie
if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0])
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager)
@@ -301,6 +305,7 @@ class MembersController < ApplicationController
grade.destroy
end
end
+ ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id)
end
respond_to do |format|
format.html { redirect_to_settings_in_projects }
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 90974b376..d26e465ba 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -534,6 +534,14 @@ class ProjectsController < ApplicationController
project_invite_messages.each do |project_invite_message|
project_invite_message.update_attribute(:viewed, true)
end
+ #更新被加入项目消息的viewed字段
+ join_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "JoinProject")
+ join_project_messages.each do |join_project|
+ join_project.update_attribute(:viewed, true)
+ end
+ #更新被移出项目消息的viewed字段
+ remove_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "RemoveFromProject")
+ remove_project_messages.update_all(:viewed => true)
end
def message_invite(message_id, key)
diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb
index b93122bd2..653771f2a 100644
--- a/app/views/users/_user_message_forge.html.erb
+++ b/app/views/users/_user_message_forge.html.erb
@@ -20,6 +20,48 @@
<%= time_tag(ma.created_at).html_safe %>
<% end %>
+
+ <% if ma.forge_message_type == "JoinProject" %>
+
+ -
+ <%=link_to image_tag(url_to_avatar(User.find(ma.forge_message_id)), :width => "30", :height => "30"), user_path(ma.forge_message_id) %>
+
+ -
+ <%=link_to User.find(ma.forge_message_id), user_path(User.find(ma.forge_message_id)), :class => "newsBlue homepageNewsPublisher" %>
+ ">将您加入了项目:
+
+ -
+ <%= link_to ma.project, project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= ma.project %>
+
+ - <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.forge_message_type == "RemoveFromProject" %>
+
+ -
+ <%=link_to image_tag(url_to_avatar(User.find(ma.forge_message_id)), :width => "30", :height => "30"), user_path(ma.forge_message_id) %>
+
+ -
+ <%=link_to User.find(ma.forge_message_id), user_path(User.find(ma.forge_message_id)), :class => "newsBlue homepageNewsPublisher" %>
+ ">将您移出了项目:
+
+ -
+ <%= link_to ma.project, project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= ma.project %>
+
+ - <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
<% if ma.forge_message_type == "ProjectInvite" %>
<% inviter = User.find(ma.forge_message_id) %>
From 2160d508f30d74721c228d9e2942e9f4f96fe5f2 Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Fri, 16 Oct 2015 10:31:10 +0800
Subject: [PATCH 2/7] =?UTF-8?q?1.=E6=9B=B4=E6=94=B9=E5=8A=A0=E5=85=A5?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BB=A5=E5=8F=8A=E7=A7=BB=E5=87=BA=E9=A1=B9?=
=?UTF-8?q?=E7=9B=AE=E6=B6=88=E6=81=AF=E7=9A=84=E6=8F=90=E7=A4=BA=EF=BC=9B?=
=?UTF-8?q?=202.=E5=AF=B9=E4=BA=8E=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=EF=BC=8C=E5=BD=93=E4=BD=9C=E4=B8=9A=E6=B6=88?=
=?UTF-8?q?=E6=81=AF=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E4=B8=8D=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=EF=BC=9B=203.=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E4=B8=AD=EF=BC=8C=E2=80=9C=E5=85=A8=E9=83=A8=E2=80=9D=E6=94=B9?=
=?UTF-8?q?=E6=88=90=E2=80=9C=E6=89=80=E6=9C=89=E6=B6=88=E6=81=AF=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 2 +-
.../users/_selector_for_messages.html.erb | 4 ++--
app/views/users/_user_message_course.html.erb | 2 +-
app/views/users/_user_message_forge.html.erb | 20 ++++++++++++++-----
4 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 3de491421..10b55d1cd 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -145,7 +145,7 @@ class UsersController < ApplicationController
when 'forge_news'
@message_alls = ForgeMessage.where("forge_message_type in (?,?) and user_id =?", "News", "Comment", @user).order("created_at desc")
when 'apply'
- @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject') and user_id =?", @user).order("created_at desc")
+ @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject', 'JoinProject', 'RemoveFromProject') and user_id =?", @user).order("created_at desc")
#贴吧消息
when 'forum'
diff --git a/app/views/users/_selector_for_messages.html.erb b/app/views/users/_selector_for_messages.html.erb
index e7884fc60..10c7e3e34 100644
--- a/app/views/users/_selector_for_messages.html.erb
+++ b/app/views/users/_selector_for_messages.html.erb
@@ -19,7 +19,7 @@
<%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "homepageTypePTask postTypeGrey" %>
<%= link_to "项目讨论", user_message_path(User.current, :type => 'forge_message'), :class => "homepagePostTypeForum postTypeGrey" %>
<%= link_to "项目新闻", user_message_path(User.current, :type => 'forge_news'), :class => "homepageTypePNews postTypeGrey" %>
- <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "homepageTypeUApply postTypeGrey" %>
+ <%= link_to "加入项目", user_message_path(User.current, :type => 'apply'), :class => "homepageTypeUApply postTypeGrey" %>
@@ -27,7 +27,7 @@
- 更多
- - <%= link_to "全部",user_message_path(User.current), :class => "resourcesTypeAll postTypeGrey" %>
+ - <%= link_to "所有消息",user_message_path(User.current), :class => "resourcesTypeAll postTypeGrey" %>
- <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "homepageTypeUnread postTypeGrey" %>
- <%= link_to "系统消息", user_system_messages_path(User.current), :class => "homepageTypeSystem postTypeGrey" %>
- <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "homepageTypePost postTypeGrey" %>
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index d4b61e966..d9b4f7a3d 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -37,7 +37,7 @@
- <%= time_tag(ma.created_at).html_safe %>
<% end %>
- <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil? %>
+ <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil? && !ma.course_message.nil? %>
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb
index 653771f2a..a7777a59a 100644
--- a/app/views/users/_user_message_forge.html.erb
+++ b/app/views/users/_user_message_forge.html.erb
@@ -31,12 +31,17 @@
">将您加入了项目:
-
- <%= link_to ma.project, project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ <%= link_to ma.project, project_member_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
- <%= ma.project %>
+
+ 项目名称:<%= ma.project.name %>
+
+
+ 项目描述:<%= ma.project.description %>
+
- <%= time_tag(ma.created_at).html_safe %>
@@ -52,12 +57,17 @@
">将您移出了项目:
- <%= link_to ma.project, project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ <%= link_to ma.project, member_project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
- <%= ma.project %>
+
+ 项目名称:<%= ma.project.name %>
+
+
+ 项目描述:<%= ma.project.description %>
+
<%= time_tag(ma.created_at).html_safe %>
@@ -71,7 +81,7 @@
<%=link_to inviter, user_path(inviter), :class => "newsBlue homepageNewsPublisher" %>
- '>邀请你加入项目
+ '>邀请你加入项目:
<% if ma.user.member_of?(ma.project) %>
From 4d246de1c64c3fe80117bf617d2e214c8604d83e Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Fri, 16 Oct 2015 15:07:09 +0800
Subject: [PATCH 3/7] =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E8=A2=AB=E6=8B=89?=
=?UTF-8?q?=E5=85=A5=E6=88=96=E8=80=85=E7=A7=BB=E5=87=BA=E6=9F=90=E7=A7=81?=
=?UTF-8?q?=E6=9C=89=E9=A1=B9=E7=9B=AE=E5=AF=B9=E5=BA=94=E7=9A=84=E6=B6=88?=
=?UTF-8?q?=E6=81=AF=EF=BC=8C=E5=BD=93=E7=94=A8=E6=88=B7=E6=B2=A1=E6=9C=89?=
=?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=9D=83=E9=99=90=EF=BC=8C=E5=BA=94=E7=BB=99?=
=?UTF-8?q?=E5=87=BA=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/users/_user_message_course.html.erb | 2 +-
app/views/users/_user_message_forge.html.erb | 38 +++++++++++++------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index d9b4f7a3d..36318c20b 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -102,7 +102,7 @@
课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.term %>)
作业标题:<%= ma.course_message.name %>
提交截止:<%= ma.course_message.end_time %> 24点
- 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> @ 24点
+ 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 24点
迟交扣分:<%= ma.course_message.late_penalty %>分
请同学们抓紧时间提交自己的作品,谢谢!
<% else %>
diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb
index a7777a59a..9a9bec10d 100644
--- a/app/views/users/_user_message_forge.html.erb
+++ b/app/views/users/_user_message_forge.html.erb
@@ -36,12 +36,19 @@
:onmouseout => "message_titile_hide($(this))" %>
-
- 项目名称:<%= ma.project.name %>
-
-
- 项目描述:<%= ma.project.description %>
-
+ <% if ma.project.is_public? || User.current.member_of?(ma.project) %>
+
+ 项目名称:<%= ma.project.name %>
+
+
+
+ 项目描述:<%= ma.project.description %>
+
+ <% else %>
+
+ 您已经被移出该私有项目,非项目成员没有权限访问私有项目
+
+ <% end %>
<%= time_tag(ma.created_at).html_safe %>
@@ -62,12 +69,19 @@
:onmouseout => "message_titile_hide($(this))" %>
-
- 项目名称:<%= ma.project.name %>
-
-
- 项目描述:<%= ma.project.description %>
-
+ <% if ma.project.is_public? || User.current.member_of?(ma.project) %>
+
+ 项目名称:<%= ma.project.name %>
+
+
+
+ 项目描述:<%= ma.project.description %>
+
+ <% else %>
+
+ 您已经被移出该私有项目,非项目成员没有权限访问私有项目
+
+ <% end %>
<%= time_tag(ma.created_at).html_safe %>
From 86cd27eb1742304ecfe2b9aa674c1da57c505054 Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Fri, 16 Oct 2015 17:30:46 +0800
Subject: [PATCH 4/7] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=AD=EF=BC=8C?=
=?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF=E7=9A=84=E6=A0=87=E9=A2=98?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E2=80=9C=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=E2=80=9D=EF=BC=8C=E8=80=8C=E9=9D=9E=E2=80=9C=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/users/_selector_for_messages.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/users/_selector_for_messages.html.erb b/app/views/users/_selector_for_messages.html.erb
index 10c7e3e34..66f9ec7a3 100644
--- a/app/views/users/_selector_for_messages.html.erb
+++ b/app/views/users/_selector_for_messages.html.erb
@@ -29,7 +29,7 @@
更多
<%= link_to "所有消息",user_message_path(User.current), :class => "resourcesTypeAll postTypeGrey" %>
<%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "homepageTypeUnread postTypeGrey" %>
- <%= link_to "系统消息", user_system_messages_path(User.current), :class => "homepageTypeSystem postTypeGrey" %>
+ <%= link_to "系统消息", user_system_messages_path(User.current, :type => 'system_messages'), :class => "homepageTypeSystem postTypeGrey" %>
<%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "homepageTypePost postTypeGrey" %>
<%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "homepageTypeUMessage postTypeGrey" %>
From 4deeaa0f34faa08c1a194c7277b77d9637bb35f9 Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Mon, 19 Oct 2015 15:45:24 +0800
Subject: [PATCH 5/7] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=EF=BC=9A=E7=94=A8=E6=88=B7=E8=BF=9F=E4=BA=A4=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8F=91=E9=80=81=E4=B8=8D=E8=83=BD=E5=8F=82?=
=?UTF-8?q?=E4=B8=8E=E5=8C=BF=E8=AF=84=E7=9A=84=E6=B6=88=E6=81=AF=EF=BC=9B?=
=?UTF-8?q?=202.=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF=EF=BC=9A=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E5=88=9B=E5=BB=BA=E8=AF=BE=E7=A8=8B=E6=97=B6=EF=BC=8C?=
=?UTF-8?q?=E5=8F=91=E9=80=81=E5=88=9B=E5=BB=BA=E8=AF=BE=E7=A8=8B=E6=B6=88?=
=?UTF-8?q?=E6=81=AF=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 4 ++
app/controllers/student_work_controller.rb | 3 ++
app/models/course.rb | 6 ++-
app/models/student_work.rb | 8 +++
app/views/users/_user_message_course.html.erb | 53 +++++++++++++++++++
5 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index e12d4886a..7d26b2eca 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -615,6 +615,10 @@ class CoursesController < ApplicationController
end
def show
+ #更新创建课程消息状态
+ create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
+ create_course_messages.update_all(:viewed => true)
+
course_activities = @course.course_activities
@canShowRealName = User.current.member_of_course? @course
@page = params[:page] ? params[:page].to_i + 1 : 0
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 17f179492..abc642030 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -62,6 +62,9 @@ class StudentWorkController < ApplicationController
journals_for_teacher.each do |journal_for_teacher|
journal_for_teacher.update_attributes(:viewed => true)
end
+ #不能参与作业匿评消息状态更新
+ no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "NoEvaluation", 0)
+ no_evaluation.update_all(:viewed => true)
# 作品留言
# 消息end
#设置作业对应的forge_messages表的viewed字段
diff --git a/app/models/course.rb b/app/models/course.rb
index 501d958e4..46599dbfc 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -50,7 +50,7 @@ class Course < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000
before_save :self_validate
- after_create :create_board_sync, :act_as_course_activity
+ after_create :create_board_sync, :act_as_course_activity, :act_as_course_message
before_destroy :delete_all_members
safe_attributes 'extra',
@@ -321,6 +321,10 @@ class Course < ActiveRecord::Base
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
end
+ #创建课程后,给该用户发送消息
+ def act_as_course_message
+ self.course_messages << CourseMessage.new(:user_id => self.tea_id, :course_id => self.id, :viewed => false)
+ end
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
#def name
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index cd4d81a32..700613792 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -12,6 +12,7 @@ class StudentWork < ActiveRecord::Base
before_destroy :delete_praise
before_save :set_program_score, :set_src
+ after_create :act_as_message
acts_as_attachable
def delete_praise
@@ -136,4 +137,11 @@ class StudentWork < ActiveRecord::Base
end
end
end
+
+ def act_as_message
+ if self.created_at > self.homework_common.end_time + 1
+ CourseMessage.create(:user_id => self.user_id, :course_id => self.homework_common.course_id,
+ :course_message_id => self.id, :course_message_type => 'NoEvaluation',:viewed => false)
+ end
+ end
end
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 36318c20b..f57d22bc5 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -359,4 +359,57 @@
<% end %>
<% end %>
+
+ <% if ma.course_message_type == "NoEvaluation" %>
+
+
+ -
+ ">迟交作业,不能参与作业匿评!
+
+ <% student_work = StudentWork.find(ma.course_message_id)%>
+ -
+ <%= link_to student_work.homework_common.name, student_work_index_path(:homework => student_work.homework_common_id),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= User.current.lastname + User.current.firstname %>
+ <%= User.current.allowed_to?(:as_teacher,student_work.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:
+
+
课程名称:<%= student_work.homework_common.course.name %>(<%= student_work.homework_common.course.term %>)
+
作业标题:<%=student_work.homework_common.name %>
+
提交截止:<%=student_work.homework_common.end_time %> 24点
+
提交时间:<%=format_time(student_work.created_at) %>
+
+ - <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.course_message_type == "Course" %>
+
+
+ -
+ 系统提示
+ ">您成功创建了课程:
+
+ -
+ <%= link_to ma.course_message.name, course_path(ma.course_message),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= User.current.lastname + User.current.firstname %>老师您好!您成功创建了一个课程,详情如下:
+
+
课程名称:<%= ma.course_message.name %>
+
开课学期:<%= ma.course_message.term %>
+
课程描述:
+
<%= ma.course_message.description.html_safe %>
+
学时总数:<%= ma.course_message.class_period%>
+
创建时间:<%= format_time(ma.course_message.created_at) %>
+
+ - <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
<% end %>
\ No newline at end of file
From efbae1f003270b31ca5c9d724a4af0b8743235de Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Mon, 19 Oct 2015 16:59:08 +0800
Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E5=86=85=E5=AE=B9=EF=BC=9A=E6=8A=8A?=
=?UTF-8?q?=E2=80=9C=E4=BD=A0=E2=80=9D=E7=BB=9F=E4=B8=80=E6=94=B9=E6=88=90?=
=?UTF-8?q?=E2=80=9C=E6=82=A8=E2=80=9D=EF=BC=9B=E5=8F=91=E5=B8=83=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A=E6=98=AF=E6=9C=AC=E4=BA=BA=E7=9A=84=E8=AF=9D=EF=BC=8C?=
=?UTF-8?q?=E6=94=B9=E6=88=90=E2=80=9C=E6=82=A8=E5=8F=91=E5=B8=83=E4=BA=86?=
=?UTF-8?q?=E4=BD=9C=E4=B8=9A=E2=80=9D=EF=BC=8C=E8=80=8C=E9=9D=9E=E2=80=9C?=
=?UTF-8?q?=E6=9F=90=E6=9F=90=E8=80=81=E5=B8=88=E5=8F=91=E5=B8=83=E4=BA=86?=
=?UTF-8?q?=E4=BD=9C=E4=B8=9A=E2=80=9D=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 4 ++--
app/views/users/_user_message_course.html.erb | 18 ++++++++++--------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 10b55d1cd..797ad1bd4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -128,12 +128,12 @@ class UsersController < ApplicationController
#课程相关消息
when 'homework'
- @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage') and user_id =?", @user).order("created_at desc")
+ @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','NoEvaluation') and user_id =?", @user).order("created_at desc")
when 'course_message'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
when 'course_news'
# 课程通知包含发布的通知和回复的通知
- @message_alls = CourseMessage.where("course_message_type =? or course_message_type =?", "News", "Comment").where("user_id =?", @user).order("created_at desc")
+ @message_alls = CourseMessage.where("course_message_type in (?, ? ,?)", "News", "Comment", "Course").where("user_id =?", @user).order("created_at desc")
when 'poll'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc")
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index f57d22bc5..7f535f2ec 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -52,7 +52,7 @@
<% if User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
<%= User.current.lastname + User.current.firstname %>老师您好!
- <%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.show_name + "老师")%>刚刚发布了一个作业:
课程名称:<%= ma.course_message.course.name %>
(<%= ma.course_message.course.term %>)
@@ -66,7 +66,7 @@
您可以修改作业内容、评分规则、匿评过程等,谢谢!
<% else %>
- <%= User.current.lastname + User.current.firstname %>同学你好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:
+ <%= User.current.lastname + User.current.firstname %>同学您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:
课程名称:<%= ma.course_message.course.name %>
(<%= ma.course_message.course.term %>)
作业标题:<%= ma.course_message.name %>
@@ -302,7 +302,7 @@
本次作业将在<%= ma.course_message.student_work.homework_common.homework_detail_manual.evaluation_end %> 24点结束匿评,到时您将可以看到所有其他同学的作品啦!大家可以进一步互相学习。
- 期待你取得更大的进步!
+ 期待您取得更大的进步!
<% end %>
@@ -348,6 +348,8 @@
:onmouseout => "message_titile_hide($(this))" %>
+
回复人:
+
<%= ma.course_message.user.show_name %>
回复内容:
<%= ma.course_message.notes %>
您的评论:
@@ -368,7 +370,7 @@
<% student_work = StudentWork.find(ma.course_message_id)%>
- <%= link_to student_work.homework_common.name, student_work_index_path(:homework => student_work.homework_common_id),
+ <%= link_to "由于迟交作业,您及您的作品都不能参与作业的匿评", student_work_index_path(:homework => student_work.homework_common_id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
@@ -377,9 +379,9 @@
<%= User.current.lastname + User.current.firstname %>
<%= User.current.allowed_to?(:as_teacher,student_work.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:
-
课程名称:<%= student_work.homework_common.course.name %>(<%= student_work.homework_common.course.term %>)
+
课程名称:<%= student_work.homework_common.course.name %>(<%= student_work.homework_common.course.time.to_s + '年' + student_work.homework_common.course.term %>)
作业标题:<%=student_work.homework_common.name %>
-
提交截止:<%=student_work.homework_common.end_time %> 24点
+
提交截止:<%=student_work.homework_common.end_time %> 24:00
提交时间:<%=format_time(student_work.created_at) %>
<%= time_tag(ma.created_at).html_safe %>
@@ -394,7 +396,7 @@
">您成功创建了课程:
- <%= link_to ma.course_message.name, course_path(ma.course_message),
+ <%= link_to "课程名称:" + ma.course_message.name, course_path(ma.course_message),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
@@ -403,7 +405,7 @@
<%= User.current.lastname + User.current.firstname %>老师您好!您成功创建了一个课程,详情如下:
课程名称:<%= ma.course_message.name %>
- 开课学期:<%= ma.course_message.term %>
+ 开课学期:<%= ma.course_message.time.to_s + '年' + ma.course_message.term %>
课程描述:
<%= ma.course_message.description.html_safe %>
学时总数:<%= ma.course_message.class_period%>
From 7898208b1604d906f20d05922138de913d79645a Mon Sep 17 00:00:00 2001
From: huang
Date: Mon, 19 Oct 2015 17:01:47 +0800
Subject: [PATCH 7/7] =?UTF-8?q?=E7=A7=81=E6=9C=89=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=B5=84=E6=BA=90=E9=83=BD=E4=B8=BA=E7=A7=81?=
=?UTF-8?q?=E6=9C=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/attachment.rb | 7 ++++++-
app/views/files/_course_list.html.erb | 13 ++++++++++---
.../lib/acts_as_attachable.rb | 17 +++++++++++------
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index f7fb9b1aa..0f728fc00 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -442,7 +442,12 @@ class Attachment < ActiveRecord::Base
def self.attach_filesex(obj, attachments,attachment_type)
- result = obj.save_attachmentsex(attachments, User.current,attachment_type)
+ if obj.is_public?
+ public_status = true
+ else
+ public_status = false
+ end
+ result = obj.save_attachmentsex(attachments, User.current,attachment_type, public_status)
obj.attach_saved_attachments
result
end
diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb
index 9e88cb2fd..3c6d545db 100644
--- a/app/views/files/_course_list.html.erb
+++ b/app/views/files/_course_list.html.erb
@@ -33,9 +33,16 @@
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
-
- <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
-
+ <% if @course.is_public? %>
+
+ <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
+
+ <% else %>
+
+ 私有
+
+ <% end %>
+
<% else %>
<% end %>
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index 377f2b112..9378013f9 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -93,13 +93,13 @@ module Redmine
end
end
- def save_attachmentsex(attachments, author=User.current,attachment_type)
+ def save_attachmentsex(attachments, author=User.current,attachment_type, public_status)
@curattachment_type = attachment_type
- result = save_attachments(attachments,author)
+ result = save_attachments(attachments,author, public_status)
result
end
- def save_attachments(attachments, author=User.current)
+ def save_attachments(attachments, author=User.current,public_status)
# 清除临时文件
if attachments
tempAttach = attachments[:dummy]
@@ -140,11 +140,16 @@ module Redmine
end
end
end
- if a && !attachment['is_public_checkbox']
+ if public_status
+ if a && !attachment['is_public_checkbox']
+ a.is_public = false
+ elsif a && attachment['is_public_checkbox']
+ a.is_public = true
+ end
+ else
a.is_public = false
- elsif a && attachment['is_public_checkbox']
- a.is_public = true
end
+
set_attachment_public(a) if a
next unless a
a.description = attachment['description'].to_s.strip