|
|
|
@ -1224,7 +1224,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
def member_to_xls homeworks, course, members,groups
|
|
|
|
|
xls_report = StringIO.new
|
|
|
|
|
book = Spreadsheet::Workbook.new
|
|
|
|
|
sheet1 = book.create_worksheet :name => "student"
|
|
|
|
|
sheet1 = book.create_worksheet :name => "总成绩"
|
|
|
|
|
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_class),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
@ -1268,6 +1268,121 @@ class CoursesController < ApplicationController
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
homeworks.each_with_index do |home, i|
|
|
|
|
|
sheet = book.create_worksheet :name => "第#{i+1}次作业"
|
|
|
|
|
sheet[0,0] = "课程编号"
|
|
|
|
|
sheet[0,1] = course.id
|
|
|
|
|
sheet[1,0] = "课程学期"
|
|
|
|
|
sheet[1,1] = course.time.to_s+"年"+course.term
|
|
|
|
|
sheet[2,0] = "课程名称"
|
|
|
|
|
sheet[2,1] = course.name
|
|
|
|
|
sheet[3,0] = "教师团队"
|
|
|
|
|
sheet[3,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_name}.join('、')
|
|
|
|
|
sheet[4,0] = "主讲教师"
|
|
|
|
|
sheet[4,1] = course.teacher.show_name
|
|
|
|
|
sheet[4,0] = "作业批次"
|
|
|
|
|
sheet[4,1] = "第#{i+1}次作业"
|
|
|
|
|
sheet[4,0] = "作业名称"
|
|
|
|
|
sheet[4,1] = home.name
|
|
|
|
|
if home.homework_type == 1 #普通作业
|
|
|
|
|
if home.anonymous_comment ==0
|
|
|
|
|
sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des),
|
|
|
|
|
l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
|
else
|
|
|
|
|
sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des),
|
|
|
|
|
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
|
end
|
|
|
|
|
count_row = 6
|
|
|
|
|
items = home.student_works.order("work_score desc")
|
|
|
|
|
items.each_with_index do |stu, j|
|
|
|
|
|
sheet[count_row,0]= j + 1
|
|
|
|
|
sheet[count_row,1] = stu.user.show_name
|
|
|
|
|
sheet[count_row,2] = stu.user.login
|
|
|
|
|
sheet[count_row,3] = stu.user.user_extensions.student_id
|
|
|
|
|
sheet[count_row,4] = stu.name
|
|
|
|
|
sheet[count_row,5] = strip_html stu.description
|
|
|
|
|
sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2)
|
|
|
|
|
sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2)
|
|
|
|
|
if home.anonymous_comment ==0
|
|
|
|
|
sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2)
|
|
|
|
|
sheet[count_row,9] = stu.absence_penalty
|
|
|
|
|
sheet[count_row,10] = stu.late_penalty
|
|
|
|
|
sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
|
|
|
|
|
sheet[count_row,12] = format_time(stu.created_at)
|
|
|
|
|
else
|
|
|
|
|
sheet[count_row,8] = stu.late_penalty
|
|
|
|
|
sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
|
|
|
|
|
sheet[count_row,10] = format_time(stu.created_at)
|
|
|
|
|
end
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
elsif home.homework_type == 2 #编程作业
|
|
|
|
|
if home.anonymous_comment ==0
|
|
|
|
|
sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des),
|
|
|
|
|
l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
|
else
|
|
|
|
|
sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des),
|
|
|
|
|
l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
|
end
|
|
|
|
|
count_row = 6
|
|
|
|
|
items = home.student_works.order("work_score desc")
|
|
|
|
|
items.each_with_index do |stu, j|
|
|
|
|
|
sheet[count_row,0]= j + 1
|
|
|
|
|
sheet[count_row,1] = stu.user.show_name
|
|
|
|
|
sheet[count_row,2] = stu.user.login
|
|
|
|
|
sheet[count_row,3] = stu.user.user_extensions.student_id
|
|
|
|
|
sheet[count_row,4] = stu.name
|
|
|
|
|
sheet[count_row,5] = stu.description
|
|
|
|
|
sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2)
|
|
|
|
|
sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2)
|
|
|
|
|
sheet[count_row,8] = stu.system_score.nil? ? l(:label_without_score) : stu.system_score.round(2)
|
|
|
|
|
if home.anonymous_comment ==0
|
|
|
|
|
sheet[count_row,9] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2)
|
|
|
|
|
sheet[count_row,10] = stu.absence_penalty
|
|
|
|
|
sheet[count_row,11] = stu.late_penalty
|
|
|
|
|
sheet[count_row,12] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
|
|
|
|
|
sheet[count_row,13] = format_time(stu.created_at)
|
|
|
|
|
else
|
|
|
|
|
sheet[count_row,9] = stu.late_penalty
|
|
|
|
|
sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
|
|
|
|
|
sheet[count_row,11] = format_time(stu.created_at)
|
|
|
|
|
end
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
elsif home.homework_type == 3 #分组作业
|
|
|
|
|
if home.anonymous_comment ==0
|
|
|
|
|
sheet.row(5).concat([l(:excel_rank),l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des),
|
|
|
|
|
l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
|
else
|
|
|
|
|
sheet.row(5).concat([l(:excel_rank),l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des),
|
|
|
|
|
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
|
|
|
|
|
end
|
|
|
|
|
count_row = 6
|
|
|
|
|
items = home.student_works.order("work_score desc")
|
|
|
|
|
items.each_with_index do |stu, j|
|
|
|
|
|
sheet[count_row,0] = j + 1
|
|
|
|
|
sheet[count_row,1] = get_group_member_names stu
|
|
|
|
|
sheet[count_row,2] = stu.name
|
|
|
|
|
sheet[count_row,3] = (stu.project_id == 0 || stu.project_id.nil?) ? l(:excel_no_project) : stu.project.name
|
|
|
|
|
sheet[count_row,4] = strip_html stu.description
|
|
|
|
|
sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2)
|
|
|
|
|
sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2)
|
|
|
|
|
if home.anonymous_comment ==0
|
|
|
|
|
sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2)
|
|
|
|
|
sheet[count_row,8] = stu.absence_penalty
|
|
|
|
|
sheet[count_row,9] = stu.late_penalty
|
|
|
|
|
sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
|
|
|
|
|
sheet[count_row,11] = format_time(stu.created_at)
|
|
|
|
|
else
|
|
|
|
|
sheet[count_row,7] = stu.late_penalty
|
|
|
|
|
sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2)
|
|
|
|
|
sheet[count_row,9] = format_time(stu.created_at)
|
|
|
|
|
end
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
group0 = CourseGroup.new();
|
|
|
|
|
group0.id = 0;
|
|
|
|
|