From 803847585e22d83493d85e6cea36b844967cee72 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Dec 2014 15:40:12 +0800 Subject: [PATCH 1/7] =?UTF-8?q?#1661=20=E5=AD=A6=E7=94=9F=E3=80=81?= =?UTF-8?q?=E8=80=81=E5=B8=88=E6=89=93=E5=88=86=E7=95=8C=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AF=84=E8=AE=BA->=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/_addjour.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 79a7711c7..8949e1ac1 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -91,7 +91,7 @@ <%= f.text_field :reference_user_id, :style=>"display:none"%>
<% else %> From 4bbc76a2179ac59fb18075f14bd4eea818b3d163 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Dec 2014 18:01:53 +0800 Subject: [PATCH 2/7] =?UTF-8?q?1.=E9=87=8D=E5=86=99homework=5Fattach?= =?UTF-8?q?=E7=9A=84show=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=A1=86=E7=9A=84=E5=BC=B9=E5=87=BA=E6=95=88?= =?UTF-8?q?=E7=8E=87=202.=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3=E7=9A=84view?= =?UTF-8?q?=E5=B1=82=E4=BB=A3=E7=A0=81=203.=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8C=87=E5=AE=9A=E8=AF=84=E5=88=86=E7=9A=84=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 114 ++++++++++-------- app/helpers/homework_attach_helper.rb | 5 + app/views/homework_attach/_addjour.html.erb | 51 +------- .../homework_attach/_histoey_new.html.erb | 39 ++++-- app/views/homework_attach/_jour.html.erb | 102 +++++++--------- app/views/homework_attach/_review.html.erb | 61 ++++++++++ app/views/homework_attach/_show.html.erb | 8 +- 7 files changed, 212 insertions(+), 168 deletions(-) create mode 100644 app/views/homework_attach/_review.html.erb diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index d07ee9448..18d6a16ac 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -284,11 +284,6 @@ class HomeworkAttachController < ApplicationController end end - #获取指定作业的所有成员 - def users_for_homework homework - homework.nil? ? [] : (homework.users + [homework.user]) - end - #获取可选成员列表 #homework:作业 #users:该作业所有成员 @@ -359,53 +354,69 @@ class HomeworkAttachController < ApplicationController #显示作业信息 def show - if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) - # 打分统计 - #stars_reates = @homework. rates(:quality) - #是否已经进行过评价 - temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{@homework.id} AND rater_id = #{User.current.id}").first - @m_score = temp.nil? ? 0:temp.stars - @has_evaluation = @homework.has_rated?( User.current,:quality) - #@jours留言 is null条件用以兼容历史数据 - @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") + if User.current.admin? || User.current.member_of_course?(@course) + # 作业打分列表 + @stars_reates = @homework.rates(:quality) + #我的评分 + @has_evaluation = @stars_reates.where("rater_id = #{User.current.id}").first + @m_score = @has_evaluation.nil? ? 0 : @has_evaluation.stars + teachers = find_course_teachers(@course) + @teacher_stars = @stars_reates.where("rater_id in (#{teachers})") #老师评分列表 + @student_stars = @stars_reates.where("rater_id not in (#{teachers})") #学生评分列表 + @is_teacher = is_course_teacher User.current,@course + @is_anonymous_comments = @bid.comment_status == 1 && !@homework.users.include?(User.current) && @homework.user != User.current && !@is_teacher #判断是不是匿评(开启匿评,当前用户不是作业的创建者或者参与者,不是老师) + jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据 + @jour = paginateHelper jours,5 #留言 @cur_page = params[:cur_page] || 1 @cur_type = params[:cur_type] || 5 - @jour = paginateHelper @jours,5 - teachers = searchTeacherAndAssistant @course - @comprehensive_evaluation = [] - #JourForMessage的is_comprehensive_evaluation字段: - #1:老师评价 - #2:学生评价 - #3 || null:学生留言 - 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 - annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') - unless annymous_users.nil? || annymous_users == "" - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") - end - #@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 = @homework.bid.comment_status == 1 #是否开启了匿评 - #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 - if User.current.member_of_course?(@homework.bid.courses.first) - if @is_teacher - @is_comprehensive_evaluation = 1 #教师评论 - else - if @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 - @is_comprehensive_evaluation = 2 #匿评 - else #是学生未开启匿评或者已经进行评分 - @is_comprehensive_evaluation = 3 #留言 - end - end - else - @is_comprehensive_evaluation = 3 - end + #if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) + # # 打分统计 + # #stars_reates = @homework. rates(:quality) + # #是否已经进行过评价 + # temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{@homework.id} AND rater_id = #{User.current.id}").first + # @m_score = temp.nil? ? 0:temp.stars + # @has_evaluation = @homework.has_rated?( User.current,:quality) + # #@jours留言 is null条件用以兼容历史数据 + # @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") + # @cur_page = params[:cur_page] || 1 + # @cur_type = params[:cur_type] || 5 + # @jour = paginateHelper @jours,5 + # + # teachers = searchTeacherAndAssistant @course + # @comprehensive_evaluation = [] + # #JourForMessage的is_comprehensive_evaluation字段: + # #1:老师评价 + # #2:学生评价 + # #3 || null:学生留言 + # 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 + # annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + # unless annymous_users.nil? || annymous_users == "" + # @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") + # end + # #@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 = @homework.bid.comment_status == 1 #是否开启了匿评 + # #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 + # if User.current.member_of_course?(@homework.bid.courses.first) + # if @is_teacher + # @is_comprehensive_evaluation = 1 #教师评论 + # else + # if @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + # @is_comprehensive_evaluation = 2 #匿评 + # else #是学生未开启匿评或者已经进行评分 + # @is_comprehensive_evaluation = 3 #留言 + # end + # end + # else + # @is_comprehensive_evaluation = 3 + # end respond_to do |format| format.html @@ -622,5 +633,10 @@ class HomeworkAttachController < ApplicationController WHERE table1.t_score IS NULL") @homework_list = paginateHelper all_homework_list,10 end + + #获取指定作业的所有成员 + def users_for_homework homework + homework.nil? ? [] : (homework.users + [homework.user]) + end end diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 1ab1cb928..4744df624 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -91,6 +91,11 @@ module HomeworkAttachHelper @m_score = temp.nil? ? 0:temp.stars.to_i end + #获取评分对应的评论 + def get_homework_review homework,is_teacher,user + homework.journals_for_messages.where("is_comprehensive_evaluation = #{is_teacher ? 1 : 2} and user_id = #{user.id}").order("created_on DESC").first + end + def convert_array array ary = "(" if array.nil? || array.count == 0 diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 8949e1ac1..bb5b21f5f 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -1,35 +1,4 @@