|
|
@ -6,12 +6,9 @@ class ZipsController < ApplicationController
|
|
|
|
before_action :require_admin_or_teacher
|
|
|
|
before_action :require_admin_or_teacher
|
|
|
|
|
|
|
|
|
|
|
|
def shixun_report
|
|
|
|
def shixun_report
|
|
|
|
# student_work_ids = Array.wrap(params[:student_work_ids])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# service = BatchExportShixunReportService.new(@homework, @student_work_ids)
|
|
|
|
|
|
|
|
service = BatchExportShixunReportService.new(@homework, @all_student_works)
|
|
|
|
service = BatchExportShixunReportService.new(@homework, @all_student_works)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filename = filename_for_content_disposition(service.filename)
|
|
|
|
filename = filename_for_content_disposition(service.filename)
|
|
|
|
send_file service.zip, filename: filename, type: 'application/zip'
|
|
|
|
send_file service.zip, filename: filename, type: 'application/zip'
|
|
|
|
rescue BatchExportShixunReportService::Error => ex
|
|
|
|
rescue BatchExportShixunReportService::Error => ex
|
|
|
@ -23,8 +20,8 @@ class ZipsController < ApplicationController
|
|
|
|
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
|
|
|
|
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
|
|
|
|
|
|
|
|
|
|
|
|
file_name = filename_for_content_disposition(exercises.filename)
|
|
|
|
file_name = filename_for_content_disposition(exercises.filename)
|
|
|
|
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
normal_status(-1, e.message)
|
|
|
|
normal_status(-1, e.message)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -44,7 +41,7 @@ class ZipsController < ApplicationController
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
|
|
|
|
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
|
|
|
|
@exercise_status = @exercise.get_exercise_status(current_user.id)
|
|
|
|
@exercise_status = @exercise.present? ? @exercise.get_exercise_status(current_user.id) : 1
|
|
|
|
group_id = params[:exercise_group_id]
|
|
|
|
group_id = params[:exercise_group_id]
|
|
|
|
if @exercise.blank?
|
|
|
|
if @exercise.blank?
|
|
|
|
normal_status(-1,"试卷不存在")
|
|
|
|
normal_status(-1,"试卷不存在")
|
|
|
@ -101,34 +98,40 @@ class ZipsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
def load_homework
|
|
|
|
def load_homework
|
|
|
|
@homework = HomeworkCommon.find(params[:homework_common_id])
|
|
|
|
@homework = HomeworkCommon.find(params[:homework_common_id])
|
|
|
|
|
|
|
|
@homework_status = @homework.present? ? @homework.homework_detail_manual.comment_status : 0
|
|
|
|
|
|
|
|
if @homework.blank?
|
|
|
|
|
|
|
|
normal_status(-1,"该作业不存在")
|
|
|
|
|
|
|
|
elsif @homework_status == 0
|
|
|
|
|
|
|
|
normal_status(-1,"该作业未发布")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@course = @homework.course
|
|
|
|
|
|
|
|
##7。2 -hs新增
|
|
|
|
|
|
|
|
@member = @course.course_member(current_user.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@all_student_works = @homework.teacher_works(@member).where("work_status > 0")
|
|
|
|
|
|
|
|
work_status = params[:work_status]
|
|
|
|
|
|
|
|
group_id = params[:course_group]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if work_status.present?
|
|
|
|
|
|
|
|
@all_student_works = @all_student_works.where(work_status:work_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if group_id.present?
|
|
|
|
|
|
|
|
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
|
|
|
|
|
|
|
|
@all_student_works = @all_student_works.where(user_id: group_user_ids)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@course = @homework.course
|
|
|
|
unless params[:search].blank?
|
|
|
|
##7。2 -hs新增
|
|
|
|
@all_student_works = @all_student_works.joins(user: :user_extension).where("concat(lastname, firstname) like ?
|
|
|
|
@member = @course.course_member(current_user.id)
|
|
|
|
|
|
|
|
@all_student_works = @homework.teacher_works(@member).where("work_status > 0")
|
|
|
|
|
|
|
|
work_status = params[:work_status]
|
|
|
|
|
|
|
|
group_id = params[:course_group]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if work_status.present?
|
|
|
|
|
|
|
|
@all_student_works = @all_student_works.where(work_status:work_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if group_id.present?
|
|
|
|
|
|
|
|
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
|
|
|
|
|
|
|
|
@all_student_works = @all_student_works.where(user_id: group_user_ids)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unless params[:search].blank?
|
|
|
|
|
|
|
|
@all_student_works = @all_student_works.joins(user: :user_extension).where("concat(lastname, firstname) like ?
|
|
|
|
|
|
|
|
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
|
|
|
|
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
student_work_sizes = @all_student_works&.size
|
|
|
|
student_work_sizes = @all_student_works&.size
|
|
|
|
if student_work_sizes.blank? || student_work_sizes == 0
|
|
|
|
if student_work_sizes.blank? || student_work_sizes == 0
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
elsif student_work_sizes > 100
|
|
|
|
elsif student_work_sizes > 100
|
|
|
|
normal_status(-2,"100")
|
|
|
|
normal_status(-2,"100")
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|