Skip to content

Commit 2ff2b13

Browse files
author
Dan Minkevitch
committed
Shows the option to remove a student from the course
fixes CNVS-22983 Test Plan: * Go to a course with students * As a teacher, click the item cog to open the dropdown for a student * You should see the option to remove them from the course if the student was manually enrolled by the teacher. * The option should also be visible if your user has admin permission and the student was enrolled via sis * The option should be hidden if your user has default teacher permissions and the student was enrolled via sis Change-Id: Icfacc377edcb82b5c4aeddab6b20e47d1f0e7f70 Reviewed-on: https://gerrit.instructure.com/62627 Reviewed-by: Jon Willesen <jonw@instructure.com> Tested-by: Jenkins QA-Review: Charles Kimball <ckimball@instructure.com> Product-Review: Dan Minkevitch <dan@instructure.com>
1 parent 8778f80 commit 2ff2b13

4 files changed

Lines changed: 7 additions & 12 deletions

File tree

app/coffeescripts/bundles/roster.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require [
3737
], (I18n, {Model}, CreateUserList, Role, CreateUsersView, RoleSelectView, rosterUsersTemplate, RosterUserCollection, RolesCollection, SectionCollection, GroupCategoryCollection, InputFilterView, PaginatedCollectionView, RosterUserView, RosterView, RosterTabsView, ResendInvitationsView, $) ->
3838

3939
fetchOptions =
40-
include: ['avatar_url', 'enrollments', 'email', 'observed_users']
40+
include: ['avatar_url', 'enrollments', 'email', 'observed_users', 'can_be_removed']
4141
per_page: 50
4242
users = new RosterUserCollection null,
4343
course_id: ENV.context_asset_string.split('_')[1]

app/coffeescripts/views/courses/roster/RosterUserView.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ define [
5050
json.url = "#{ENV.COURSE_ROOT_URL}/users/#{@model.get('id')}"
5151
json.isObserver = @model.hasEnrollmentType('ObserverEnrollment')
5252
json.isPending = @model.pending(@model.currentRole)
53-
json.canRemoveStudents = ENV.permissions.manage_students and _.all @model.get('enrollments'), (e) -> !e.sis_source_id
53+
json.canRemoveStudents = ENV.permissions.manage_students and _.any @model.get('enrollments'), (e) -> e.can_be_removed
5454
json.canEditSections = not _.isEmpty @model.sectionEditableEnrollments()
5555
json.canLinkStudents = json.isObserver && !ENV.course.concluded
5656
json.canViewLoginIdColumn = ENV.permissions.manage_admin_users or ENV.permissions.manage_students

lib/api/v1/user.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ def enrollment_json(enrollment, user, session, includes = [], opts = {})
222222
if includes.include?('observed_users') && enrollment.observer? && enrollment.associated_user && !enrollment.associated_user.deleted?
223223
json[:observed_user] = user_json(enrollment.associated_user, user, session, user_includes, @context, enrollment.associated_user.not_ended_enrollments.all_student.shard(enrollment).where(:course_id => enrollment.course_id))
224224
end
225+
if includes.include?('can_be_removed')
226+
json[:can_be_removed] = (!enrollment.defined_by_sis? || context.grants_right?(@current_user, session, :manage_account_settings)) &&
227+
enrollment.can_be_deleted_by(@current_user, @context, session)
228+
end
225229
end
226230
end
227231

spec/selenium/people_spec.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ def create_student_group(group_text = "new student group")
3131
expect(f('#category_list')).to include_text(group_text)
3232
end
3333

34-
def enroll_student(student, sis_source_id: nil)
34+
def enroll_student(student)
3535
e1 = @course.enroll_student(student)
3636
e1.workflow_state = 'active'
37-
e1.sis_source_id = sis_source_id if sis_source_id
3837
e1.save!
3938
@course.reload
4039
end
@@ -82,10 +81,6 @@ def open_dropdown_menu(selector: nil, option: nil, displayed: true)
8281

8382
enroll_student(@student_1)
8483

85-
#add second student as if enrolled via SIS
86-
@sis_student = create_user('sis_student@test.com')
87-
enroll_student(@sis_student, sis_source_id: 'oh hai')
88-
8984
#adding users for tests to work correctly
9085

9186
#teacher user
@@ -113,10 +108,6 @@ def open_dropdown_menu(selector: nil, option: nil, displayed: true)
113108
open_dropdown_menu(option: 'removeFromCourse')
114109
end
115110

116-
it "should not display the option to remove a student if enrolled via SIS" do
117-
open_dropdown_menu(selector: '.rosterUser:nth-child(2)', option: 'removeFromCourse', displayed: false)
118-
end
119-
120111
it "should display activity report on clicking Student Interaction button", priority: "1", test_id: 244446 do
121112
fln("Student Interactions Report").click
122113
wait_for_ajaximations

0 commit comments

Comments
 (0)