From f6a6a5e98da0a15cfcd718bcff6d4c981d69f6f6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 5 Jul 2019 18:21:22 +0800 Subject: [PATCH] fixbug --- app/controllers/exercises_controller.rb | 3 +-- app/models/exercise.rb | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 7426a40d5..9087aeee6 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -105,8 +105,7 @@ class ExercisesController < ApplicationController @course_all_members_count = @course_all_members.size #当前课堂的学生数 @exercises_count = @exercises_all.size # 全部页面,需返回 @exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数 - @exercises_published_counts = @exercises_all.exercise_by_status([2,3]).size # 已发布的试卷数,包含已截止的 - @exercises_ended_counts = @exercises_all.exercise_by_status(3).size #已截止的试卷数 + @exercises_published_counts = @exercises_count - @exercises_unpublish_counts # 已发布的试卷数,包含已截止的 rescue Exception => e uid_logger_error(e.message) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index d6e9269cc..42b737c26 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -69,11 +69,7 @@ class Exercise < ApplicationRecord def common_published_ids(user_id) current_user_groups = course.teacher_course_ids(user_id) if unified_setting - if course.none_group_count > 0 #有未分班的,则发布到未发布分班 - un_group_ids = [0] - else - un_group_ids = [] - end + un_group_ids = (course.none_group_count > 0) ? [0] : [] published_group_ids = (current_user_groups + un_group_ids).uniq #统一设置时,为当前用户的分班id及未分班 else ex_group_setting = exercise_group_settings.pluck("course_group_id").uniq @@ -89,11 +85,7 @@ class Exercise < ApplicationRecord ex_group_settings = exercise_group_settings.pluck(:course_group_id) member = course.course_members.course_find_by_ids("user_id",user_id) member_group_id = member.pluck(:course_group_id).uniq - if (member_group_id & ex_group_settings).size > 0 || user_identity < Course::STUDENT - true - else - false - end + ((member_group_id & ex_group_settings).size > 0 || user_identity < Course::STUDENT) ? true : false end #判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间