作品列表为空时缺评列表报错

This commit is contained in:
sw 2015-06-19 16:23:28 +08:00
parent 95ab6dd6c0
commit a9ff9f96bd
1 changed files with 8 additions and 4 deletions

View File

@ -245,6 +245,9 @@ class StudentWorkController < ApplicationController
def student_work_absence_penalty
render_403 unless User.current.allowed_to?(:as_teacher,@course)
order = params[:order] || "desc"
if @homework.student_works.empty?
@stundet_works = []
else
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
@stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM(
SELECT * ,
@ -254,6 +257,7 @@ class StudentWorkController < ApplicationController
WHERE homework_common_id = #{@homework.id}
) AS table_1
ORDER BY absence #{order}")
end
@order = order == "desc" ? "asc" : "desc"
respond_to do |format|
format.html