diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 3f1a66eb4..9a5e7c9fa 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -9,32 +9,32 @@ class StudentWorkController < ApplicationController before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] def index - @order,@b_sort,@name = params[:order] || "final_score",params[:sort] || "desc",params[:name] || "" + @order,@b_sort,@name = params[:order] || "score",params[:sort] || "desc",params[:name] || "" @is_teacher = User.current.allowed_to?(:as_teacher,@course) #老师 || 非匿评作业 || 匿评结束 显示所有的作品 - @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 + @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? if @show_all - if @homework.homework_type == 1 || @is_teacher || User.current.admin? + if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 if @order == "name" - @stundet_works = search_homework_member @homework.student_works.joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name else - @stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name + @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name end - else - my_work = @homework.student_works.where(:user_id => User.current.id) + else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 + my_work = @homework.student_works.select("*,final_score - absence_penalty - late_penalty as score").where(:user_id => User.current.id) if my_work.empty? @stundet_works = [] else if @order == "name" - @stundet_works = search_homework_member @homework.student_works.joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name else - @stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name + @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name end end end else #学生 if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 - @stundet_works = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 @is_evaluation = true my_work = @homework.student_works.where(:user_id => User.current.id) diff --git a/app/views/student_work/_student_work.html.erb b/app/views/student_work/_student_work.html.erb index cd60ef024..302c513b1 100644 --- a/app/views/student_work/_student_work.html.erb +++ b/app/views/student_work/_student_work.html.erb @@ -38,8 +38,9 @@ <% end%> -