课程成员列表excel导出
This commit is contained in:
parent
a07bb18dcb
commit
35dce16924
|
@ -340,14 +340,14 @@ class CoursesController < ApplicationController
|
|||
case @role
|
||||
when '1'
|
||||
@subPage_title = l :label_teacher_list
|
||||
@members = searchTeacherAndAssistant(@course)
|
||||
@members = paginateHelper @members, 10
|
||||
@all_members = searchTeacherAndAssistant(@course)
|
||||
@members = paginateHelper @all_members, 10
|
||||
when '2'
|
||||
@subPage_title = l :label_student_list
|
||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||
@members = student_homework_score(0,page, 10,"desc")
|
||||
@all_members = student_homework_score(0,page, 10,"desc")
|
||||
|
||||
@members = paginateHelper_for_members @members, 10
|
||||
@members = paginateHelper_for_members @all_members, 10
|
||||
|
||||
|
||||
end
|
||||
|
@ -357,7 +357,6 @@ class CoursesController < ApplicationController
|
|||
else
|
||||
format.html {render :layout => 'base_courses'}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# render :layout => 'base_courses'
|
||||
|
@ -367,6 +366,16 @@ class CoursesController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def export_course_member_excel
|
||||
@all_members = student_homework_score(0,0,0,"desc")
|
||||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "student_list_#{Time.now.strftime("%Y%m%d")}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def member_score_sort
|
||||
# @teachers= searchTeacherAndAssistant(@course)
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||
|
@ -924,4 +933,39 @@ class CoursesController < ApplicationController
|
|||
@results = paginateHelper @results, 10
|
||||
|
||||
end
|
||||
|
||||
def member_to_xls members,groups
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet1 = book.create_worksheet :name => "student"
|
||||
|
||||
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_homework_score)])
|
||||
count_row = 1
|
||||
group0 = CourseGroup.new();
|
||||
group0.id = 0;
|
||||
group0.name = l(:excel_member_with_out_class)
|
||||
groups_dup = groups.dup
|
||||
groups_dup << group0
|
||||
groups_dup.each do |group|
|
||||
sheet1[count_row,0] = l(:excel_class)
|
||||
sheet1[count_row,1] = group.name
|
||||
count_row += 1
|
||||
members.each do |member|
|
||||
if member.course_group_id == group.id
|
||||
sheet1[count_row,0]= member.user.id
|
||||
sheet1[count_row,1] = member.user.lastname.to_s + member.user.firstname.to_s
|
||||
sheet1[count_row,2] = member.user.login
|
||||
sheet1[count_row,3] = member.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = member.user.mail
|
||||
sheet1[count_row,5] = format("%0.2f",member.score.to_s)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
<%= submit_tag l(:label_search_member),:style => "float: left", :name => 'incourse',:onclick => "checkclass('group_name_0')",:class => "f_2"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= link_to l(:label_export_excel), export_course_member_excel_course_path(@course,:format => 'xls'),:class=>'xls'%>
|
||||
<% end %>
|
|
@ -2099,6 +2099,9 @@ zh:
|
|||
excel_t_score: 教师评分
|
||||
excel_n_score: 匿名评分
|
||||
excel_commit_time: 提交时间
|
||||
excel_homework_score: 作业积分
|
||||
excel_class: "班级:"
|
||||
excel_member_with_out_class: "未加入班级的学生"
|
||||
label_export_excel: 导出Excel
|
||||
|
||||
label_softapplication: 应用软件
|
||||
|
|
|
@ -641,6 +641,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'file', :action => 'file', :as => 'file'
|
||||
get 'feedback', :action => 'feedback', :as => 'course_feedback'
|
||||
get 'member', :controller => 'courses', :action => 'member', :as => 'member'
|
||||
get 'export_course_member_excel',:controller => 'courses',:action => 'export_course_member_excel'
|
||||
get 'member_score', :to => 'courses#member_score'
|
||||
post 'finishcourse'
|
||||
post 'restartcourse'
|
||||
|
|
|
@ -41,7 +41,16 @@ input.f_2 {
|
|||
.st_search{ margin:10px 0;}
|
||||
.st_search span{ font-size:14px; font-weight:bold; color:#606060; margin-right:35px;}
|
||||
.st_search input{ border:1px solid #1c9ec7; height:20px; width:200px;}
|
||||
a:hover.xls{ background: url('../images/icon_excel.gif') no-repeat scroll 1px 50% transparent !important;
|
||||
padding: 2px 0px 3px 16px;
|
||||
font-family:微软雅黑 !important;
|
||||
font-size: 12px !important;
|
||||
color: #136b3b !important;
|
||||
text-decoration: underline !important;
|
||||
font-weight:normal !important;
|
||||
}
|
||||
.st_search a:hover{ background:#048fbb; text-decoration:none;}
|
||||
|
||||
/*.st_search input.f_2{ background:#1c9ec7; padding: 3px; margin-left: 3px; color:#fff;border:1px solid #1c9ec7; text-align:center; display:block; width:45px; height:28px; font-size:12px; }*/
|
||||
|
||||
.classbox{ border:1px solid #f8df8c; background:#fffce6; color:#0d90c3; padding:0 3px; float:left; margin-left:15px;}
|
||||
|
|
|
@ -1432,10 +1432,11 @@ ul.contest-notification-list li span{
|
|||
word-break: break-all;
|
||||
}
|
||||
|
||||
a.xls {
|
||||
.xls {
|
||||
background: url('../images/icon_excel.gif') no-repeat scroll 1px 50% transparent;
|
||||
padding: 2px 0px 3px 16px;
|
||||
font-family:微软雅黑 !important;
|
||||
font-size: 12px !important;
|
||||
color: #136b3b !important;
|
||||
font-weight:normal !important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue