Skip to content

Commit

Permalink
For LTI 1.3 only consider roles in the context for automatically crea…
Browse files Browse the repository at this point in the history
…ted users.

This is to fix the issue discussed in
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=8565#p21514.

If someone needs the institution roles, then the new
$LTI{v1p3}{AllowInstitutionRoles} option defined in conf/authen_LTI_1_3
can be set to 1, and then those roles will also be considered.
  • Loading branch information
drgrice1 committed Oct 18, 2024
1 parent 6d96fda commit d6ba13c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions conf/authen_LTI_1_3.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ $LTI{v1p3}{LMSrolesToWeBWorKroles} = {
'Grader' => 'ta',
};

# The LMS reports roles context (or membership), instititution, and system
# roles. WeBWorK always ignores system roles, and also ignores institution
# roles by default. In some cases you may also want to consider institution
# roles. In that case set the following to 1.
$LTI{v1p3}{AllowInstitutionRoles} = 0;

################################################################################################
# Local routine to modify users
################################################################################################
Expand Down
9 changes: 7 additions & 2 deletions lib/WeBWorK/Authen/LTIAdvantage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,15 @@ sub create_user ($self) {
# Determine the roles defined for this user defined in the LTI request and assign a permission level on that basis.
my @LTIroles = @{ $self->{roles} };

# Restrict to institution and context roles and remove the purl link portion (ignore system roles).
# Restrict to context roles and remove the purl link portion. System roles are always ignored, but institution
# roles are also included if $LTI{v1p3}{AllowInstitutionRoles} = 1.
@LTIroles =
map {s|^[^#]*#||r}
grep {m!^http://purl.imsglobal.org/vocab/lis/v2/(membership|institution\/person)#!} @LTIroles;
grep {
m!^http://purl.imsglobal.org/vocab/lis/v2/membership#!
|| ($ce->{LTI}{v1p3}{AllowInstitutionRoles}
&& m!^http://purl.imsglobal.org/vocab/lis/v2/institution/person#!)
} @LTIroles;

if ($ce->{debug_lti_parameters}) {
warn "The adjusted LTI roles defined for this user are: \n-- " . join("\n-- ", @LTIroles),
Expand Down

0 comments on commit d6ba13c

Please sign in to comment.