Skip to content

Commit 1f57787

Browse files
committed
Make LTI 1.3 launch redirection honor query parameters in the target_link_uri.
This is useful if you want to make unpublished instructor links in the LMS that go to specific pages in webwork with query params to make certain display options active immediately. For example, if you use a link such as `https://webwork.server.edu/webwork2/instructor/progress/set/setID?returning=1&show_date=1&show_testtime=1&show_problems=1` then the test dates, times, and problems will be shown when the page opens. Currently URL parameters are dropped. This was not intentional when I implemented this, it is merely a side effect of calling `systemlink` and `url_for` on the `target_link_uri` that is given. This just gets the query parameters that are passed in the given `target_link_uri` and then passes them to `systemLink` so that it adds them back to the generated URL that gets redirected to.
1 parent d712732 commit 1f57787

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/WeBWorK/ContentGenerator/LTIAdvantage.pm

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package WeBWorK::ContentGenerator::LTIAdvantage;
22
use Mojo::Base 'WeBWorK::ContentGenerator', -signatures;
33

44
use Mojo::UserAgent;
5+
use Mojo::URL;
56
use Mojo::JSON qw(decode_json);
67
use Crypt::JWT qw(decode_jwt encode_jwt);
78
use Math::Random::Secure qw(irand);
@@ -175,9 +176,11 @@ sub launch ($c) {
175176

176177
return $c->redirect_to($c->systemLink(
177178
$c->url_for($c->stash->{LTILaunchRedirect}),
178-
$c->stash->{isContentSelection}
179-
? (
180-
params => {
179+
params => {
180+
%{ Mojo::URL->new($c->stash->{LTILaunchRedirect})->query->to_hash },
181+
$c->stash->{isContentSelection}
182+
? (
183+
181184
courseID => $c->stash->{courseID},
182185
initial_request => 1,
183186
accept_multiple =>
@@ -191,9 +194,9 @@ sub launch ($c) {
191194
? (data => $c->stash->{lti_jwt_claims}
192195
{'https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings'}{data})
193196
: ()
194-
}
195-
)
196-
: ()
197+
)
198+
: ()
199+
}
197200
));
198201
}
199202

0 commit comments

Comments
 (0)