Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lms): do not add observers or mentors as students #57970

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard/lib/policies/lti.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module AccessTokenScopes
]
).freeze
CONTEXT_LEARNER_ROLE = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'.freeze
CONTEXT_MENTOR_ROLE = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Mentor'.freeze
LTI_ROLES_KEY = 'https://purl.imsglobal.org/spec/lti/claim/roles'.freeze
LTI_CUSTOM_CLAIMS = "https://purl.imsglobal.org/spec/lti/claim/custom".freeze
LTI_CONTEXT_CLAIM = "https://purl.imsglobal.org/spec/lti/claim/context".freeze
Expand Down
2 changes: 1 addition & 1 deletion dashboard/lib/services/lti.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def self.parse_nrps_response(nrps_response, issuer)
members = nrps_response[:members]
context_title = nrps_response.dig(:context, :title)
members.each do |member|
next if member[:status] == 'Inactive'
next if member[:status] == 'Inactive' || member[:roles].include?(Policies::Lti::CONTEXT_MENTOR_ROLE)
# TODO: handle multiple messages. Shouldn't be needed until we support Deep Linking.

# If the LMS hasn't implemented the resource link level membership service, we don't get the message property in the member object
Expand Down
35 changes: 35 additions & 0 deletions dashboard/test/lib/services/lti_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Services::LtiTest < ActiveSupport::TestCase
]
@lti_integration = create :lti_integration
@student_role = Policies::Lti::CONTEXT_LEARNER_ROLE
@observer_role = Policies::Lti::CONTEXT_MENTOR_ROLE
@teacher_role = Policies::Lti::TEACHER_ROLES.first

@id_token = {
Expand Down Expand Up @@ -58,6 +59,19 @@ class Services::LtiTest < ActiveSupport::TestCase
}],
}.deep_symbolize_keys

@nrps_observer = {
status: 'Active',
user_id: SecureRandom.uuid,
roles: [@observer_role],
message: [{
@custom_claims_key => {
display_name: 'parent',
full_name: 'Test Parent',
email: 'test-parent@code.org'
}
}],
}.deep_symbolize_keys

@course_name = 'Test Course'
@lms_section_ids = [1, 2, 3]
@lms_section_names = ['Section 1', 'Section 2', 'Section 3']
Expand Down Expand Up @@ -133,6 +147,27 @@ class Services::LtiTest < ActiveSupport::TestCase
}
]
},
{
status: "Active",
user_id: "observer-0",
roles: [Policies::Lti::CONTEXT_MENTOR_ROLE],
message: [
{
'https://purl.imsglobal.org/spec/lti/claim/message_type': "LtiResourceLinkRequest",
locale: "en",
'https://purl.imsglobal.org/spec/lti/claim/custom': {
email: "parent-0@code.org",
course_id: "115",
full_name: "Parent Zero",
given_name: "Test",
family_name: "Zero",
section_ids: @lms_section_ids.join(','),
display_name: "Test Zero",
section_names: @lms_section_names.to_s
},
}
]
},
{
status: "Active",
user_id: SecureRandom.uuid,
Expand Down