diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 21dcdcd0f..390c4620b 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -366,16 +366,35 @@ class HomeworkAttachController < ApplicationController #是否开启互评功能 @is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil @limit = 10 - @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") + #@jours留言 is null条件用以兼容历史数据 + @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] - @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") + #@comprehensive_evaluation教师评论 + @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1").order("created_on DESC") + #@anonymous_comments 匿评 + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2").order("created_on DESC") @totle_score = score_for_homework @homework @teaher_score = teacher_score_for_homework @homework + is_student = is_cur_course_student @homework.bid.courses.first + is_teacher = is_course_teacher User.current,@homework.bid.courses.first + is_anonymous_comments = true #是否开启了匿评 + if !User.current.member_of_course?(@homework.bid.courses.first) + @is_comprehensive_evaluation = 3 #留言 + elsif is_student && is_anonymous_comments #是学生且开启了匿评 + @is_comprehensive_evaluation = 2 #匿评 + elsif is_student && !is_anonymous_comments #是学生未开启匿评 + @is_comprehensive_evaluation = 3 #留言 + elsif is_teacher + @is_comprehensive_evaluation = 1 #教师评论 + else + @is_comprehensive_evaluation = 3 + end + respond_to do |format| format.html format.js diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index c3bd240a3..8ba02136e 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -84,4 +84,10 @@ module HomeworkAttachHelper def praise_homework_count obj_id PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").count end + + #获取用户对作业的评分 + def get_homework_score user, homework + seems_rateable_rate = HomeworkAttach.find_by_sql("SELECT * FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id} AND rater_id = #{user.id}") + seems_rateable_rate.nil? || seems_rateable_rate.count == 0 ? 0:seems_rateable_rate[0].stars + end end \ No newline at end of file diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 20e0c15f4..4819cd253 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -14,6 +14,7 @@ class JournalsForMessage < ActiveRecord::Base "is_readed", # 留言是否已读 "m_reply_count", # 留言的回复数量 "m_reply_id" # 回复某留言的留言id(a留言回复了b留言,这是b留言的id) + "is_comprehensive_evaluation" # 1 教师评论、2 匿评、3 留言 acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC" belongs_to :project, diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index fae799a93..2519f6a15 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -63,27 +63,19 @@ <% if User.current.logged? %> - - - - -
<%= f.text_area 'user_message', :rows => 3, :cols => 65, :value => "#{l(:label_leave_a_message)}", - :onfocus => "clearInfo('new_form_user_message','#{l(:label_leave_a_message)}')", - :onblur => "showInfo('new_form_user_message','#{l(:label_leave_a_message)}')", - :style => "resize: none;", :class => 'noline'%>
+ <%= f.text_area 'user_message', :rows => 3, :cols => 65, + :style => "resize: none;", :class => 'noline', :placeholder => l(:text_caracters_maximum,:count=>250)%> <%= f.text_field :reference_user_id, :style=>"display:none"%> - - - - -
<%= submit_tag l(:button_leave_meassge), +
+ <%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear_meassge), :name => nil, :class => "enterprise", + <%= submit_tag l(:button_clear_meassge), :name => nil, :class => "enterprise", :onclick => "clearMessage('new_form_user_message');", :onmouseout => "this.style.backgroundPosition = 'left top'", - :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
+ :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> + <% else %>
<%= l(:label_user_login_tips) %> diff --git a/app/views/homework_attach/_history.erb b/app/views/homework_attach/_history.erb index 6897ef6b5..299ba1aa5 100644 --- a/app/views/homework_attach/_history.erb +++ b/app/views/homework_attach/_history.erb @@ -19,7 +19,7 @@
- <%= link_to journal.user, user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%>2014-10-24 + <%= link_to journal.user, user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%><%= journal.created_on %>

<%= textilizable journal.notes%>

diff --git a/app/views/homework_attach/_jour.html.erb b/app/views/homework_attach/_jour.html.erb new file mode 100644 index 000000000..06800084c --- /dev/null +++ b/app/views/homework_attach/_jour.html.erb @@ -0,0 +1,28 @@ +
+ +
+
+ <%= link_to jour.user, user_path(jour.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%> + <%= jour.created_on %> + <%= l(:label_work_rating) %>: + <%= render :partial => 'show_score', locals: {:stars => get_homework_score(jour.user,@homework ) } %> + +
+

<%= textilizable jour.notes%>

+
+
+ <% ids = 'project_respond_form_'+ jour.id.to_s%> + + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{jour.user.name}: '); $('##{ids} textarea') ;return false;"} + %> + <% if jour.user==User.current|| User.current.admin? %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy_jour', :object_id => jour, :user_id => jour.user}, + :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> + <% end %> + +
+ +
+
+
\ No newline at end of file diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index c432d4f3f..22b33fbec 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -1,9 +1,11 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> +