diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index 7298f2fe7..cad482390 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -107,10 +107,10 @@ class ExerciseAnswersController < ApplicationController normal_status(-1,"该课堂不存在!") elsif @exercise_user.blank? normal_status(-1,"试卷用户不存在!") - elsif @exercise_user_status == 3 || @exercise_user.commit_status == 1 + elsif @exercise_user.commit_status == 1 normal_status(-1,"已提交/已结束的试卷不允许修改!") else - if @exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + (@exercise.time.to_i + 1).minutes) < Time.now) + if (@exercise_user_status == 3 && @exercise_user.commit_status == 0) || (@exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + (@exercise.time.to_i + 1).minutes) < Time.now)) objective_score = calculate_student_score(@exercise,current_user)[:total_score] subjective_score = @exercise_user.subjective_score < 0.0 ? 0.0 : @exercise_user.subjective_score total_score = objective_score + subjective_score diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e1a5ce826..555da8e54 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1632,12 +1632,6 @@ class ExercisesController < ApplicationController normal_status(404,"答题用户不存在") elsif @exercise.get_exercise_status(current_user.id) != 2 || @answer_committed_user.commit_status == 1 # normal_status(-1,"提交错误,试卷已截止/用户已提交!") - # elsif @exercise.time > 0 - # user_start_at = @answer_committed_user.start_at - # exercise_time = @exercise.time.to_i - # if (user_start_at + exercise_time.minutes) < Time.now - # normal_status(-1,"限时试卷已结束,已自动提交!") - # end end end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index fb2608632..0c8b97ca7 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -114,27 +114,6 @@ class Exercise < ApplicationRecord else status = exercise_status #当为老师的时候,则为试卷的总状态 end - # if user_group.present? - # if user_group.role == "STUDENT" #为学生 - # is_teacher = false - # else - # is_teacher = true - # end - # ex_time = get_exercise_times(user_id,is_teacher) - # - # pb_time = ex_time[:publish_time] - # ed_time = ex_time[:end_time] - # - # if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now - # status = 2 - # elsif ed_time.present? && ed_time <= Time.now - # status = 3 - # else - # status = 1 - # end - # else - # status = exercise_status - # end status end @@ -144,31 +123,11 @@ class Exercise < ApplicationRecord pb_time = publish_time en_time = end_time - if end_time <= Time.now && exercise_status != 3 + if en_time.present? && (en_time <= Time.now) && (exercise_status != 3) update_column("exercise_status",3) end else ex_group_setting = exercise_group_settings - # if teacher #当前为老师,为设置组的最大值和最小值 - # user_group = course.teacher_course_groups.get_user_groups(user_id) - # user_group_ids = user_group.present? ? user_group.pluck(:course_group_id) : course.course_groups.pluck(:id) - # user_ex_group_settings = ex_group_setting.find_in_exercise_group("course_group_id",user_group_ids) - # pb_time_min = user_ex_group_settings.publish_time_no_null.map(&:publish_time) - # en_time_max = user_ex_group_settings.end_time_no_null.map(&:end_time) - # pb_time = pb_time_min.size > 0 ? pb_time_min.min : nil - # en_time = en_time_max.size > 0 ? en_time_max.max : nil - # else - # user_group = course.students.course_find_by_ids("user_id",user_id) - # if user_group.present? - # user_group_id = user_group.first.course_group_id - # user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id) - # pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil - # en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil - # else - # pb_time = nil - # en_time = nil - # end - # end user_group = course.students.course_find_by_ids("user_id",user_id) if user_group.present? user_group_id = user_group.first.course_group_id