diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 94a692ed9..1af84a1a3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1829,23 +1829,29 @@ class UsersController < ApplicationController @message_count = @message_alls.count @message_alls = paginateHelper @message_alls, 20 # 用户待解决的issue - @unsolved_issues_count = 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]).count my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")" # 用户待完成的作业 - homeworks = HomeworkCommon.where("course_id in #{my_course_ids}") + homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'") 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 # 用户待完成的测验 - exercises = Exercise.where("course_id in #{my_course_ids} and end_time > #{Time.now}") + exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2") 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 - # 用户待匿评的作业 - @anonymous_evaluation = 1 - # 待评阅的作业 + polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") + poll_ids = polls.blank? ? "(-1)" : "(" + polls.map{|poll| poll.id}.join(",") + ")" + poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}") + @unfinished_poll_count = polls.count - poll_users.count + # 用户待匿评的作品 + student_work_evaluations = @user.student_works_evaluation_distributions + student_work_ids = student_work_evaluations.blank? ? "(-1)" : "(" + student_work_evaluations.map{|st| st.student_work_id}.join(",") + ")" + student_work_scores = @user.student_works_scores.where("student_work_id in #{student_work_ids} and reviewer_role = 3") + @anonymous_evaluation_count = student_work_evaluations.count - student_work_scores.count + # 待评阅的作业 暂不做 @unreview_homework = 1 # 待审批的作业 @unapproval_homework = 1 diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e54ad445a..12e6679de 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -12,7 +12,7 @@
  • - 248 + <%= @unsolved_issues_count %>

    待解决Issue @@ -22,7 +22,7 @@
  • - 21 + <%= @unfinished_homework_count %>

    待完成作业 @@ -32,7 +32,7 @@
  • - 21 + <%= @unfinished_test_count %>

    待完成测验 @@ -42,7 +42,7 @@
  • - 11 + <%= @unfinished_poll_count %>

    待完成问卷 @@ -52,22 +52,22 @@
  • - 21 + <%= @anonymous_evaluation_count %>
    -
    待匿评作业 -
    -
    -
    -
    - -
  • - 21 -
    -
    -
    待评阅作业 +
    待匿评作品
    + + + + + + + + + +