匿评列表导出Excel
This commit is contained in:
parent
d7d87c6999
commit
fa31fe421b
|
@ -282,14 +282,19 @@ class StudentWorkController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls")
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_absence_list)}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
#导出匿评列表
|
||||
def evaluation_list
|
||||
|
||||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(evaluation_list_xls(@homework.student_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_evaluation_list)}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -373,15 +378,43 @@ class StudentWorkController < ApplicationController
|
|||
sheet1.row(0).concat([l(:excel_student_id),l(:excel_nickname),l(:excel_user_name),l(:lable_all_penalty),l(:lable_has_penalty),l(:lable_absence_penalty)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.user_extensions.student_id
|
||||
sheet1[count_row,1]=homework.user.login
|
||||
sheet1[count_row,2]=homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,3]=homework.all_count
|
||||
sheet1[count_row,4]=homework.has_count
|
||||
sheet1[count_row,5]=homework.absence
|
||||
sheet1[count_row,0] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,1] = homework.user.login
|
||||
sheet1[count_row,2] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,3] = homework.all_count
|
||||
sheet1[count_row,4] = homework.has_count
|
||||
sheet1[count_row,5] = homework.absence
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
|
||||
#匿评列表转换为excel
|
||||
def evaluation_list_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet1 = book.create_worksheet :name => "homework"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
|
||||
sheet1.row(0).concat([l(:label_work_name),l(:label_work_id),l(:label_work_autor),l(:label_evaluation_id),l(:label_evaluation_name),
|
||||
l(:label_evaluation_score),l(:label_evaluation_common),l(:label_evaluation_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
homework.student_works_scores.where(:reviewer_role => 3).each do |score|
|
||||
sheet1[count_row,0] = homework.name
|
||||
sheet1[count_row,1] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,2] = homework.user.show_name
|
||||
sheet1[count_row,3] = score.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = score.user.show_name
|
||||
sheet1[count_row,5] = score.score
|
||||
sheet1[count_row,6] = score.comment
|
||||
sheet1[count_row,7] = format_time(score.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
end
|
|
@ -71,7 +71,7 @@
|
|||
</div>
|
||||
|
||||
<%= link_to l(:label_list), student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<%= link_to "匿评", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<%= link_to "匿评", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<%= link_to "缺评", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<span class="mt3 fr " style="color:#136b3b;">导出全部:</span>
|
||||
</div>
|
||||
|
|
|
@ -1820,6 +1820,8 @@ zh:
|
|||
excel_member_with_out_class: "未加入班级的学生"
|
||||
excel_member_list: 成员列表
|
||||
excel_homework_list: 作品列表
|
||||
excel_absence_list: 缺评列表
|
||||
excel_evaluation_list: 匿评列表
|
||||
excel_been_rated: 已评
|
||||
excel_not_rated: 未评
|
||||
label_export_excel: 导出列表
|
||||
|
@ -2011,3 +2013,14 @@ zh:
|
|||
lable_has_penalty: 实评
|
||||
lable_absence_penalty: 缺评
|
||||
|
||||
label_work_name: 作品名称
|
||||
label_work_autor: 作品提交者
|
||||
label_work_id: 提交者学号
|
||||
label_evaluation_id: 匿评者学号
|
||||
label_evaluation_name: 匿评者
|
||||
label_evaluation_score: 匿评分数
|
||||
label_evaluation_common: 匿评评语
|
||||
label_evaluation_time: 匿评时间
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue