@ -403,10 +403,13 @@ class HomeworkAttachController < ApplicationController
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 )
@is_comprehensive_evaluation = 3 #留言
elsif is_student && @is_anonymous_comments #是学生且开启了匿评
elsif is_student && @is_anonymous_comments && ! @has_evaluation #是学生且开启了匿评 且未进行评分
@is_comprehensive_evaluation = 2 #匿评
elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分
@is_comprehensive_evaluation = 3 #留言
elsif is_student && ! @is_anonymous_comments #是学生未开启匿评
@is_comprehensive_evaluation = 3 #留言
elsif is_teacher
@ -458,14 +461,17 @@ class HomeworkAttachController < ApplicationController
#添加留言
def addjours
@homework = HomeworkAttach . find ( params [ :jour_id ] )
#保存评分
@homework . rate ( params [ :stars_value ] , User . current . id , :quality )
#保存评论
@add_jour = @homework . addjours User . current . id , params [ :new_form ] [ :user_message ] , 0 , params [ :is_comprehensive_evaluation ]
if @add_jour . is_comprehensive_evaluation == 3
@jours = @homework . journals_for_messages . where ( " is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null " ) . order ( " created_on DESC " )
@jour = paginateHelper @jours , 5
elsif @add_jour . is_comprehensive_evaluation == 2
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 " )
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
elsif @add_jour . is_comprehensive_evaluation == 1
teachers = searchTeacherAndAssistant @homework . bid . courses . first
@ -476,36 +482,23 @@ class HomeworkAttachController < ApplicationController
end
end
#@limit = 10
#@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")
@totle_score = score_for_homework @homework
@teaher_score = teacher_score_for_homework @homework
stars_reates = @homework . rates ( :quality )
is_student = is_cur_course_student @homework . bid . courses . first
is_teacher = is_course_teacher User . current , @homework . bid . courses . first
@has_evaluation = stars_reates . where ( " rater_id = ? " , User . current ) . count > 0
@is_anonymous_comments = @homework . bid . comment_status == 1 #是否开启了匿评
if ! User . current . member_of_course? ( @homework . bid . courses . first )
@is_comprehensive_evaluation = 3 #留言
elsif is_student && @is_anonymous_comments && ! @has_evaluation #是学生且开启了匿评且未进行评分
@is_comprehensive_evaluation = 2 #匿评
elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分
@is_comprehensive_evaluation = 3 #留言
elsif is_student && ! @is_anonymous_comments #是学生未开启匿评
@is_comprehensive_evaluation = 3 #留言
elsif is_teacher
@is_comprehensive_evaluation = 1 #教师评论
#@has_evaluation = @homework.has_rated?( User.current,:quality)
is_anonymous_comments = @homework . bid . comment_status == 1 #是否开启了匿评
if User . current . member_of_course? ( @homework . bid . courses . first )
if is_student && is_anonymous_comments && ! @has_evaluation #是学生且开启了匿评且未进行评分
@is_comprehensive_evaluation = 2 #匿评
elsif is_student && is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分
@is_comprehensive_evaluation = 3 #留言
elsif is_student && ! is_anonymous_comments #是学生未开启匿评
@is_comprehensive_evaluation = 3 #留言
else #是老师
@is_comprehensive_evaluation = 1 #教师评论
end
else
@is_comprehensive_evaluation = 3
end
respond_to do | format |
format . js
end