Skip to content

Commit bf2df99

Browse files
authored
Merge pull request #2326 from openstax/fix_missing_teacher_exercises
Fix missing teacher exercises
2 parents 8d34f30 + 32e8319 commit bf2df99

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/routines/get_page_exercise_ids_by_pool_types.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def exec(ecosystem: nil, course: nil, page_ids: nil, exercise_ids: nil, pool_typ
2828
page_ids = page_ids.map(&:to_i)
2929
ecosystem.pages.select { |page| page_ids.include? page.id }
3030
else
31-
ecosystem.pages.select(*pool_method_name_by_pool_type.values).where(id: page_ids)
31+
ecosystem.pages.select(:id, *pool_method_name_by_pool_type.values).where(id: page_ids)
3232
end
3333

3434
# Build map of pool types to pools
@@ -45,9 +45,11 @@ def exec(ecosystem: nil, course: nil, page_ids: nil, exercise_ids: nil, pool_typ
4545
# Add teacher-created exercises if course is provided
4646
return if course.nil?
4747

48-
teacher_exercise_ids = Content::Models::Exercise.where(
48+
teacher_exercises = Content::Models::Exercise.where(
4949
content_page_id: pages.map(&:id), user_profile_id: course.related_teacher_profile_ids
50-
).pluck(:id)
50+
)
51+
teacher_exercises = teacher_exercises.where(id: exercise_ids) unless exercise_ids.nil?
52+
teacher_exercise_ids = teacher_exercises.pluck(:id)
5153

5254
(pool_types - [ :reading_context, :reading_dynamic ]).each do |pool_type|
5355
outputs.exercise_ids_by_pool_type[pool_type].concat teacher_exercise_ids

0 commit comments

Comments
 (0)