当最终评分未评时,成绩显示未评分

This commit is contained in:
sw 2015-07-02 17:44:25 +08:00
parent 0d0e294c10
commit e82c88df48
3 changed files with 16 additions and 15 deletions

View File

@ -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)

View File

@ -38,8 +38,9 @@
</div>
<% end%>
</li>
<li class=" hwork_score <%= score_color student_work.final_score%>">
<%= 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%>
<li class=" hwork_score <%= score_color score%>">
<%= score.nil? ? "--" : format("%.1f",score)%>
</li>
<div class="cl"></div>
</ul><!---hwork_ul end-->

View File

@ -36,8 +36,8 @@
<% end%>
</li>
<li class="ml20">
<%= 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%>
</li>