@ -190,11 +190,11 @@ class HomeworkCommonController < ApplicationController
#开启匿评
#开启匿评
#statue 1:启动成功, 2: 启动失败, 作业总数大于等于2份时才能启动匿评, 3:已开启匿评,请务重复开启,4:没有开启匿评的权限
#statue 1:启动成功, 2: 启动失败, 作业总数大于等于2份时才能启动匿评, 3:已开启匿评,请务重复开启,4:没有开启匿评的权限
def start_anonymous_comment
def start_anonymous_comment
@statue = 4 and return unless User . current . admin? || User . current . allowed_to? ( :as_teacher , @course )
@statue = 4 and return unless User . current . admin? || User . current . allowed_to? ( :as_teacher , @course )
@statue = 5 and return if Time . parse ( @homework . end_time . to_s ) . strftime ( " %Y-%m-%d " ) > = Time . now . strftime ( " %Y-%m-%d " )
@statue = 5 and return if Time . parse ( @homework . end_time . to_s ) . strftime ( " %Y-%m-%d " ) > = Time . now . strftime ( " %Y-%m-%d " )
if @homework_detail_manual . comment_status == 1
if @homework_detail_manual . comment_status == 1
student_works = @homework . student_works
student_works = @homework . student_works
if student_works && student_works . size > = 2
if student_works && student_works . size > = 2
student_works . each_with_index do | work , index |
student_works . each_with_index do | work , index |
user = work . user
user = work . user
n = @homework_detail_manual . evaluation_num
n = @homework_detail_manual . evaluation_num
@ -218,11 +218,11 @@ class HomeworkCommonController < ApplicationController
#关闭匿评
#关闭匿评
def stop_anonymous_comment
def stop_anonymous_comment
@homework_detail_manual . update_column ( 'comment_status' , 3 )
@homework_detail_manual . update_column ( 'comment_status' , 3 )
#计算缺评扣分---->计算缺评数量
work_ids = " ( " + @homework . student_works . map ( & :id ) . join ( " , " ) + " ) "
work_ids = " ( " + @homework . student_works . map ( & :id ) . join ( " , " ) + " ) "
@homework . student_works . each do | student_work |
@homework . student_works . each do | student_work |
absence_penalty_count = student_work . user . student_works_evaluation_distributions . where ( " student_work_id IN #{ work_ids } " ) . count - student_work . user . student_works_scores . where ( " student_work_id IN #{ work_ids } " ) . count
absence_penalty_count = student_work . user . student_works_evaluation_distributions . where ( " student_work_id IN #{ work_ids } " ) . count - student_work . user . student_works_scores . where ( " student_work_id IN #{ work_ids } " ) . count
student_work . absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual . absence_penalty : 0
student_work . absence_penalty = absence_penalty_count > 0 ? absence_penalty_count : 0
student_work . save
student_work . save
end
end