作业全部附件打包下周无法下载

This commit is contained in:
sw 2015-05-28 10:47:40 +08:00
parent ff4dae56d1
commit b182feb988
2 changed files with 25 additions and 2 deletions

View File

@ -42,7 +42,7 @@
<%= link_to "附件", "javascript:void(0)", class: "down_btn fr", :onclick => "alert('没有学生提交作业,无法下载附件')" %>
<% else%>
<%= link_to "附件", zipdown_assort_path(obj_class: @homework.class, obj_id: @homework, format: :json),
remote: true, class: "down_btn fr" %>
remote: true, class: "down_btn fr", :id => "download_homework_attachments" %>
<% end%>
<a class="down_btn fr" href="javascript:void(0);">列表</a>

View File

@ -897,8 +897,31 @@ $(function(){
}
}
});
$('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) {
if(status == 'success'){
var res = JSON.parse(data.responseText);
if(res.length<1){
return;
}
if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return;
}
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
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);
})
}
}
});
});