实训作业的重做

dev_cs
cxt 5 years ago
parent 4b1f4c7845
commit cad878c6da

@ -113,7 +113,7 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity == Course::STUDENT
@work = @homework.user_work(current_user.id)
# 学生访问列表时计算个人成绩
if @homework.homework_type == "practice"
if @homework.homework_type == "practice" && !@homework.end_or_late
myshixun = Myshixun.find_by(shixun_id: @shixun.id, user_id: current_user.id)
if @work && myshixun
challenge_settings = @homework.homework_challenge_settings

@ -237,4 +237,9 @@ module HomeworkCommonsHelper
def anon_comments user, work_id
StudentWorksScore.where(student_work_id: work_id, reviewer_role: 3, user_id: user.id)
end
def student_redo_work work, homework
publish_time = homework.homework_group_setting(work.user_id)&.publish_time
work.myshixun && publish_time && work.myshixun.games.where("status = 2 and answer_open = 1 and end_time <= '#{publish_time}'").count > 0
end
end

@ -31,7 +31,7 @@ elsif @user_course_identity == Course::STUDENT
json.left_time left_time @homework, @current_user.id
if @homework.homework_type == "practice"
json.(@work, :id, :work_status, :update_time, :ultimate_score)
json.(@work, :id, :work_status, :update_time, :ultimate_score, :myshixun_id)
json.calculation_time @work.calculation_time
json.late_penalty @work.late_penalty if @homework.allow_late
json.cost_time @work.myshixun.try(:total_spend_time)
@ -40,7 +40,7 @@ elsif @user_course_identity == Course::STUDENT
json.efficiency work_score_format(@work.efficiency, true, @score_open)
json.eff_score work_score_format(@work.eff_score, true, @score_open)
json.complete_count @work.myshixun.try(:passed_count)
# json.redo_work student_redo_work(@work)
json.redo_work @homework.end_or_late ? false : student_redo_work(@work, @homework)
else
json.(@work, :id, :work_status, :update_time, :ultimate_score)

Loading…
Cancel
Save