增加按学生login、学号、真实姓名排序
This commit is contained in:
parent
1fdd3b0b92
commit
a1e28bcd9e
|
@ -7,8 +7,8 @@ class StudentWorkController < ApplicationController
|
||||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@order,sort = params[:order] || "final_score",params[:sort] || "desc"
|
@order,sort,@name = params[:order] || "final_score",params[:sort] || "desc",params[:name] || ""
|
||||||
@stundet_works = @homework.student_works.order("#{@order} #{sort}")
|
@stundet_works = search_homework_member @homework.student_works.order("#{@order} #{sort}"),@name
|
||||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||||
@score = sort == "desc" ? "asc" : "desc"
|
@score = sort == "desc" ? "asc" : "desc"
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -178,4 +178,12 @@ class StudentWorkController < ApplicationController
|
||||||
def author_of_work
|
def author_of_work
|
||||||
render_403 unless User.current.id == @work.user_id && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
render_403 unless User.current.id == @work.user_id && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#根据条件过滤作业结果
|
||||||
|
def search_homework_member homeworks,name
|
||||||
|
select_homework = homeworks.select{ |homework|
|
||||||
|
homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name)
|
||||||
|
}
|
||||||
|
select_homework
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -36,7 +36,7 @@
|
||||||
所有作品(<span class="c_red"><%= @stundet_works.count%></span>)
|
所有作品(<span class="c_red"><%= @stundet_works.count%></span>)
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
<input type="text" name="" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl">
|
<input type="text" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName($(this),'<%= student_work_index_path(:homework => @homework.id)%>',event);">
|
||||||
<div class="fr">
|
<div class="fr">
|
||||||
<a class="down_btn fr" href="javascript:void(0);">附件</a>
|
<a class="down_btn fr" href="javascript:void(0);">附件</a>
|
||||||
<a class="down_btn fr" href="javascript:void(0);">列表</a>
|
<a class="down_btn fr" href="javascript:void(0);">列表</a>
|
||||||
|
@ -55,25 +55,25 @@
|
||||||
<span class="c_dark f14 fb fl">作品名称</span>
|
<span class="c_dark f14 fb fl">作品名称</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="w70 mr5" >
|
<li class="w70 mr5" >
|
||||||
<%= link_to "教师评分",student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score),:class => "c_dark f14 fb fl"%>
|
<%= link_to "教师评分",student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name),:class => "c_dark f14 fb fl"%>
|
||||||
<% if @order == "teacher_score"%>
|
<% if @order == "teacher_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
</li>
|
</li>
|
||||||
<li class="w70 mr5">
|
<li class="w70 mr5">
|
||||||
<%= link_to "教辅评分",student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score),:class => "c_dark f14 fb fl"%>
|
<%= link_to "教辅评分",student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name),:class => "c_dark f14 fb fl"%>
|
||||||
<% if @order == "teaching_asistant_score"%>
|
<% if @order == "teaching_asistant_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
</li>
|
</li>
|
||||||
<li class="w60 mr5 ml10">
|
<li class="w60 mr5 ml10">
|
||||||
<%= link_to "匿评",student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score),:class => "c_dark f14 fb fl"%>
|
<%= link_to "匿评",student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name),:class => "c_dark f14 fb fl"%>
|
||||||
<% if @order == "student_score"%>
|
<% if @order == "student_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
</li>
|
</li>
|
||||||
<li class="w40 ml10" id="final_sort">
|
<li class="w40 ml10" id="final_sort">
|
||||||
<%= link_to "成绩",student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score),:class => "c_dark f14 fb fl"%>
|
<%= link_to "成绩",student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score, :name => @name),:class => "c_dark f14 fb fl"%>
|
||||||
<% if @order == "final_score"%>
|
<% if @order == "final_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
|
@ -792,3 +792,11 @@ function clickOK(path)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SearchByName(obj,url,event)
|
||||||
|
{
|
||||||
|
var keycode = (event.keyCode ? event.keyCode : event.which);
|
||||||
|
if(keycode == '13'){
|
||||||
|
location.href = url + "&name=" + obj.val();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue