|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
class HomeworkCommonController < ApplicationController
|
|
|
|
|
layout "base_courses"
|
|
|
|
|
before_filter :find_course, :only => [:index,:new,:create]
|
|
|
|
|
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment]
|
|
|
|
|
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment]
|
|
|
|
|
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
@ -124,8 +124,30 @@ class HomeworkCommonController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#开启匿评
|
|
|
|
|
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
|
|
|
|
def start_anonymous_comment
|
|
|
|
|
|
|
|
|
|
@statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
|
|
|
|
|
if @homework_detail_manual.comment_status == 1
|
|
|
|
|
student_works = @homework.student_works
|
|
|
|
|
if student_works && student_works.size >=2
|
|
|
|
|
student_works.each_with_index do |work, index|
|
|
|
|
|
user = work.user
|
|
|
|
|
n = @homework_detail_manual.evaluation_num
|
|
|
|
|
n = n < student_works.size ? n : student_works.size - 1
|
|
|
|
|
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
|
|
|
|
|
assigned_homeworks.each do |h|
|
|
|
|
|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
|
|
|
|
student_works_evaluation_distributions.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@homework_detail_manual.update_column('comment_status', 2)
|
|
|
|
|
@statue = 1
|
|
|
|
|
else
|
|
|
|
|
@statue = 2
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@statue = 3
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#关闭匿评
|
|
|
|
@ -170,4 +192,9 @@ class HomeworkCommonController < ApplicationController
|
|
|
|
|
def teacher_of_course
|
|
|
|
|
render_403 unless User.current.allowed_to?(:as_teacher,@course)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_assigned_homeworks(student_works, n, index)
|
|
|
|
|
student_works += student_works
|
|
|
|
|
student_works[index + 1 .. index + n]
|
|
|
|
|
end
|
|
|
|
|
end
|