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 @@ 实评