From 13f1d15b337a184143eae10ee7bdd8769d8f5491 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:01:46 +0800 Subject: [PATCH 1/3] fix but --- app/models/exercise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index fb2608632..3b3b93f09 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -144,7 +144,7 @@ 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 From a5e63a512485e18145f13d07edb05ae384af557a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:07:43 +0800 Subject: [PATCH 2/3] fix but --- app/models/exercise.rb | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 3b3b93f09..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 @@ -149,26 +128,6 @@ class Exercise < ApplicationRecord 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 From 9c1ab345193dea5f0248866986d15426b282564b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 16:19:07 +0800 Subject: [PATCH 3/3] fix bug --- app/controllers/exercise_answers_controller.rb | 4 ++-- app/controllers/exercises_controller.rb | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) 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