缺评列表导出
This commit is contained in:
parent
156f2f9a2e
commit
c2e21f7a0c
|
@ -2,10 +2,11 @@ class StudentWorkController < ApplicationController
|
|||
layout "base_courses"
|
||||
include StudentWorkHelper
|
||||
require 'bigdecimal'
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty]
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
||||
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
|
||||
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
|
||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
||||
|
||||
def index
|
||||
@order,@b_sort,@name = params[:order] || "final_score",params[:sort] || "desc",params[:name] || ""
|
||||
|
@ -241,9 +242,8 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#评价列表显示
|
||||
#缺评列表显示
|
||||
def student_work_absence_penalty
|
||||
render_403 unless User.current.allowed_to?(:as_teacher,@course)
|
||||
order = params[:order] || "desc"
|
||||
if @homework.student_works.empty?
|
||||
@stundet_works = []
|
||||
|
@ -264,6 +264,34 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#导出缺评列表
|
||||
def absence_penalty_list
|
||||
if @homework.student_works.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@stundet_works = StudentWork.find_by_sql("SELECT * FROM (SELECT *,(all_count - has_count) AS absence FROM(
|
||||
SELECT * ,
|
||||
(SELECT evaluation_num FROM homework_detail_manuals WHERE homework_detail_manuals.homework_common_id = #{@homework.id}) AS all_count,
|
||||
(SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
|
||||
FROM `student_works`
|
||||
WHERE homework_common_id = #{@homework.id}
|
||||
) AS table_1) AS table_2
|
||||
where absence > 0 order by absence")
|
||||
end
|
||||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
#导出匿评列表
|
||||
def evaluation_list
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
#获取作业
|
||||
def find_homework
|
||||
|
@ -293,6 +321,10 @@ class StudentWorkController < ApplicationController
|
|||
render_403 unless (User.current.id == @work.user_id || User.current.admin?) && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||
end
|
||||
|
||||
def teacher_of_course
|
||||
render_403 unless User.current.allowed_to?(:as_teacher,@course)
|
||||
end
|
||||
|
||||
#根据条件过滤作业结果
|
||||
def search_homework_member homeworks,name
|
||||
name = name.downcase
|
||||
|
@ -302,6 +334,7 @@ class StudentWorkController < ApplicationController
|
|||
select_homework
|
||||
end
|
||||
|
||||
#作品列表转换为excel
|
||||
def homework_to_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
|
@ -328,4 +361,27 @@ class StudentWorkController < ApplicationController
|
|||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
|
||||
#缺评列表转换为excel
|
||||
def absence_penalty_list_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet1 = book.create_worksheet :name => "homework"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
|
||||
sheet1.row(0).concat([l(:excel_student_id),l(:excel_nickname),l(:excel_user_name),l(:lable_all_penalty),l(:lable_has_penalty),l(:lable_absence_penalty)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.user_extensions.student_id
|
||||
sheet1[count_row,1]=homework.user.login
|
||||
sheet1[count_row,2]=homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,3]=homework.all_count
|
||||
sheet1[count_row,4]=homework.has_count
|
||||
sheet1[count_row,5]=homework.absence
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
end
|
|
@ -71,6 +71,8 @@
|
|||
</div>
|
||||
|
||||
<%= link_to l(:label_list), student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<%= link_to "匿评", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<%= link_to "缺评", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr'%>
|
||||
<span class="mt3 fr " style="color:#136b3b;">导出全部:</span>
|
||||
</div>
|
||||
<% end%>
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
<a href="javascript:void(0)">姓名</a>
|
||||
</li>
|
||||
<li class="ml320">
|
||||
<a href="javascript:void(0)">应评</a>
|
||||
<a href="javascript:void(0)"><%= l(:lable_all_penalty)%></a>
|
||||
</li>
|
||||
<li class="ml30">
|
||||
<a href="javascript:void(0)">实评</a>
|
||||
<a href="javascript:void(0)"><%= l(:lable_has_penalty)%></a>
|
||||
</li>
|
||||
<li class="ml30">
|
||||
<%= link_to "缺评",student_work_absence_penalty_student_work_index_path(:homework => @homework.id,:order => @order)%>
|
||||
<%= link_to l(:lable_absence_penalty),student_work_absence_penalty_student_work_index_path(:homework => @homework.id,:order => @order)%>
|
||||
<a href="javascript:void(0);" class="<%= @order == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -2006,3 +2006,8 @@ zh:
|
|||
|
||||
error_upload_avatar_to_large: "超过大小限制 (%{max_size})"
|
||||
not_valid_image_file: 不是有效的图片文件
|
||||
|
||||
lable_all_penalty: 应评
|
||||
lable_has_penalty: 实评
|
||||
lable_absence_penalty: 缺评
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ RedmineApp::Application.routes.draw do
|
|||
post 'add_score_reply'
|
||||
get 'destroy_score_reply'
|
||||
get 'student_work_absence_penalty'
|
||||
get 'absence_penalty_list'
|
||||
get 'evaluation_list'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue