用户待完成的测验、用户待完成的作业

This commit is contained in:
cxt 2016-12-12 16:44:01 +08:00
parent 93cf24cf41
commit 9715cba687
1 changed files with 10 additions and 4 deletions

View File

@ -1829,12 +1829,18 @@ class UsersController < ApplicationController
@message_count = @message_alls.count
@message_alls = paginateHelper @message_alls, 20
# 用户待解决的issue
@unsolved_issues = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6])
@unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6])
my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")"
# 用户待完成的作业
@my_course = StudentsForCourse.where(:student_id => @user.id)
@unfinished_homework = 1
homeworks = HomeworkCommon.where("course_id in #{my_course_ids}")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
@unfinished_homework_count = homeworks.count - student_works.count
# 用户待完成的测验
@unfinished_test = 1
exercises = Exercise.where("course_id in #{my_course_ids} and end_time > #{Time.now}")
exercise_ids = exercises.blank? ? "(-1)" : "(" + exercises.map{|ex| ex.id}.join(",") + ")"
exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}")
@unfinished_test_count = exercises.count - exercise_users.count
# 用户待完成的问卷
@unfinished_poll = 1
# 用户待匿评的作业