diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 5fa5296d5..44b694239 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -32,13 +32,13 @@ class ExercisesController < ApplicationController @exercises_all = @course.exercises member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷 @current_user_ = current_user - @exercises_count = @exercises_all.count # 全部页面,需返回 - @exercises_unpublish_counts = @exercises_all.exercise_by_status(1).count #未发布的试卷数 - @exercises_published_counts = @exercises_all.exercise_by_status([2,3]).count # 已发布的试卷数,包含已截止的 - @exercises_ended_counts = @exercises_all.exercise_by_status(3).count #已截止的试卷数 + @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 #已截止的试卷数 # 课堂的学生人数 @course_all_members = @course.students #当前课堂的全部学生 - @course_all_members_count = @course_all_members.count #当前课堂的学生数 + @course_all_members_count = @course_all_members.size #当前课堂的学生数 @current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生 # exercises的不同用户群体的显示 @@ -64,7 +64,7 @@ class ExercisesController < ApplicationController @is_teacher_or = 0 @exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] end - if @exercises.count > 0 + if @exercises.size > 0 if params[:type].present? choose_type = params[:type].to_i member_group_id = @current_student.first.try(:course_group_id).to_i diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 56bbb9b77..b5ba79dcc 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -3,8 +3,8 @@ module PollsHelper #获取试卷的已答/未答人数 def get_poll_answers(poll_users) @commit_poll_users = poll_users.commit_by_status(1) #当前老师的全部学生中已提交的 - @poll_answers = @commit_poll_users.present? ? @commit_poll_users.count : 0 #表示已经提交了的用户 - course_all_members_count = poll_users.present? ? poll_users.count : 0 + @poll_answers = @commit_poll_users.present? ? @commit_poll_users.size : 0 #表示已经提交了的用户 + course_all_members_count = poll_users.present? ? poll_users.size : 0 @poll_unanswers = (course_all_members_count - @poll_answers) end diff --git a/app/models/poll.rb b/app/models/poll.rb index ce5da17dd..1cead3291 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -137,17 +137,17 @@ class Poll < ApplicationRecord #判断当前用户的答题状态 def check_user_votes_status(user) poll_answer_user = poll_users.find_by(user_id: user.id) - user_poll_status = get_poll_status(user.id) + # user_poll_status = get_poll_status(user.id) user_status = 2 if poll_answer_user.present? && (poll_answer_user.start_at.present? || poll_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 user_status = poll_answer_user.commit_status end - - if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 - # user_status = 4 - user_status = 5 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示 - end + # + # if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 + # # user_status = 4 + # user_status = 2 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示 + # end user_status end