实训作业算分调整

dev_forum
cxt 5 years ago
parent a8dc1afcad
commit 0aa403ff75

@ -238,7 +238,7 @@ class HomeworkCommonsController < ApplicationController
end end
def update_score def update_score
tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now tip_exception("作业还未发布,暂不能计算成绩") if @homework.end_or_late_none_group
begin begin
if @homework.unified_setting if @homework.unified_setting
student_works = @homework.student_works student_works = @homework.student_works
@ -258,6 +258,8 @@ class HomeworkCommonsController < ApplicationController
HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings
end end
end end
HomeworksService.new.update_student_eff_score @homework if (@homework.allow_late && @homework.late_time < Time.now) ||
(!@homework.allow_late && @homework.end_time < Time.now)
@homework.update_attribute('calculation_time', Time.now) @homework.update_attribute('calculation_time', Time.now)
normal_status("更新成功") normal_status("更新成功")
rescue Exception => e rescue Exception => e
@ -606,14 +608,14 @@ class HomeworkCommonsController < ApplicationController
@homework.score_open = params[:score_open] @homework.score_open = params[:score_open]
@homework.save! @homework.save!
if score_change # if score_change
@homework.student_works.has_committed.each do |student_work| # @homework.student_works.has_committed.each do |student_work|
HomeworksService.new.set_shixun_final_score student_work # HomeworksService.new.set_shixun_final_score student_work
end # end
end # end
# 更新所有学生的效率分(作业允许补交且补交已截止 或者 作业不允许补交且提交已截止) # 更新所有学生的效率分(作业允许补交且补交已截止 或者 作业不允许补交且提交已截止)
if (score_change || update_eff_score) && @homework.end_or_late if update_eff_score && @homework.end_or_late_none_group
HomeworksService.new.update_student_eff_score HomeworkCommon.find_by(id: @homework.id) HomeworksService.new.update_student_eff_score HomeworkCommon.find_by(id: @homework.id)
end end
@ -1017,8 +1019,8 @@ class HomeworkCommonsController < ApplicationController
homework.save! homework.save!
# 更新学生状态及成绩 # 更新学生状态及成绩(手动点击计算)
HomeworkPublishUpdateWorkStatusJob.perform_later(tiding_group_ids, homework.id) # HomeworkPublishUpdateWorkStatusJob.perform_later(tiding_group_ids, homework.id)
end end
normal_status(0, "发布成功") normal_status(0, "发布成功")
rescue Exception => e rescue Exception => e

@ -167,7 +167,7 @@ class MyshixunsController < ApplicationController
end end
# 更新实训关联的作品分数 TODO: 更新作品分数 # 更新实训关联的作品分数 TODO: 更新作品分数
HomeworksService.new.update_myshixun_work_score myshixun # HomeworksService.new.update_myshixun_work_score myshixun
end end
# 如果过关了下一关的状态是3为开启则需要把状态改成1已开启 # 如果过关了下一关的状态是3为开启则需要把状态改成1已开启
# next_game = game.next_game # next_game = game.next_game

@ -118,6 +118,11 @@ class HomeworkCommon < ApplicationRecord
status status
end end
# 作业是否补交截止或者不允许补交且提交截止(不考虑分班)
def end_or_late_none_group
course.is_end || (allow_late && late_time < Time.now) || (!allow_late && end_time < Time.now)
end
# 作业是否可以查重 # 作业是否可以查重
def code_review def code_review
self.homework_type == 'practice' && self.publish_time.present? && self.publish_time < Time.now && self.homework_group_reviews.count == 0 self.homework_type == 'practice' && self.publish_time.present? && self.publish_time < Time.now && self.homework_group_reviews.count == 0

@ -156,7 +156,7 @@ class HomeworksService
end end
# 用户评测时更新实训作业成绩 # 用户评测时更新实训作业成绩
def update_myshixun_work_score myshixun def update_myshixun_work_score_old myshixun
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
student_works = myshixun.student_works.where(user_id: myshixun.user_id) student_works = myshixun.student_works.where(user_id: myshixun.user_id)
#logger.info("#############student_works_count: #{student_works.count}") #logger.info("#############student_works_count: #{student_works.count}")

@ -23,7 +23,7 @@ namespace :homework_publishtime do
homework_detail_manual.update_column('comment_status', 1) homework_detail_manual.update_column('comment_status', 1)
# 统一设置的作业在这发消息,非统一设置的只给有全部分班权限的老师发 # 统一设置的作业在这发消息,非统一设置的只给有全部分班权限的老师发
if homework.unified_setting if homework.unified_setting
HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id) # HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, nil) HomeworkCommonPushNotifyJob.perform_later(homework.id, nil)
else else
course = homework.course course = homework.course
@ -53,7 +53,7 @@ namespace :homework_publishtime do
homework_group_settings.each do |homework_group| homework_group_settings.each do |homework_group|
homework = homework_group.homework_common homework = homework_group.homework_common
if homework.present? if homework.present?
HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) # HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.course_group_id]) HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.course_group_id])
end end
end end

Loading…
Cancel
Save