dev_course
SylorHuang 5 years ago
parent bd218764e9
commit c5baf84e85

@ -79,29 +79,7 @@ class ExercisesController < ApplicationController
unified_setting_ids = @exercises.unified_setting.where("exercise_status = #{choose_type}").pluck(:id) unified_setting_ids = @exercises.unified_setting.where("exercise_status = #{choose_type}").pluck(:id)
ex_ids = (ex_setting_ids + unified_setting_ids).uniq ex_ids = (ex_setting_ids + unified_setting_ids).uniq
@exercises = @exercises.where(id: ex_ids) @exercises = @exercises.where(id: ex_ids)
# @exercises = @exercises.unified_setting.where("exercise_status = #{choose_type}").or(@exercises.where(id:ex_setting_ids)).distinct
end end
# member_group_id = @current_student.first.try(:course_group_id).to_i
# if @is_teacher_or == 2 && member_group_id > 0
# exercise_groups_sets = @course.exercise_group_settings.where(course_group_id: member_group_id)
# .exercise_group_published
# exercise_settings_ids = exercise_groups_sets.pluck(:exercise_id)
# exercise_ended_ids = exercise_groups_sets.exercise_group_ended.pluck(:exercise_id).uniq
# if choose_type == 2
# @exercises = @exercises_all.exists? ?
# @exercises_all.exercise_by_status(2).unified_setting
# .or(@exercises_all.where(id: (exercise_settings_ids - exercise_ended_ids).uniq))
# : []
# elsif choose_type == 3
# @exercises = @exercises_all.exists? ?
# @exercises_all.exercise_by_status(3).unified_setting
# .or(@exercises_all.where(id: exercise_ended_ids))
# : []
# end
# else
# @exercises = @exercises.exercise_by_status(choose_type)
# end
end end
if params[:search].present? if params[:search].present?
@ -1342,7 +1320,8 @@ class ExercisesController < ApplicationController
def export_exercise def export_exercise
@request_url = request.base_url @request_url = request.base_url
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d_%H%M')}.pdf" filename_ = "#{@exercise.user.real_name}_#{@exercise.exercise_name}"
filename = Base64.urlsafe_encode64(filename_.strip.first(30))
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
end end

@ -456,9 +456,9 @@ class StudentWorksController < ApplicationController
@echart_data = student_efficiency(@homework, @work) @echart_data = student_efficiency(@homework, @work)
@myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id } @myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id }
@myself_consume = @echart_data[:consume_list].find { |item| item.last == @user.id } @myself_consume = @echart_data[:consume_list].find { |item| item.last == @user.id }
# filename = "实训报告_#{@shixun.name}_#{@use.real_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" #下载报错 unknown nil name,下面为修改的-hs-0606
filename = "实训报告_#{@shixun&.name}_#{@use&.real_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" filename_ = "实训报告_#{@shixun&.name}_#{@use&.real_name}"
filename = Base64.urlsafe_encode64(filename_.strip.first(30))
stylesheets = %w(shixun_work/shixun_work.css shared/codemirror.css) stylesheets = %w(shixun_work/shixun_work.css shared/codemirror.css)
render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets
end end

Loading…
Cancel
Save