Merge branch 'develop' into szzh

This commit is contained in:
sw 2015-06-25 14:25:35 +08:00
commit e4011adf16
3 changed files with 17 additions and 9 deletions

View File

@ -245,15 +245,19 @@ class StudentWorkController < ApplicationController
def student_work_absence_penalty def student_work_absence_penalty
render_403 unless User.current.allowed_to?(:as_teacher,@course) render_403 unless User.current.allowed_to?(:as_teacher,@course)
order = params[:order] || "desc" order = params[:order] || "desc"
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" if @homework.student_works.empty?
@stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM( @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 * , SELECT * ,
(SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count, (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
(SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
FROM `student_works` FROM `student_works`
WHERE homework_common_id = #{@homework.id} WHERE homework_common_id = #{@homework.id}
) AS table_1 ) AS table_1
ORDER BY absence #{order}") ORDER BY absence #{order}")
end
@order = order == "desc" ? "asc" : "desc" @order = order == "desc" ? "asc" : "desc"
respond_to do |format| respond_to do |format|
format.html format.html

View File

@ -36,7 +36,7 @@
<% if @show_all%> <% if @show_all%>
<input type="text" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName($(this),'<%= student_work_index_path(:homework => @homework.id)%>',event);"> <input type="text" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName($(this),'<%= student_work_index_path(:homework => @homework.id)%>',event);">
<a class="student_work_search fl" onclick="SearchByName_1($(this).prev(),'<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)">搜索</a> <a class="student_work_search fl" onclick="SearchByName_1($(this).prev(),'<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)">搜索</a>
<%= link_to "缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank" if @is_teacher%> <%= link_to "缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank" if @is_teacher && @homework.homework_type == 1 && @homework.homework_detail_manual.comment_status != 1 %>
<% end%> <% end%>
<% if @is_teacher%> <% if @is_teacher%>
<div class="fr"> <div class="fr">

View File

@ -863,6 +863,10 @@ function redo() {
window.location.reload() window.location.reload()
} }
function encodeHomeworkUrl(url){
var file = encodeURI(url).replace(/\+/g, '%2B');
return '/zipdown/download?file='+file;
}
//// 作业附件删除 //// 作业附件删除
$(function(){ $(function(){
@ -880,7 +884,7 @@ $(function(){
} }
if(res.length==1){ if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return; location.href = encodeHomeworkUrl(res[0].file);return;
} }
document.getElementById('light').style.display='block'; document.getElementById('light').style.display='block';
@ -893,7 +897,7 @@ $(function(){
} else { } else {
des = '第'+res[i].index+'个学生的作品下载'; des = '第'+res[i].index+'个学生的作品下载';
} }
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="/zipdown/download?file='+res[i].file+'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container); $('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="'+ encodeHomeworkUrl(res[i].file) +'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
} }
} }
@ -910,7 +914,7 @@ $(function(){
else else
{ {
if(res.length==1){ if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return; location.href = encodeHomeworkUrl(res[0].file);return;
} }
document.getElementById('light').style.display='block'; document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul'); $container = $('#light .upload_box_ul');
@ -922,7 +926,7 @@ $(function(){
} else { } else {
des = '第'+res[i].index+'个学生的作品下载'; des = '第'+res[i].index+'个学生的作品下载';
} }
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="/zipdown/download?file='+res[i].file+'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container); $('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="'+ encodeHomeworkUrl(res[i].file) +'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
} }
} }