diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 811b19ad6..4982a4b6b 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -444,14 +444,15 @@ class HomeworkAttachController < ApplicationController homework = @homework is_teacher = @is_teacher ? 1 : 0 #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0)) - if @m_score + @is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言 + if @m_score && (@is_teacher || @is_anonymous_comments) rate = @homework.rates(:quality).where(:rater_id => User.current.id, :is_teacher_score => is_teacher).first if rate rate.stars = @m_score - rate.save! else - @homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher).save! + rate = @homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher) end + rate.save! if homework.is_teacher_score == 0 if is_teacher == 1 @@ -469,14 +470,26 @@ class HomeworkAttachController < ApplicationController end end homework.save! - end + end #保存评论 - @is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言 - if params[:new_form] && params[:new_form][:user_message] #有没有留言 - @homework.addjours(User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation) if @is_teacher - else - @homework.addjours User.current.id, "",0,@is_comprehensive_evaluation if @is_teacher + if params[:new_form] && params[:new_form][:user_message] #有没有留言 + jour = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{User.current.id}").order("created_on DESC").first + if params[:new_form][:user_message] == "" + if @is_teacher + unless jour + jour = @homework.addjours User.current.id, "",0,@is_comprehensive_evaluation + end + end + else + jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation + end + end + + if jour + jour.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(jour) + jour.save end @teacher_stars = @stars_reates.where("is_teacher_score = 1") #老师评分列表 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 0a6944e3b..239a15881 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -52,7 +52,7 @@ class JournalsForMessage < ActiveRecord::Base :permission => :view_course_journals_for_messages, :timestamp => "#{self.table_name}.updated_on", :find_options => {:include => :course } - + acts_as_attachable has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/views/attachments/_homework_jour_link.html.erb b/app/views/attachments/_homework_jour_link.html.erb new file mode 100644 index 000000000..a83640f1f --- /dev/null +++ b/app/views/attachments/_homework_jour_link.html.erb @@ -0,0 +1,17 @@ +
+ <% for attachment in attachments %> +
+ <%= link_to_short_attachment attachment, :class => 'link_file', :download => true, :length => 100 -%> +
+ <% if attachment.is_text? %> +
+ <%= link_to image_tag('magnifier.png'), + {:controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename}, + :target => "_blank"%> +
+ <% end %> + <% end %> +
diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index c0ae219a5..f11d9d3af 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -57,7 +57,6 @@
<%= render :partial => 'homework_attach/homeworks_list', :locals => {:homeworks => @homework_list, - :homework_count => @obj_count, :remote => false, :not_batch_homework => @not_batch_homework,:is_student_batch_homework => @is_student_batch_homework}%>
diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 861ad10d3..824ddd8ce 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -52,6 +52,16 @@ :style => "resize: none;", :class => 'noline', :placeholder => l(:text_caracters_maximum,:count=>250), :maxlength => 250 %> <%= f.text_field :reference_user_id, :style=>"display:none"%> +
+ <% if @is_anonymous_comments || @is_teacher %> + + 文件: + +
+ <%= render :partial => 'attachments/form' %> +
+
+ <% end %>
<%= l(:label_confirmation) %> diff --git a/app/views/homework_attach/_homeworks_list.html.erb b/app/views/homework_attach/_homeworks_list.html.erb index c235133a1..24ea2190c 100644 --- a/app/views/homework_attach/_homeworks_list.html.erb +++ b/app/views/homework_attach/_homeworks_list.html.erb @@ -9,7 +9,7 @@ <%= l(:label_homework_list)%> ( - <%= homework_count%> + <%= homeworks.count%> ) <% url= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id) if is_batch_homeworks diff --git a/app/views/homework_attach/_jour.html.erb b/app/views/homework_attach/_jour.html.erb index 0544baea3..2f550087d 100644 --- a/app/views/homework_attach/_jour.html.erb +++ b/app/views/homework_attach/_jour.html.erb @@ -13,7 +13,7 @@ <%= format_time(jour.created_on) %>
-

<%= textilizable jour.notes%>

+ <%= textilizable jour.notes%>
<% ids = 'project_respond_form_'+ jour.id.to_s%> diff --git a/app/views/homework_attach/_review.html.erb b/app/views/homework_attach/_review.html.erb index 4849dab76..9c7d9d82c 100644 --- a/app/views/homework_attach/_review.html.erb +++ b/app/views/homework_attach/_review.html.erb @@ -39,7 +39,15 @@ <% notes = textilizable(jour.nil? ? "" : jour.notes)%> <%= notes.empty? ? "

".html_safe : notes%>
+
<% unless jour.nil? %> + <% unless jour.attachments.empty?%> + <% options = {:author => true, :deletable => attach_delete(jour)} %> + <%= render :partial => 'attachments/homework_jour_link', + :locals => {:attachments => jour.attachments, :options => options} %> + <% end %> +
+ <% ids = 'project_respond_form_'+ jour.id.to_s%>
diff --git a/app/views/homework_attach/addjours.js.erb b/app/views/homework_attach/addjours.js.erb index 29cd82d9c..3720623ad 100644 --- a/app/views/homework_attach/addjours.js.erb +++ b/app/views/homework_attach/addjours.js.erb @@ -3,11 +3,13 @@ HoverLi(4); $('#jour_count_4').html('<%= @teacher_stars.count %>'); $('#tbc_04').html('<%= escape_javascript(render(:partial => 'homework_attach/review',:locals => {:review_list => @teacher_stars,:show_name => true,:show_jour => true})) %>'); + $("#homework_attach_jour_attachment").html('<%= escape_javascript(render :partial => 'attachments/form') %>'); //匿评 <% elsif @is_anonymous_comments %> HoverLi(5); $('#jour_count_5').html('<%= @student_stars.count %>'); $('#tbc_05').html('<%= escape_javascript(render(:partial => 'homework_attach/review',:locals => {:review_list => @student_stars,:show_name => false || @is_teacher, :show_jour => false})) %>'); + $("#homework_attach_jour_attachment").html('<%= escape_javascript(render :partial => 'attachments/form') %>'); //留言 <% else %> HoverLi(3); diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 3de539ab0..9e42df961 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -18,6 +18,7 @@ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= heads_for_theme %> + <%= javascript_include_tag "attachments" %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d00ad37e7..bf35566ea 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -10,6 +10,7 @@ h4 {border-bottom: 1px dotted #bbb;} /*上传图片处理*/ .upload_img img{max-width: 100%;} +.link_file{ background:url(../images/pic_file.png) 0 0px no-repeat !important; padding-left:20px !important; color:#64bdd9 !important; } /****翻页***/ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 1e4b4fedf..d93bc8519 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -246,7 +246,7 @@ a:hover.tijiao{ background:#0f99a9;} /* 创建作品 homework */ .hwork_new{ color:#4c4c4c;} .c_red{ color:#F00;} -.hwork_input{ border:1px solid #64bdd9; height:22px; width:555px; background:#fff; margin-bottom:10px; padding:5px;} +.hwork_input{ border:1px solid #64bdd9; height:22px; width:88%; background:#fff; margin-bottom:10px; padding:5px;} .hwork_input02{ border:1px solid #64bdd9; height:15px; width:140px; background:#fff; margin-bottom:10px; padding:5px;} .hwork_text{ border:1px solid #64bdd9; height:100px;width:555px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} .hwork_new ul li{ }