longhornopen / laravel-celtic-lti

Integrates the Celtic LTI library with a Laravel app
GNU Lesser General Public License v2.1
11 stars 12 forks source link

Token needed for Score submission #32

Open onebonsai opened 2 months ago

onebonsai commented 2 months ago

Hi,

I am trying to send back the scores of my tool to the platform. Using ltiMessage, I store the ltiResourceLinkId and ltiUserId in session. I then retrieve that in the scoring function at the end of the use of my tool.

$score = 100;
$pointsPossible = 100;
$activityProgress = 'Submitted';
$gradingProgress = 'FullyGraded';
$outcome = new Outcome($score, $pointsPossible, $activityProgress, $gradingProgress);
$outcome->comment = '';
$ok = $resourceLink->doOutcomesService(ServiceAction::Write, $outcome, $userResult);
if ($ok) {
    Log::info('Result sent to LMS: ' . json_encode($outcome));
    return Helper::SUCCESS;
} else {
    Log::info('Result failed to sent to LMS: ' . json_encode($outcome));
    return Helper::ERR_OUTCOME_SERVICE_FAILED;
}

However, the doOutcomesService function returns false, due to doScoreService returning false (ResourceLink.php). This is because

$http = $scoreService->getHttpMessage();

returns false with this error message:

{"ok":false,"request":null,"requestHeaders":[],"response":null,"responseHeaders":[],"relativeLinks":[],"status":0,"error":"Unable to obtain an access token for scope: https:\/\/purl.imsglobal.org\/spec\/lti-ags\/scope\/score"}

I understood that this token was automagically retrieved using the jwks funtionality. Additionally, I have set the required_scopes in the config/lti.php file to match the above required scope (score).

I do not know what I am missing?

Thanks!

chrispittman commented 2 months ago

I'm guessing you're using Moodle, which I'm not real familiar with. Have you seen https://moodle.org/mod/forum/discuss.php?d=446771#p1795488 ?

onebonsai commented 2 months ago

Thanks for that post. Not sure though what they mean with:

I just figured it out, we had a silly typo in our signature method: RSA256. This should be, RS256 of course.

Where do I set this signature method? I might have a similar issue?

chrispittman commented 2 months ago

All the settings that you can change are in config/lti.php.

onebonsai commented 2 months ago

A pity, signature_method is

'signature_method' => env('LTI13_SIGNATURE_METHOD', 'RS256'),

Fyi, I use a similar approach to https://github.com/longhornopen/lti-example-app/blob/main/web/app/Http/Controllers/LtiController.php to get the resourceLink and userResult.

Sadly, that does not seem to send the correct token through.

As you mention, this might be a question for the Moodle team. I will post one there as well.

Thanks!

chrispittman commented 2 months ago

Hmm. The only info I've been able to find is the privacy-settings thing from that moodle.org link I posted. If you figure it out, post the solution here for others, please?