分组作业的缺评扣分

This commit is contained in:
cxt 2016-11-07 14:06:11 +08:00
parent e8d9cd4098
commit f8316ee1ee
3 changed files with 31 additions and 13 deletions

View File

@ -270,13 +270,13 @@ class HomeworkCommonController < ApplicationController
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.save
if student_work.absence_penalty != 0
pros = student_work.student_work_projects.where("is_leader = 0")
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
student_works = @homework.student_works.where("user_id in #{user_ids}")
student_works.each do |st_work|
st_work.update_attribute("absence_penalty", student_work.absence_penalty)
end
pros = student_work.student_work_projects.where("is_leader = 0")
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
student_works = @homework.student_works.where("user_id in #{user_ids}")
student_works.each do |st_work|
absence_penalty_count = st_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - st_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
st_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
st_work.save
end
end
end

View File

@ -985,11 +985,27 @@ class StudentWorkController < ApplicationController
if params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s
homework_detail_manual.absence_penalty = params[:absence_penalty]
if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
@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} and reviewer_role = 3").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")"
if @homework.homework_type != 3
@homework.student_works.has_committed.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
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
end
else
@homework.student_works.has_committed.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
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
pros = student_work.student_work_projects.where("is_leader = 0")
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
student_works = @homework.student_works.where("user_id in #{user_ids}")
student_works.each do |st_work|
absence_penalty_count = st_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - st_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
st_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
st_work.save
end
end
end
end

View File

@ -98,7 +98,9 @@ namespace :homework_evaluation do
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
student_works = homework_common.student_works.where("user_id in #{user_ids}")
student_works.each do |st_work|
st_work.update_attribute("absence_penalty", student_work.absence_penalty)
absence_penalty_count = st_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - st_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
st_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
st_work.save
end
end
end