Fix an issue that can cause LTI 1.3 grade passback to fail when called from the job queue. #2319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
get_access_token
method calls$c->url_for
(on line 141 ofWeBWorK::Authen::LTIAdvantage::SubmitGrade
. This is only called if the access token is not saved in the database or if the access token that is saved is expired. When this is called from the minion job queue,$c
is not aMojolicious::Controller
. Instead it is an unblessed hash reference that has the keysce
,db
, andapp
defined. Clearly that unblessed hash reference will not have theurl_for
method. As such, the job will fail if a new access token is needed. So as is done on line 249 in thesubmit_grade
method, the$c
object needs to be switched to the passed in$c->{app}
object, which does have theurl_for
method.Note that with the current code this method will still succeed if the database has an unexpired access token stored. Also, this method will succeed if called with a
Mojolicious::Controller
object (for instance when called in the case that a student initially logs in via LTI 1.3 authentication or in the case that a student submits an answer to a problem or grades a test).This could be considered for a hotfix.