From 2628ab48082e1ad618d3ddc9e7dbe2762d0ef79b Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 3 Nov 2014 11:01:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=84=E5=88=86=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 18 ++++++++++++++---- app/helpers/homework_attach_helper.rb | 15 +++++++++++++++ app/views/homework_attach/_show.html.erb | 12 ++++++------ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 390c4620b..a2c2ce5bc 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -1,7 +1,7 @@ class HomeworkAttachController < ApplicationController layout "course_base" include CoursesHelper - + include HomeworkAttachHelper helper :words ############################### before_filter :can_show_course,except: [] @@ -373,10 +373,20 @@ class HomeworkAttachController < ApplicationController @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] #@comprehensive_evaluation教师评论 - @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1").order("created_on DESC") + #@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1").order("created_on DESC") + teachers = searchTeacherAndAssistant @course + @comprehensive_evaluation = [] + teachers.each do|teacher| + temp = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first + @comprehensive_evaluation << temp if temp + end + #@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id in #{convert_array(teachers)}").order("created_on DESC") #@anonymous_comments 匿评 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2").order("created_on DESC") - + #@anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2").order("created_on DESC") + annymous_users = @homework.homework_evaluations.map(&:user) + unless annymous_users.nil? || annymous_users.count == 0 + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + end @totle_score = score_for_homework @homework @teaher_score = teacher_score_for_homework @homework diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 8ba02136e..ec66a42d9 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -90,4 +90,19 @@ module HomeworkAttachHelper 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 + + def convert_array array + ary = "(" + if array.nil? || array.count == 0 + return "()" + end + array.each do |member| + if member == array.last + ary += member.to_s + ")" + else + ary += member.to_s + "," + end + end + ary + end 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 22b33fbec..3a17ecb88 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -79,11 +79,11 @@
@@ -95,12 +95,12 @@
- <% if @comprehensive_evaluation.count > 0 %> - <%= render :partial => 'homework_attach/jour',:locals => {:jour => @comprehensive_evaluation.first} %> + <% @comprehensive_evaluation.nil? || @comprehensive_evaluation.count == 0 || @comprehensive_evaluation.each do |jour| %> + <%= render :partial => 'homework_attach/jour',:locals => {:jour => jour} %> <% end %>
- <%= @anonymous_comments.each do |jour| %> + <%= @anonymous_comments.nil? || @anonymous_comments.each do |jour| %> <%= render :partial => 'homework_attach/jour',:locals => {:jour => jour} %> <% end %>