实训作业的调整

chromesetting
cxt 5 years ago
parent e11b0cd629
commit 02f60c83a9

@ -78,7 +78,7 @@ class HomeworkCommonsController < ApplicationController
when '4'
sql_str = %Q((homework_detail_manuals.comment_status = #{order} and homework_detail_manuals.appeal_time > '#{Time.now}'))
when '5'
sql_str = %Q((homework_detail_manuals.comment_status = #{order} or (anonymous_comment = 0 and homework_commons.end_time <= '#{Time.now}')))
sql_str = %Q((homework_detail_manuals.comment_status = #{order} or (anonymous_comment = 0 and ((allow_late= 0 and homework_commons.end_time <= '#{Time.now}') or (allow_late= 1 and late_time <= '#{Time.now}')))))
else
sql_str = %Q(homework_detail_manuals.comment_status = #{order})
end
@ -168,7 +168,8 @@ class HomeworkCommonsController < ApplicationController
params_work_status = params[:work_status]
work_status = params_work_status.map{|status| status.to_i}
all_student_works = @student_works.left_joins(:myshixun)
@student_works = all_student_works.where(work_status: work_status)
@student_works = all_student_works.where(work_status: work_status) if work_status.include?(0)
@student_works = @student_works.or(all_student_works.where(work_status: 0)).or(all_student_works.where(myshixuns: {status: 0})) if work_status.include?(1)
@student_works = @student_works.or(all_student_works.where(work_status: 0)).or(all_student_works.where(myshixuns: {status: 0})) if work_status.include?(3)
@student_works = @student_works.or(all_student_works.where(myshixuns: {status: 1})) if work_status.include?(4)

@ -34,6 +34,12 @@ module HomeworkCommonsHelper
# 作业状态大于“提交”状态时,不用考虑分班权限
if ho_detail_manual.comment_status > 1
case ho_detail_manual.comment_status
when 2
unless homework_common.allow_late
status << "已截止"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
time_status = 5
end
when 3
if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now
status << "匿评中"
@ -46,8 +52,8 @@ module HomeworkCommonsHelper
time = "申诉剩余时间:" + how_much_time(ho_detail_manual.appeal_time)
time_status = 4
end
when 2, 5, 6
status << "评阅中"
when 5, 6
status << "已截止"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
time_status = 5
end
@ -77,12 +83,12 @@ module HomeworkCommonsHelper
time = "提交剩余时间:" + how_much_time(homework_common.end_time)
time_status = 1
elsif homework_common.end_time && homework_common.end_time < Time.now
time_status = 5
if homework_common.allow_late && (homework_common.late_time.nil? || homework_common.late_time >= Time.now)
time = "补交剩余时间:" + how_much_time(homework_common.late_time)
time_status = 2
else
status << "已截止"
time_status = 5
end
end
end

@ -83,6 +83,11 @@ class Myshixun < ApplicationRecord
self.games.select{|game| game.status == 2}.size
end
# 指定时间前完成的关卡数
def time_passed_count time
time.present? ? self.games.select{|game| game.status == 2 && game.end_time < time}.size : 0
end
# 查看答案的关卡数,只统计通关前看的关卡
def view_answer_count
answer_ids = user.grades.joins("join games on grades.container_id = games.id").where("container_type = 'Answer' and games.status=2 and games.end_time > grades.created_at").pluck(:container_id)

@ -123,6 +123,26 @@ class StudentWork < ApplicationRecord
end
end
# 实训作业的作品状态 0未提交1未通关2按时通关(提交截止前通关)3迟交通关提交截止-补交截止间通关)
def real_work_status
status = work_status
if status > 0 && myshixun
if myshixun.status != 1
status = 1
else
homework_end_time = homework_common.homework_group_setting(user_id)&.end_time
if homework_end_time.present? && homework_end_time > myshixun.passed_time
status = 2
elsif homework_end_time.present? && homework_common.allow_late && homework_common.late_time > myshixun.passed_time
status = 3
else
status = 1
end
end
end
status
end
# 更新作品成绩
def set_work_score
if work_status > 0 && homework_common && !self.ultimate_score

@ -33,7 +33,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, :update_time, :ultimate_score)
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)
@ -41,8 +41,10 @@ elsif @user_course_identity == Course::STUDENT
json.final_score work_score_format(@work.final_score, true, @score_open)
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.current_complete_count @work.myshixun.try(:passed_count) if @homework.end_or_late
json.complete_count @work.myshixun&.time_passed_count(@homework.homework_group_setting(@work.user_id)&.end_time)
json.view_answer_count @work.myshixun.try(:view_answer_count)
json.work_status @work.real_work_status
else
json.(@work, :id, :work_status, :update_time, :ultimate_score)
@ -87,7 +89,7 @@ if @homework.homework_type == "practice"
json.work_efficiency @homework.work_efficiency
json.student_works @student_works.each do |work|
json.(work, :id, :work_status, :update_time, :ultimate_score, :myshixun_id)
json.(work, :id, :update_time, :ultimate_score, :myshixun_id)
json.late_penalty work.late_penalty if @homework.allow_late
json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open)
@ -96,12 +98,14 @@ if @homework.homework_type == "practice"
json.eff_score work_score_format(work.eff_score, @current_user == work.user, @score_open)
json.cost_time work.myshixun.try(:total_spend_time)
json.complete_count work.myshixun.try(:passed_count)
json.current_complete_count work.myshixun.try(:passed_count) if @homework.end_or_late
json.complete_count work.myshixun&.time_passed_count(@homework.homework_group_setting(work.user_id)&.end_time)
json.view_answer_count work.myshixun.try(:view_answer_count)
json.user_login work.user.try(:login)
json.user_name work.user.try(:real_name)
json.student_id work.user.try(:student_id)
json.group_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name)
json.work_status work.real_work_status
end
elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.anonymous_comment @homework.anonymous_comment

@ -0,0 +1,5 @@
class MigrateStudentWorkCompeleteStatus < ActiveRecord::Migration[5.2]
def change
end
end
Loading…
Cancel
Save