parent
0007b720b3
commit
1dce1a2a4c
|
@ -1,5 +1,5 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status
|
||||
|
||||
# 多态 虚拟关联
|
||||
belongs_to :course_message ,:polymorphic => true
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#encoding=UTF-8
|
||||
class StudentWorksScore < ActiveRecord::Base
|
||||
#reviewer_role: 1:教师评分;2:教辅评分;3:学生匿评
|
||||
attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role
|
||||
|
@ -9,13 +10,31 @@ class StudentWorksScore < ActiveRecord::Base
|
|||
|
||||
acts_as_attachable
|
||||
|
||||
after_create :act_as_course_message
|
||||
after_save :act_as_course_message
|
||||
|
||||
# 评阅作品消息提示
|
||||
def act_as_course_message
|
||||
if self.student_work
|
||||
if self.student_work && self.student_work.user && self.student_work.homework_common.course
|
||||
receiver = self.student_work.user
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false)
|
||||
# 判断是第一次评阅还是更新 status:0 新建;1 更新
|
||||
if self.created_at == self.updated_at
|
||||
if self.comment.nil?
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score}", :status=> false)
|
||||
else
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score} 评语:#{self.comment}", :status=> false)
|
||||
end
|
||||
else # 更新
|
||||
if self.comment.nil?
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score}", :status=> true)
|
||||
else
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score} 评语:#{self.comment}", :status=> true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %></a></li>
|
||||
<li class="homepageNewsPublisher fl"><%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue" %></li>
|
||||
<li class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复了通知</li>
|
||||
<li class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">评论了通知</li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= link_to ma.course_message.comments.html_safe, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id },
|
||||
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
|
||||
|
@ -106,17 +106,19 @@
|
|||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
|
||||
<li class="homepageNewsPublisher fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue" %></li>
|
||||
<li class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">评阅了作品</li>
|
||||
<li class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>"><%= ma.status == 0 ? "评阅了作品" : "重新评阅了作品" %></li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to "#{ma.course_message.comment.nil? ? "分数:"+ma.course_message.score.to_s : "分数:"+ma.course_message.score.to_s + "----" + "评语:" + ma.course_message.comment}", student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ma.course_message.comment}" %></a></li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_at).html_safe %> </li>
|
||||
<% unless ma.content.nil? %>
|
||||
<%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ma.content.html_safe}" %></a></li>
|
||||
<% end %>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.course_message_type == "JournalsForMessage" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
|
||||
<li class="homepageNewsPublisher fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue" %></li>
|
||||
<li class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复了作品</li>
|
||||
<li class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复了作品评论</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ma.course_message.notes}" %></a></li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_on).html_safe %> </li>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddContentToCourseMessage < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :course_messages, :content, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddStatusToCourseMessage < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :course_messages, :status, :integer
|
||||
end
|
||||
end
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150824133916) do
|
||||
ActiveRecord::Schema.define(:version => 20150826061843) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -374,6 +374,8 @@ ActiveRecord::Schema.define(:version => 20150824133916) do
|
|||
t.integer "viewed"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "content"
|
||||
t.integer "status"
|
||||
end
|
||||
|
||||
create_table "course_statuses", :force => true do |t|
|
||||
|
@ -572,16 +574,6 @@ ActiveRecord::Schema.define(:version => 20150824133916) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "forum_messages", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "forum_id"
|
||||
t.integer "memo_message_id"
|
||||
t.string "memo_message_type"
|
||||
t.integer "viewed"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.text "description"
|
||||
|
|
Loading…
Reference in New Issue