导出在线测验成绩列表
This commit is contained in:
parent
5b234580a8
commit
05f822a5c2
|
@ -376,6 +376,11 @@ class ExerciseController < ApplicationController
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
format.xls {
|
||||||
|
filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@exercise.exercise_name}#{l(:excel_exercise_list)}.xls"
|
||||||
|
send_data(exercise_to_xls(@exercise_users_list), :type => "text/excel;charset=utf-8; header=present",
|
||||||
|
:filename => filename_for_content_disposition(filename))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -603,6 +608,28 @@ class ExerciseController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
#测验列表转换为excel
|
||||||
|
def exercise_to_xls items
|
||||||
|
xls_report = StringIO.new
|
||||||
|
book = Spreadsheet::Workbook.new
|
||||||
|
sheet1 = book.create_worksheet :name => "exercise"
|
||||||
|
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||||
|
sheet1.row(0).default_format = blue
|
||||||
|
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_f_score),l(:excel_commit_time)])
|
||||||
|
count_row = 1
|
||||||
|
items.each do |exercise|
|
||||||
|
sheet1[count_row,0]=exercise.user.id
|
||||||
|
sheet1[count_row,1] = exercise.user.lastname.to_s + exercise.user.firstname.to_s
|
||||||
|
sheet1[count_row,2] = exercise.user.login
|
||||||
|
sheet1[count_row,3] = exercise.user.user_extensions.student_id
|
||||||
|
sheet1[count_row,4] = exercise.user.mail
|
||||||
|
sheet1[count_row,5] = exercise.score
|
||||||
|
sheet1[count_row,6] = format_time(exercise.created_at)
|
||||||
|
count_row += 1
|
||||||
|
end
|
||||||
|
book.write xls_report
|
||||||
|
xls_report.string
|
||||||
|
end
|
||||||
|
|
||||||
# ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个
|
# ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个
|
||||||
def get_exercise_user exercise_id,user_id
|
def get_exercise_user exercise_id,user_id
|
||||||
|
|
|
@ -5,29 +5,6 @@
|
||||||
$("#Container").css("width","1000px");
|
$("#Container").css("width","1000px");
|
||||||
});
|
});
|
||||||
|
|
||||||
// 匿评弹框提示
|
|
||||||
<%# if @is_evaluation && !@stundet_works.empty?%>
|
|
||||||
// $(function(){
|
|
||||||
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>');
|
|
||||||
// showModal('ajax-modal', '500px');
|
|
||||||
// $('#ajax-modal').siblings().remove();
|
|
||||||
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
|
||||||
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
|
||||||
// $('#ajax-modal').parent().css("top","").css("left","");
|
|
||||||
// $('#ajax-modal').parent().addClass("anonymos");
|
|
||||||
// });
|
|
||||||
<%# end%>
|
|
||||||
|
|
||||||
//设置评分规则
|
|
||||||
function set_score_rule(){
|
|
||||||
$('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework,:student_path => true}) %>');
|
|
||||||
showModal('ajax-modal', '350px');
|
|
||||||
$('#ajax-modal').siblings().remove();
|
|
||||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
|
||||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
|
||||||
$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed");
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$("#homework_info_hidden").click(function(){
|
$("#homework_info_hidden").click(function(){
|
||||||
$("#homeworkInformation").hide();
|
$("#homeworkInformation").hide();
|
||||||
|
@ -84,6 +61,20 @@
|
||||||
<!---menu_r end--->
|
<!---menu_r end--->
|
||||||
</div>
|
</div>
|
||||||
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
|
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
|
||||||
|
<% if @is_teacher%>
|
||||||
|
<div class="fr mt5">
|
||||||
|
<ul class="resourcesSelect">
|
||||||
|
<li class="resourcesSelected">
|
||||||
|
<a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||||
|
<ul class="hworkMenu">
|
||||||
|
<li>
|
||||||
|
<%= link_to "导出测验成绩", student_exercise_list_exercise_path(@exercise.id,:course_id => @course.id, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end%>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1871,6 +1871,7 @@ zh:
|
||||||
excel_been_rated: 已评
|
excel_been_rated: 已评
|
||||||
excel_not_rated: 未评
|
excel_not_rated: 未评
|
||||||
label_export_excel: 导出列表
|
label_export_excel: 导出列表
|
||||||
|
excel_exercise_list: 测验成绩列表
|
||||||
|
|
||||||
label_softapplication: 应用软件
|
label_softapplication: 应用软件
|
||||||
label_attending_contest: 参加竞赛
|
label_attending_contest: 参加竞赛
|
||||||
|
|
Loading…
Reference in New Issue