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