学生追加附件发送消息

This commit is contained in:
cxt 2016-05-12 10:29:43 +08:00
parent 9ec488684b
commit f4b8f2c794
3 changed files with 25 additions and 1 deletions

View File

@ -866,6 +866,10 @@ class StudentWorkController < ApplicationController
end
attachment = @work.attachments.where("attachtype = 7").first
attachment.update_attributes(:description => params[:description])
if attachment.attachtype == 7
student_work = StudentWork.find attachment.container_id
CourseMessage.create(:user_id => student_work.homework_common.user_id, :course_id => student_work.homework_common.course_id, :viewed => false,:course_message_id=>attachment.container_id,:course_message_type=>'StudentWork',:status=>2)
end
respond_to do |format|
format.js
end

View File

@ -301,7 +301,7 @@ class Attachment < ActiveRecord::Base
nil
end
def filename=(arg)
def filename=(arg)
write_attribute :filename, sanitize_filename(arg.to_s)
filename
end

View File

@ -497,6 +497,26 @@
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!-- 学生追加作品附件 -->
<% if ma.course_message_type == "StudentWork" && ma.status == 2 %>
<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="homepageNewsPubType fl">
<%= link_to ma.course_message.user.show_name+ "同学",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">追加新附件了:</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业标题:" + ma.course_message.homework_common.name, student_work_index_path(:homework => ma.course_message.homework_common_id, :show_work_id => ma.course_message_id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!-- 创建课程消息 -->
<% if ma.course_message_type == "Course" %>
<ul class="homepageNewsList fl">