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