dev_forum
SylorHuang 5 years ago
parent 0b1049e319
commit 26919424e0

@ -32,13 +32,13 @@ class ExercisesController < ApplicationController
@exercises_all = @course.exercises @exercises_all = @course.exercises
member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷 member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷
@current_user_ = current_user @current_user_ = current_user
@exercises_count = @exercises_all.count # 全部页面,需返回 @exercises_count = @exercises_all.size # 全部页面,需返回
@exercises_unpublish_counts = @exercises_all.exercise_by_status(1).count #未发布的试卷数 @exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数
@exercises_published_counts = @exercises_all.exercise_by_status([2,3]).count # 已发布的试卷数,包含已截止的 @exercises_published_counts = @exercises_all.exercise_by_status([2,3]).size # 已发布的试卷数,包含已截止的
@exercises_ended_counts = @exercises_all.exercise_by_status(3).count #已截止的试卷数 @exercises_ended_counts = @exercises_all.exercise_by_status(3).size #已截止的试卷数
# 课堂的学生人数 # 课堂的学生人数
@course_all_members = @course.students #当前课堂的全部学生 @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) #当前用户是否为课堂的学生 @current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生
# exercises的不同用户群体的显示 # exercises的不同用户群体的显示
@ -64,7 +64,7 @@ class ExercisesController < ApplicationController
@is_teacher_or = 0 @is_teacher_or = 0
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] @exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : []
end end
if @exercises.count > 0 if @exercises.size > 0
if params[:type].present? if params[:type].present?
choose_type = params[:type].to_i choose_type = params[:type].to_i
member_group_id = @current_student.first.try(:course_group_id).to_i member_group_id = @current_student.first.try(:course_group_id).to_i

@ -3,8 +3,8 @@ module PollsHelper
#获取试卷的已答/未答人数 #获取试卷的已答/未答人数
def get_poll_answers(poll_users) def get_poll_answers(poll_users)
@commit_poll_users = poll_users.commit_by_status(1) #当前老师的全部学生中已提交的 @commit_poll_users = poll_users.commit_by_status(1) #当前老师的全部学生中已提交的
@poll_answers = @commit_poll_users.present? ? @commit_poll_users.count : 0 #表示已经提交了的用户 @poll_answers = @commit_poll_users.present? ? @commit_poll_users.size : 0 #表示已经提交了的用户
course_all_members_count = poll_users.present? ? poll_users.count : 0 course_all_members_count = poll_users.present? ? poll_users.size : 0
@poll_unanswers = (course_all_members_count - @poll_answers) @poll_unanswers = (course_all_members_count - @poll_answers)
end end

@ -137,17 +137,17 @@ class Poll < ApplicationRecord
#判断当前用户的答题状态 #判断当前用户的答题状态
def check_user_votes_status(user) def check_user_votes_status(user)
poll_answer_user = poll_users.find_by(user_id: user.id) 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 user_status = 2
if poll_answer_user.present? && (poll_answer_user.start_at.present? || poll_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 if poll_answer_user.present? && (poll_answer_user.start_at.present? || poll_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = poll_answer_user.commit_status user_status = poll_answer_user.commit_status
end end
#
if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 # if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3
# user_status = 4 # # user_status = 4
user_status = 5 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示 # user_status = 2 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示
end # end
user_status user_status
end end

Loading…
Cancel
Save