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/controllers/news_controller.rb b/app/controllers/news_controller.rb index d41491349..f71a77ca7 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -152,6 +152,9 @@ class NewsController < ApplicationController end def edit + if @course + render :layout => "base_courses" + end end def update 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/_form.html.erb b/app/views/attachments/_form.html.erb index 7e86b098b..2e8800617 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -18,7 +18,7 @@ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <% end %> - <% container.saved_attachments.each_with_index do |attachment, i| %> + <% container.saved_attachments.each_with_index do |attachment, i| %> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %> <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> @@ -37,14 +37,6 @@ <% end %> <% end %> - <% project = project %> <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> 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.html.erb b/app/views/bids/_homework.html.erb index a7a703c05..0cb1ff7cc 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -1,16 +1,5 @@ <%= render_flash_messages %>