分组作业的匿评分配

This commit is contained in:
cxt 2016-10-09 09:48:55 +08:00
parent f0e334d33d
commit b123192286
3 changed files with 39 additions and 39 deletions

View File

@ -202,24 +202,24 @@ class HomeworkCommonController < ApplicationController
if @homework_detail_manual.comment_status == 1
student_works = @homework.student_works.has_committed
if student_works && student_works.size >= 2
if @homework.homework_type == 3
student_work_projects = @homework.student_work_projects.where("student_work_id is not null")
student_work_projects.each_with_index do |pro_work, pro_index|
n = @homework_detail_manual.evaluation_num
n = n < student_works.size ? n : student_works.size - 1
work_index = -1
student_works.each_with_index do |stu_work, stu_index|
if stu_work.id.to_i == pro_work.student_work_id.to_i
work_index = stu_index
end
end
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
end
else
# if @homework.homework_type == 3
# student_work_projects = @homework.student_work_projects.where("student_work_id is not null")
# student_work_projects.each_with_index do |pro_work, pro_index|
# n = @homework_detail_manual.evaluation_num
# n = n < student_works.size ? n : student_works.size - 1
# work_index = -1
# student_works.each_with_index do |stu_work, stu_index|
# if stu_work.id.to_i == pro_work.student_work_id.to_i
# work_index = stu_index
# end
# end
# assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
# assigned_homeworks.each do |h|
# student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
# student_works_evaluation_distributions.save
# end
# end
# else
student_works.each_with_index do |work, index|
user = work.user
n = @homework_detail_manual.evaluation_num
@ -230,7 +230,7 @@ class HomeworkCommonController < ApplicationController
student_works_evaluation_distributions.save
end
end
end
#end
@homework_detail_manual.update_column('comment_status', 2)
@homework_detail_manual.update_column('evaluation_start', Date.today)
@statue = 1

View File

@ -2829,7 +2829,7 @@ module ApplicationHelper
link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
end
else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 #匿评作业,且作业状态不是在开启匿评之前
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 && work.user_id == User.current.id #匿评作业,且作业状态不是在开启匿评之前
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品"
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束"

View File

@ -14,24 +14,24 @@ namespace :homework_evaluation do
if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 1 #新建状态才可开启匿评
student_works = homework_common.student_works.has_committed
if student_works && student_works.size >= 2
if homework_common.homework_type == 3
student_work_projects = homework_common.student_work_projects.where("student_work_id is not null")
student_work_projects.each_with_index do |pro_work, pro_index|
n = homework_detail_manual.evaluation_num
n = n < student_works.size ? n : student_works.size - 1
work_index = -1
student_works.each_with_index do |stu_work, stu_index|
if stu_work.id.to_i == pro_work.student_work_id.to_i
work_index = stu_index
end
end
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
end
else
# if homework_common.homework_type == 3
# student_work_projects = homework_common.student_work_projects.where("student_work_id is not null")
# student_work_projects.each_with_index do |pro_work, pro_index|
# n = homework_detail_manual.evaluation_num
# n = n < student_works.size ? n : student_works.size - 1
# work_index = -1
# student_works.each_with_index do |stu_work, stu_index|
# if stu_work.id.to_i == pro_work.student_work_id.to_i
# work_index = stu_index
# end
# end
# assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
# assigned_homeworks.each do |h|
# student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
# student_works_evaluation_distributions.save
# end
# end
# else
student_works.each_with_index do |work, index|
user = work.user
n = homework_detail_manual.evaluation_num
@ -42,7 +42,7 @@ namespace :homework_evaluation do
student_works_evaluation_distributions.save
end
end
end
#end
homework_detail_manual.update_column('comment_status', 2)
# 匿评开启消息邮件通知,# 所有人
#send_message_anonymous_comment(homework_common, 2)