|
|
|
@ -376,6 +376,11 @@ class ExerciseController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@ -603,6 +608,28 @@ class ExerciseController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个
|
|
|
|
|
def get_exercise_user exercise_id,user_id
|
|
|
|
|