dev_course
SylorHuang 6 years ago
parent b7b5821f93
commit bd218764e9

@ -64,22 +64,23 @@ class ExercisesController < ApplicationController
if params[:type].present?
choose_type = params[:type].to_i
ex_setting_ids = []
case choose_type
when 1
ex_setting_ids = @course.exercise_group_settings.exercise_group_not_published.pluck(:exercise_id)
# @exercises = @exercises.where("exercise_status = #{choose_type}").or(@exercises.where(id:ex_setting_ids))
when 2
ex_setting_ids = @course.exercise_group_settings.where("publish_time is not null and publish_time <= ? and end_time > ?",Time.now,Time.now).pluck(:exercise_id)
# @exercises = @exercises.where("exercise_status = #{choose_type}").or(@exercises.where(id:ex_published_groups))
when 3
ex_setting_ids = @course.exercise_group_settings.exercise_group_ended.pluck(:exercise_id)
# @exercises = @exercises.where("exercise_status = #{choose_type}").or(@exercises.where(id:ex_ended_groups))
if @is_teacher_or != 2
@exercises = @exercises.where("exercise_status = #{choose_type}")
else
case choose_type
when 1
ex_setting_ids = @course.exercise_group_settings.where("course_group_id = #{@member_group_id}").exercise_group_not_published.pluck(:exercise_id)
when 2
ex_setting_ids = @course.exercise_group_settings.where("course_group_id = #{@member_group_id}")
.where("publish_time is not null and publish_time <= ? and end_time > ?",Time.now,Time.now).pluck(:exercise_id)
when 3
ex_setting_ids = @course.exercise_group_settings.where("course_group_id = #{@member_group_id}").exercise_group_ended.pluck(:exercise_id)
end
unified_setting_ids = @exercises.unified_setting.where("exercise_status = #{choose_type}").pluck(:id)
ex_ids = (ex_setting_ids + unified_setting_ids).uniq
@exercises = @exercises.where(id: ex_ids)
# @exercises = @exercises.unified_setting.where("exercise_status = #{choose_type}").or(@exercises.where(id:ex_setting_ids)).distinct
end
@exercises = @exercises.unified_setting.where("exercise_status = #{choose_type}").or(@exercises.where(id:ex_setting_ids)).distinct
# member_group_id = @current_student.first.try(:course_group_id).to_i
# if @is_teacher_or == 2 && member_group_id > 0

Loading…
Cancel
Save