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 @@