个人首页的待匿评作品、待完成问卷

This commit is contained in:
cxt 2016-12-13 13:57:25 +08:00
parent 9715cba687
commit 30dccdec90
2 changed files with 29 additions and 23 deletions

View File

@ -1829,23 +1829,29 @@ class UsersController < ApplicationController
@message_count = @message_alls.count @message_count = @message_alls.count
@message_alls = paginateHelper @message_alls, 20 @message_alls = paginateHelper @message_alls, 20
# 用户待解决的issue # 用户待解决的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(",") + ")" 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(",") + ")" 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") 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_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_ids = exercises.blank? ? "(-1)" : "(" + exercises.map{|ex| ex.id}.join(",") + ")"
exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}") exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}")
@unfinished_test_count = exercises.count - exercise_users.count @unfinished_test_count = exercises.count - exercise_users.count
# 用户待完成的问卷 # 用户待完成的问卷
@unfinished_poll = 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(",") + ")"
@anonymous_evaluation = 1 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 @unreview_homework = 1
# 待审批的作业 # 待审批的作业
@unapproval_homework = 1 @unapproval_homework = 1

View File

@ -12,7 +12,7 @@
<div class="homepage_tab_div" id="user_homepage_tab_01" style=""> <div class="homepage_tab_div" id="user_homepage_tab_01" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;"> <span style="margin: 5px auto; vertical-align: middle; display: inline-block;">
<li class="homepage_issue_tab mb5 fl"></li> <li class="homepage_issue_tab mb5 fl"></li>
<span class="ml5 fl" style="font-size: 20px;">248</span> <span class="ml5 fl" style="font-size: 20px;"><%= @unsolved_issues_count %></span>
<div class="cl"></div> <div class="cl"></div>
</span> </span>
<br />待解决Issue <br />待解决Issue
@ -22,7 +22,7 @@
<div class="homepage_tab_div" id="user_homepage_tab_02" style=""> <div class="homepage_tab_div" id="user_homepage_tab_02" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;"> <span style="margin: 5px auto; vertical-align: middle; display: inline-block;">
<li class="homepage_issue_tab mb5 fl"></li> <li class="homepage_issue_tab mb5 fl"></li>
<span class="ml5 fl" style="font-size: 20px;">21</span> <span class="ml5 fl" style="font-size: 20px;"><%= @unfinished_homework_count %></span>
<div class="cl"></div> <div class="cl"></div>
</span> </span>
<br />待完成作业 <br />待完成作业
@ -32,7 +32,7 @@
<div class="homepage_tab_div" id="user_homepage_tab_03" style=""> <div class="homepage_tab_div" id="user_homepage_tab_03" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;"> <span style="margin: 5px auto; vertical-align: middle; display: inline-block;">
<li class="homepage_issue_tab mb5 fl"></li> <li class="homepage_issue_tab mb5 fl"></li>
<span class="ml5 fl" style="font-size: 20px;">21</span> <span class="ml5 fl" style="font-size: 20px;"><%= @unfinished_test_count %></span>
<div class="cl"></div> <div class="cl"></div>
</span> </span>
<br />待完成测验 <br />待完成测验
@ -42,7 +42,7 @@
<div class="homepage_tab_div" id="user_homepage_tab_04" style=""> <div class="homepage_tab_div" id="user_homepage_tab_04" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;"> <span style="margin: 5px auto; vertical-align: middle; display: inline-block;">
<li class="homepage_issue_tab mb5 fl"></li> <li class="homepage_issue_tab mb5 fl"></li>
<span class="ml5 fl" style="font-size: 20px;">11</span> <span class="ml5 fl" style="font-size: 20px;"><%= @unfinished_poll_count %></span>
<div class="cl"></div> <div class="cl"></div>
</span> </span>
<br />待完成问卷 <br />待完成问卷
@ -52,22 +52,22 @@
<div class="homepage_tab_div" id="user_homepage_tab_05" style=""> <div class="homepage_tab_div" id="user_homepage_tab_05" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;"> <span style="margin: 5px auto; vertical-align: middle; display: inline-block;">
<li class="homepage_issue_tab mb5 fl"></li> <li class="homepage_issue_tab mb5 fl"></li>
<span class="ml5 fl" style="font-size: 20px;">21</span> <span class="ml5 fl" style="font-size: 20px;"><%= @anonymous_evaluation_count %></span>
<div class="cl"></div> <div class="cl"></div>
</span> </span>
<br />待匿评作业 <br />待匿评作品
</div>
</div>
<div class="flex-cell_homepage">
<div class="homepage_tab_div" id="user_homepage_tab_06" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;">
<li class="homepage_issue_tab mb5 fl"></li>
<span class="ml5 fl" style="font-size: 20px;">21</span>
<div class="cl"></div>
</span>
<br />待评阅作业
</div> </div>
</div> </div>
<!--<div class="flex-cell_homepage">-->
<!--<div class="homepage_tab_div" id="user_homepage_tab_06" style="">-->
<!--<span style="margin: 5px auto; vertical-align: middle; display: inline-block;">-->
<!--<li class="homepage_issue_tab mb5 fl"></li>-->
<!--<span class="ml5 fl" style="font-size: 20px;">21</span>-->
<!--<div class="cl"></div>-->
<!--</span>-->
<!--<br />待评阅作业-->
<!--</div>-->
<!--</div>-->
<div class="flex-cell_homepage"> <div class="flex-cell_homepage">
<div class="homepage_tab_div" id="user_homepage_tab_07" style=""> <div class="homepage_tab_div" id="user_homepage_tab_07" style="">
<span style="margin: 5px auto; vertical-align: middle; display: inline-block;"> <span style="margin: 5px auto; vertical-align: middle; display: inline-block;">