From 04e46063b2dae1964645730587dad8071d30a9a3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 15 Jul 2019 16:10:32 +0800 Subject: [PATCH 1/2] fixbug --- app/controllers/exercises_controller.rb | 8 ++++---- app/helpers/exercises_helper.rb | 6 +++++- app/models/exercise.rb | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 6fa694fbf..79b22d571 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1519,7 +1519,7 @@ class ExercisesController < ApplicationController if exercise.present? if exercise.unified_setting #统一设置只有两种情况,全部发布,全部截止 exercise_user_status = exercise.get_exercise_status(current_user) #当前用户的能看到的试卷 - if (exercise_user_status == exercise_status) || exercise_status == Exercise::ENDED #未发布的情况 + if (exercise_user_status == exercise_status) || exercise_status == Exercise::DEADLINE #未发布的情况 unpublish_group = unpublish_group + user_groups_id end else @@ -1527,7 +1527,7 @@ class ExercisesController < ApplicationController ex_group_settings = ex_all_group_settings.exercise_group_published.pluck(:course_group_id).uniq #问卷设置的班级 if exercise_status == Exercise::UNPUBLISHED unpublish_group = user_groups_id - ex_group_settings - elsif exercise_status == Exercise::ENDED + elsif exercise_status == Exercise::DEADLINE ex_ended_groups = ex_all_group_settings.exercise_group_ended.pluck(:course_group_id).uniq ex_and_user = user_groups_id & ex_group_settings #用户已设置的分班 unpublish_group = unpublish_group + ex_and_user - ex_ended_groups #已发布的全部班级减去截止的全部班级 @@ -1627,7 +1627,7 @@ class ExercisesController < ApplicationController def check_exercise_public if @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生,试卷公开统计,且已截止,且已提交 ex_user = @exercise.exercise_users.exercise_commit_users(current_user.id).first - unless @exercise.get_exercise_status(current_user) == Exercise::ENDED && ex_user.present? && ex_user.commit_status == 1 && + unless @exercise.get_exercise_status(current_user) == Exercise::DEADLINE && ex_user.present? && ex_user.commit_status == 1 && @exercise.show_statistic normal_status(-1,"学生暂不能查看") end @@ -1650,7 +1650,7 @@ class ExercisesController < ApplicationController ex_question_random = exercise.question_random question_answered = 0 exercise_questions.each_with_index do |q,index| - if ex_question_random && exercise_user_status != Exercise::ENDED + if ex_question_random && exercise_user_status != Exercise::DEADLINE ques_number = index + 1 else ques_number = q.question_number diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 3e73931e0..92816d68b 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -89,6 +89,7 @@ module ExercisesHelper questions.each do |ex| ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分 ex_answers = ex.exercise_answers + if ex.question_type != Exercise::PRACTICAL ques_title = ex.question_title ques_less_title = nil @@ -98,13 +99,16 @@ module ExercisesHelper ques_less_title = ex.question_title effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids) end - effictive_users_count = effictive_users.count #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数 + + effictive_users_count = effictive_users.size #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数 ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 + if ex_total_score == 0.0 percent = 0.0 else percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率 end + question_answer_infos = [] if ex.question_type <= Exercise::JUDGMENT #单选题 standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id) #标准答案的位置 diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 79701767f..e7d141ea9 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -135,7 +135,7 @@ class Exercise < ApplicationRecord if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now status = Exercise::PUBLISHED elsif ed_time.present? && ed_time <= Time.now - status = Exercise::ENDED + status = Exercise::DEADLINE else status = Exercise::UNPUBLISHED end From 0e4bc4d4ce5ecdca0039de5101fd09a2b988008d Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 15 Jul 2019 16:15:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/base_account_controller.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/controllers/users/base_account_controller.rb b/app/controllers/users/base_account_controller.rb index 5c474517d..0d6bb24ec 100644 --- a/app/controllers/users/base_account_controller.rb +++ b/app/controllers/users/base_account_controller.rb @@ -1,15 +1,8 @@ class Users::BaseAccountController < Users::BaseController - before_action :require_login, :check_auth + before_action :require_login def observed_user @_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id])) end - private - - def require_login - return if User.current.logged? - - tip_exception(401, "..") - end end