From 05f822a5c212036db3dd9c15a404888cd402355d Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Jan 2016 16:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=9C=A8=E7=BA=BF=E6=B5=8B?= =?UTF-8?q?=E9=AA=8C=E6=88=90=E7=BB=A9=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 27 ++++++++++++++ .../exercise/student_exercise_list.html.erb | 37 +++++++------------ config/locales/zh.yml | 1 + 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index a3e4f89c3..1bc160592 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -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 diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 2e51d61af..c96f8156a 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -5,29 +5,6 @@ $("#Container").css("width","1000px"); }); - // 匿评弹框提示 - <%# if @is_evaluation && !@stundet_works.empty?%> - // $(function(){ - // $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>'); - // showModal('ajax-modal', '500px'); - // $('#ajax-modal').siblings().remove(); - // $('#ajax-modal').before("" + - // ""); - // $('#ajax-modal').parent().css("top","").css("left",""); - // $('#ajax-modal').parent().addClass("anonymos"); - // }); - <%# end%> - - //设置评分规则 - function set_score_rule(){ - $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework,:student_path => true}) %>'); - showModal('ajax-modal', '350px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before("" + - ""); - $('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); - } - $(function(){ $("#homework_info_hidden").click(function(){ $("#homeworkInformation").hide(); @@ -84,6 +61,20 @@ + <% if @is_teacher%> +
+ +
+ <% end%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e4a23373d..24e7179b7 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1871,6 +1871,7 @@ zh: excel_been_rated: 已评 excel_not_rated: 未评 label_export_excel: 导出列表 + excel_exercise_list: 测验成绩列表 label_softapplication: 应用软件 label_attending_contest: 参加竞赛