This commit is contained in:
alan 2014-12-31 10:23:36 +08:00
commit 7a727bfed7
8 changed files with 73 additions and 10 deletions

View File

@ -1049,7 +1049,7 @@ class BidsController < ApplicationController
@totle_size = 0
@bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count}
@cur_size = 0
@bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.rater_id is_teacher_score = 0").count}
@bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count}
end
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
respond_to do |format|

View File

@ -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 => "#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}.xls")
}
end
end
def member_score_sort
# @teachers= searchTeacherAndAssistant(@course)
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@ -960,4 +969,39 @@ GROUP BY members.user_id ORDER BY score #{score_sort_by}"
@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.nil? ? 0:member.score.to_s)
count_row += 1
end
end
end
book.write xls_report
xls_report.string
end
end

View File

@ -31,7 +31,7 @@ class HomeworkAttachController < ApplicationController
format.js
format.xls {
send_data(homework_to_xls(@all_homework_list), :type => "text/excel;charset=utf-8; header=present",
:filename => "not_rated_homework_#{Time.now.strftime("%Y%m%d")}.xls")
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls")
}
end
end
@ -61,7 +61,7 @@ class HomeworkAttachController < ApplicationController
format.js
format.xls {
send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present",
:filename => "been_rated_homework_#{Time.now.strftime("%Y%m%d")}.xls")
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls")
}
end
end
@ -92,7 +92,7 @@ class HomeworkAttachController < ApplicationController
format.js
format.xls {
send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present",
:filename => "all_homework_#{Time.now.strftime("%Y%m%d")}.xls")
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls")
}
end
end

View File

@ -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 %>

View File

@ -2099,6 +2099,13 @@ zh:
excel_t_score: 教师评分
excel_n_score: 匿名评分
excel_commit_time: 提交时间
excel_homework_score: 作业积分
excel_class: "班级:"
excel_member_with_out_class: "未加入班级的学生"
excel_member_list: 成员列表
excel_homework_list: 作品列表
excel_been_rated: 已评
excel_not_rated: 未评
label_export_excel: 导出Excel
label_softapplication: 应用软件

View File

@ -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'

View File

@ -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;}

View File

@ -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;
}