instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.42k stars 2.42k forks source link

TeacherEnrollment's limit section privileges for a course is overwritten when observing a student in the same course but different section #2245

Open cgravatt opened 10 months ago

cgravatt commented 10 months ago

Summary:

The limit section privileges on a TeacherEnrollment for a course is overwritten when observing a student in the same course but different section. Even when the student's enrollment has limit section privileges.

Steps to reproduce:

  1. Enroll a teacher in a section of course with limit section privileges set to true
  2. Enroll a student in a different section of the same course with limit section privileges set to true
  3. Set up the teacher as an observer of the student (for example the teacher teaches a section of a course but has a son or daughter taking a different section of the same course)
  4. Confirm the teacher can now view all sections

Expected behavior:

The teacher can observer the student and only see their enrolled section

Actual behavior:

Teacher is no longer limited to section and can see all sections.

Additional notes:

cgravatt commented 10 months ago

I'm happy to contribute a PR to resolve this, but I'm not sure which direction would be preferred. I can see two possibilities.

Option 1: Update create_linked_enrollment_for(observer) to copy over the limit_section_privileges value so that ObserverEnrollments are created with a limit_section_privileges value that matches the student

Option 2: Update section_visibilities_for on the course model to exclude enrollments of type ObserverEnrollment from consideration.