Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
d827b3e519
|
@ -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
|
||||
|
@ -255,11 +255,28 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework_detail_manual.update_column('evaluation_end', Date.today)
|
||||
#计算缺评扣分
|
||||
work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")"
|
||||
@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
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 匿评关闭消息邮件通知
|
||||
send_message_anonymous_comment(@homework, m_status = 3)
|
||||
Mailer.send_mail_anonymous_comment_close(@homework).deliver
|
||||
|
|
|
@ -2280,6 +2280,8 @@ module ApplicationHelper
|
|||
candown = true
|
||||
elsif attachment.container.class.to_s=="Memo" #论坛资源允许下载
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s=="Syllabus" #论坛资源允许下载
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s == "User"
|
||||
candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id)
|
||||
elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses
|
||||
|
@ -2829,7 +2831,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 => "匿评已结束"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品
|
||||
class StudentWork < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time
|
||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty
|
||||
|
||||
belongs_to :homework_common
|
||||
belongs_to :user
|
||||
|
|
|
@ -52,15 +52,15 @@
|
|||
<% unless score.nil?%>
|
||||
<div class="g_infoNi none width180">
|
||||
作品最终评分为
|
||||
<span class="c_red"> <%= student_work.final_score%> </span>分。
|
||||
<span class="c_red"> <%= student_work.final_score%> </span>分。<br/>
|
||||
迟交扣分
|
||||
<span class="c_red">
|
||||
<%= student_work.homework_common && student_work.homework_common.teacher_priority == 1 && student_work.teacher_score ? 0 : student_work.late_penalty %>
|
||||
</span>分,
|
||||
</span>分,<br/>
|
||||
缺评扣分
|
||||
<span class="c_red">
|
||||
<%= student_work.homework_common && student_work.homework_common.teacher_priority == 1 && student_work.teacher_score ? 0 : student_work.absence_penalty%>
|
||||
</span>分,
|
||||
</span>分,<br/>
|
||||
最终成绩为
|
||||
<span class="c_red"> <%= format("%.1f",score<0 ? 0 : score)%> </span>分。
|
||||
</div>
|
||||
|
|
|
@ -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)
|
||||
|
@ -77,10 +77,26 @@ namespace :homework_evaluation do
|
|||
if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 2 #开启匿评状态才可关闭匿评
|
||||
#计算缺评扣分
|
||||
work_ids = "(" + homework_common.student_works.has_committed.map(&:id).join(",") + ")"
|
||||
homework_common.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
|
||||
if homework_common.homework_type != 3
|
||||
homework_common.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_common.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
|
||||
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_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)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
homework_detail_manual.update_column('comment_status', 3)
|
||||
# 匿评关闭消息通知 给所有人发
|
||||
|
|
Loading…
Reference in New Issue