修改作业添加评论、删除评论、留言值设定逻辑混乱

This commit is contained in:
sw 2014-12-01 16:31:13 +08:00
parent 9a61354328
commit 21c4caa7a6
1 changed files with 24 additions and 27 deletions

View File

@ -400,20 +400,20 @@ class HomeworkAttachController < ApplicationController
#@totle_score = score_for_homework @homework
#@teaher_score = teacher_score_for_homework @homework
is_student = is_cur_course_student @homework.bid.courses.first
#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 && !@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
if User.current.member_of_course?(@homework.bid.courses.first)
if is_teacher
@is_comprehensive_evaluation = 1 #教师评论
else
if is_student && @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分
@is_comprehensive_evaluation = 2 #匿评
else #是学生未开启匿评或者已经进行评分
@is_comprehensive_evaluation = 3 #留言
end
end
else
@is_comprehensive_evaluation = 3
end
@ -438,9 +438,9 @@ class HomeworkAttachController < ApplicationController
@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 @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.count == ""
@anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC")
end
elsif @is_comprehensive_evaluation == 1
teachers = searchTeacherAndAssistant @course
@ -450,9 +450,6 @@ class HomeworkAttachController < ApplicationController
@comprehensive_evaluation << temp if temp
end
end
respond_to do |format|
format.js
end
@ -482,18 +479,18 @@ class HomeworkAttachController < ApplicationController
end
end
is_student = is_cur_course_student @homework.bid.courses.first
#@has_evaluation = @homework.has_rated?( User.current,:quality)
is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评
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_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 #是老师
if is_teacher
@is_comprehensive_evaluation = 1 #教师评论
else
if is_student && @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分
@is_comprehensive_evaluation = 2 #匿评
else #是学生未开启匿评或者已经进行评分
@is_comprehensive_evaluation = 3 #留言
end
end
else
@is_comprehensive_evaluation = 3