From e82c88df48492adc743c1457ee6ecc2f33339426 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 2 Jul 2015 17:44:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E6=9C=80=E7=BB=88=E8=AF=84=E5=88=86?= =?UTF-8?q?=E6=9C=AA=E8=AF=84=E6=97=B6=EF=BC=8C=E6=88=90=E7=BB=A9=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9C=AA=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 20 +++++++++---------- app/views/student_work/_student_work.html.erb | 5 +++-- .../student_work/_student_work_title.html.erb | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) 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%> -
  • - <%= student_work.final_score.nil? ? "--" : format("%.1f",student_work.final_score)%> + <% score = student_work.respond_to?("score") ? student_work.score : student_work.final_score - student_work.absence_penalty - student_work.late_penalty%> +
  • + <%= score.nil? ? "--" : format("%.1f",score)%>
  • \ No newline at end of file diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb index 23e29b01b..0e4151065 100644 --- a/app/views/student_work/_student_work_title.html.erb +++ b/app/views/student_work/_student_work_title.html.erb @@ -36,8 +36,8 @@ <% end%>
  • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "final_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <% if @show_all && @order == "score"%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • \ No newline at end of file