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