From 4b49571ab58b3b6651626d71f7dc505bc62c36e0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 5 Jul 2019 11:31:45 +0800 Subject: [PATCH] fix bug --- app/controllers/exercises_controller.rb | 40 ++----------------------- app/controllers/polls_controller.rb | 2 -- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e6f9876bc..49dd7edb9 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -477,10 +477,8 @@ class ExercisesController < ApplicationController params_end_time = params[:end_time].to_time end - if exercise_status == 2 && @exercise.publish_time != params_publish_time - normal_status(-1,"已发布,不允许修改发布时间") - elsif exercise_status == 3 && (@exercise.end_time != params_end_time || @exercise.publish_time != params_publish_time) - normal_status(-1,"已截止,不允许修改时间") + if (exercise_status != 1) && (@exercise.publish_time != params_publish_time) + normal_status(-1,"已发布/已截止,不允许修改发布时间") elsif params_publish_time.present? && params_end_time.present? && params_end_time < params_publish_time normal_status(-1,"截止时间不能小于发布时间") else @@ -523,12 +521,7 @@ class ExercisesController < ApplicationController end # exercise_end_time = t[:end_time].present? ? t[:end_time].to_time : nil exercise_group = exercise_groups.find_in_exercise_group("course_group_id",course_id) #判断该分班是否存在 - if exercise_group.present? && exercise_group.first.end_time <= Time.now && - (exercise_end_time != exercise_group.first.end_time || exercise_publish_time != exercise_group.first.publish_time) #已截止且时间改变的,则提示错误 - error_count += 1 - end - if exercise_group.present? && exercise_group.first.publish_time < - Time.now && exercise_publish_time != exercise_group.first.publish_time + if exercise_group.present? && (exercise_group.first.publish_time < Time.now) && (exercise_publish_time != exercise_group.first.publish_time) error_count += 1 end if error_count == 0 @@ -1639,36 +1632,9 @@ class ExercisesController < ApplicationController @answer_committed_user = @exercise.exercise_users.exercise_commit_users(current_user.id)&.first if @answer_committed_user.blank? normal_status(404,"答题用户不存在") - # elsif @exercise.get_exercise_status(current_user.id) == 2 && @answer_committed_user.commit_status == 1 #当试卷截止时,会自动提交 - # normal_status(-1,"提交错误,试卷用户已提交!") end end - # def commit_user_exercise - # @exercise_user_current = @exercise.exercise_users.exercise_commit_users(@exercise_current_user_id)&.first #查找当前用户是否有过答题 - # if @user_course_identity == Course::STUDENT - # if @exercise_user_current.present? - # if @exercise.time > 0 && @exercise_user_current.start_at.present? && (@exercise_user_current.commit_status == 0) && - # ((@exercise_user_current.start_at + (@exercise.time.to_i + 1).minutes) < Time.now) - # #当前用户存在,且已回答,且试卷时间已过,且未提交,则自动提交。最好是前端控制 - # objective_score = calculate_student_score(@exercise,current_user)[:total_score] - # subjective_score = @exercise_user_current.subjective_score < 0.0 ? 0.0 : @exercise_user_current.subjective_score - # total_score = objective_score + subjective_score - # commit_option = { - # :status => 1, - # :commit_status => 1, - # :end_at => Time.now, - # :objective_score => objective_score, - # :score => total_score, - # :subjective_score => subjective_score - # } - # @exercise_user_current.update_attributes(commit_option) - # normal_status(0,"已交卷成功!") - # end - # end - # end - # end - #打回重做时的初步判断 def check_exercise_status @exercise_users = @exercise.all_exercise_users(current_user.id).commit_exercise_by_status(1) #当前教师所在分班的全部已提交的学生数 diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 57bbc9769..64827b375 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1282,8 +1282,6 @@ class PollsController < ApplicationController else normal_status(-1,"请选择分班!") end - # elsif (@poll.poll_status != 1) && (params[:publish_time].to_time != @poll.publish_time) && (@user_course_identity > Course::CREATOR) - # normal_status(-1,"已发布/已截止的不能修发布时间!") #课堂管理员和超级管理员才有权限 end end