diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 3dd5e9890..c8cbde626 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -236,7 +236,17 @@ class StudentWorkController < ApplicationController #评价列表显示 def student_work_absence_penalty render_403 unless User.current.allowed_to?(:as_teacher,@course) - @stundet_works = @homework.student_works + order = params[:order] || "desc" + work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" + @stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM( + SELECT * , + (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count, + (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count + FROM `student_works` + WHERE homework_common_id = 213 + ) AS table_1 + ORDER BY absence #{order}") + @order = order == "desc" ? "asc" : "desc" respond_to do |format| format.html end diff --git a/app/views/student_work/student_work_absence_penalty.html.erb b/app/views/student_work/student_work_absence_penalty.html.erb index a0d6cdc04..e9054561f 100644 --- a/app/views/student_work/student_work_absence_penalty.html.erb +++ b/app/views/student_work/student_work_absence_penalty.html.erb @@ -20,7 +20,8 @@ 实评
  • - 缺评 + <%= link_to "缺评",student_work_absence_penalty_student_work_index_path(:homework => @homework.id,:order => @order)%> +
  • @@ -35,19 +36,14 @@
  • <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02"%>
  • - <% - all_count = all_evaluation_count student_work.user,@homework - has_count = has_evaluation_count student_work.user,@homework - absence = all_count - has_count - %>
  • - <%= all_count%> + <%= student_work.all_count%>
  • - <%= has_count%> + <%= student_work.has_count%>
  • -
  • - <%= absence%> +
  • + <%= student_work.absence%>
  • <% end%>