Skip to content

Add a course selection step in content item selection for LTI 1.3.#2994

Open
drgrice1 wants to merge 2 commits into
openwebwork:WeBWorK-2.21from
drgrice1:lti-1.3-features-plus-course-choice
Open

Add a course selection step in content item selection for LTI 1.3.#2994
drgrice1 wants to merge 2 commits into
openwebwork:WeBWorK-2.21from
drgrice1:lti-1.3-features-plus-course-choice

Conversation

@drgrice1
Copy link
Copy Markdown
Member

@drgrice1 drgrice1 commented Jun 1, 2026

If the new $LTI{v1p3}{allowCourseSelection} option is set to 1 and an instructor attempts to sign in via LTI 1.3 authentication from an LMS course that is not in the LTI course map for the site, then a list of webwork courses will be compiled that have matching LTI 1.3 parameters, that have a user that works for the LMS user with email_address set that matches the email address sent from the LMS, and such that the user has the access_instructor_tools and modify_problem_sets permissions. So it is important that the email_address be set in the webwork courses for the user. Also note that the LTI user id selection parameters (preferred_source_of_username, fallback_source_of_username, strip_domain_from_email, and lowercase_username`) have to be the same for all matching courses (effectively the settings from the first course found are used).

Then the user will be presented a list of courses to choose from (or if only one matching course is found that course will be used). When the user selects a course (or only on course matches), it will be automatically added to the LTI course map, and then content selection will continue as usual with that course.

For this to work, the user is authenticated into the first matching course. Then if the user chooses a different course, that authentication is transfered to the selected course. Authentication should work in any of them since all of the matching courses have the same LTI 1.3 parameters and the user in each course has the same user id, email address, and permissions.

If no matching courses are found or if the $LTI{v1p3}{allowCourseSelection} option is set to 0, then the context id is shown as before.

Note that the $LTI{v1p3}{allowCourseSelection} is necessarily a site wide option that cannot be configured per course.

Note that this is built on top of #2993.

drgrice1 added 2 commits May 31, 2026 05:22
First, the `lineitems` URL that is sent with any resource link (and even
for a deep linking request, i.e., a content selection request) is stored
in the course settings whenever one of those occur.  This `lineitems`
URL is unique for the external tool, and can be used to fetch a list of
all resource links that use the external tool. Then when any grade pass
back is performed this URL is used to get that list which includes the
`lineitem` URL for each specific resource link. That is the link that is
used for grade pass back for the set.  However, webwork needs to be able
to identify the set it belongs to.  Since it does not come from a
resource link launch the webwork2 set id is not available.  To fix this,
when deep linking is used to create a resource link, webwork now sets
the `resourceId` of the lineitem.  Note that this is a reserved value
for the tool provider, and the LMS (the tool consumer) is not supposed
to ever change it, and must send it when the `lineitems` URL is used.
Thus is deep linking is used to create a resource link to a set, then
grade pass back will be available immediately for that set without a
user ever using the link.

Second, implement LMS roster synchronization.  The requires that the
names and roles service be enabled for the external tool.  The
registration URL now includes the
`https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly`
scope which makes this so. Note that tools created manually without the
registration URL, this service can be enabled for the tool.  However, at
least for Canvas, if the tool was created using the registration URL
before this scope was added, the only way to add the scope is to have
the Canvas admin delete the tool and recreate it again using the
registration URL with what is in this pull request. Moodle still allows
editing of the tool created via the registration URL, so this can be
added later. In any case, if the names and roles service is enabled,
than any launch request (again including a deep linking request)
includes the `namesrolesservice` URL. That can be used to request the
list of users in the LMS course.  There is now a new tab that will
appear in the accounts manager if LTI 1.3 is enabled for a course, the
`preferred_source_of_username` is set, and this `namesrolesservice` URL
has been obtained (by some user using content selection or a resource
link).  When this tab is available and its action used, the list of
users in the LMS course will be obtained, and users will be created in
webwork that do not already exist, users will be updated that do exist
(if `LMSManageUserData` is true), and users not in the LMS course will
have their status changed to dropped.  Note that the data sent when
using the `namesrolesservice` URL is not the same as that sent in a
launch request.  So there are some new options that control what is used
for the username and student_id.  See the options and documentation in
`conf/authen_LTI_1_3.conf.dist`. Also note that this will never add,
update, or modify in any way any users that have a role that is above
the `LTIAccountCreationCutoff`.

Note that when users are created or updated via the tab in the accounts
manager and the `namesrolesservice` URL, the LMS `user_id` (or `sub`) is
included in the data received and saved to the `lis_source_did` column
for the user.  So this means that for links created via deep linking
with this pull request and users added or updated in this way, grade
pass back is available immediately, even if the user never logs in to
webwork via the LMS.

Also fix plurality of some texts for some other similar action results
in the accounts manager.

Unfortunately the message on the assignments page stating "You must
access this assignment from the LMS before you can start." is still
shown even if an instructor uses deep linking to create links in the
LMS.  The problem is that although grade passabck will work for those
sets, the lineitem URL is still not saved in the database for all of
those sets.  The lineitem is not obtained until grade pass back occurs
or as before, a user uses the link from the LMS. So those that create
all links via deep linking will most likely want to set
`$LTI{v1p3}{ignoreMissingSourcedID}` so that users are not shown that
message, and can access the sets. As such, I made that option one that
can be made available for instructors to set on the LTI tab in the
course configuration.

Third, implement set date synchronization with the LMS. Set dates can be
synchronized to or from the LMS. There is a new tab for this in the sets
manager that is shown if LTI 1.3 with homework grade pass back is
enabled and the general lineitems URL is available. Also there is a new
LTI 1.3 option `$LTI{v1p3}{autoSyncSetDatesToLMS}`. If this is true,
then anytime that dates are changed on the sets manager or problem set
detail pages, a job to synchronize dates to the LMS will automatically
be queued for the sets with dates changed.

Note that only the open and due (or close) dates have an equivalent in
the LTI specification, namely the start and end dates. So when
synchronizing from an LMS, the reduced scoring date and answer date are
adjusted if needed to make them fit into the dates received from the
LMS. Of course, when sending dates, only the open and due date are sent.

It is also important to note that date synchronization is not supported
by all LMSs.  Canvas does, but Moodle does not.  As usual, I don't know
what D2L or Blackboard support.

One related small change is that set dates are now also set when grade
pass back mode is homework and a link is created to a set via deep
linking.

Another small change to the deep linking response is that
`window => { targetName => '_blank' }` is set. This makes Canvas open
the links in a new window instead of being embedded in the page. This
does not work for Moodle, and as far as I can tell, there is no way to
make this happen from the deep linking response.  Fortunately for Moodle
users, the external tool can be set so that all links created that use
the external tool open in a new window.  Canvas on the other hand does
not have that.  So without this change, Canvas users that create links
have to go edit each link and change it to open in a new window.
If the new `$LTI{v1p3}{allowCourseSelection}` option is set to 1 and an
instructor attempts to sign in via LTI 1.3 authentication from an LMS
course that is not in the LTI course map for the site, then a list of
webwork courses will be compiled that have matching LTI 1.3 parameters,
that have a user that works for the LMS user with email_address set that
matches the email address sent from the LMS, and such that the user has
the access_instructor_tools and modify_problem_sets permissions. So it
is important that the email_address be set in the webwork courses for
the user. Also note that the LTI user id selection parameters
(`preferred_source_of_username`, `fallback_source_of_username`,
strip_domain_from_email`, and `lowercase_username`) have to be the same
for all matching courses (effectively the settings from the first course
found are used).

Then the user will be presented a list of courses to choose from (or if
only one matching course is found that course will be used). When the
user selects a course (or only on course matches), it will be
automatically added to the LTI course map, and then content selection
will continue as usual with that course.

For this to work, the user is authenticated into the first matching
course. Then if the user chooses a different course, that authentication
is transfered to the selected course. Authentication should work in any
of them since all of the matching courses have the same LTI 1.3
parameters and the user in each course has the same user id, email
address, and permissions.

If no matching courses are found or if the `$LTI{v1p3}{allowCourseSelection}`
option is set to 0, then the context id is shown as before.

Note that the `$LTI{v1p3}{allowCourseSelection}` is necessarily a site
wide option that cannot be configured per course.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant