oat-sa / lib-lti1p3-core

PHP library for LTI 1.3 Core implementations as platforms and / or as tools.
GNU General Public License v2.0
33 stars 18 forks source link

Workflow implementation of LTI as a Platform #152

Open abanghendri opened 1 year ago

abanghendri commented 1 year ago

Hello, I need help about this package, I still confuse about step by step guide if I want integrate my laravel app as a LTI platform, I use moodle as LTI Tool provider and moodle give me Registration URL, what can I do with that link? I cannot find any code that tell me to process that link, what essential routes needed to be a Platform, how to process from Registration URL and get all the data from tool provider and then launch the course.

thank you in advance

anubhabmondalDirac commented 1 year ago

@abanghendri do you implement this library successfully in your tool end?

abanghendri commented 1 year ago

@anubhabmondalDirac yes, I'm able to implement it until content launch but now I face some issue on NRPS and AGS service I use moodle for LTI consumer, but when I access moodle token, I always got this error

 OAT \ Library \ Lti1p3Core \ Exception \ LtiException (400)
Cannot get line item: Cannot get access token: Client error: `POST http://moodle.local/mod/lti/token.php` resulted in a `400 Bad Request` response: { "error" : "Cannot handle token prior to 2023-02-10T16:39:07+0700" } 

I don't know if this error comes from this library or moodle, because it says 400 which mean client (my platform) error

anubhabmondalDirac commented 1 year ago

@abanghendri oh okk .. Sorry, I am also new to LTI 1.3. I am trying to understand how to embed it into my tool I am also using Moodle for LMS. Do you have any code examples to understand the workflow and launch? Thanks!

anubhabmondalDirac commented 1 year ago

How can I implement find registration? what will be my code structure any one help?

use OAT\Library\Lti1p3Core\Registration\RegistrationInterface; use OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface;

$registrationRepository = new class implements RegistrationRepositoryInterface { public function find(string $identifier): ?RegistrationInterface { // TODO: Implement find() method to find a registration by identifier, or null if not found. }

public function findAll(): array { // TODO: Implement findAll() method to find all available registrations. }

public function findByClientId(string $clientId) : ?RegistrationInterface { // TODO: Implement findByClientId() method to find a registration by client id, or null if not found. }

public function findByPlatformIssuer(string $issuer, string $clientId = null): ?RegistrationInterface { // TODO: Implement findByPlatformIssuer() method to find a registration by platform issuer, and client id if provided. }

public function findByToolIssuer(string $issuer, string $clientId = null): ?RegistrationInterface { // TODO: Implement findByToolIssuer() method to find a registration by tool issuer, and client id if provided. } };

any demo example code available ? Thanks in advance !

abanghendri commented 1 year ago

since it our company's propietary code thus I cannot share as is to anyone, so I'll back to you as soon as possible with my new integration example, may be 2-4 days @anubhabmondalDirac

anubhabmondalDirac commented 1 year ago

Ok, I understand. Thank you so much.

abanghendri commented 1 year ago

Hi @anubhabmondalDirac , you can fork my repo here Laravel LTI Example

the steps is

  1. you need some endpoint (OIDC init, Launch URL, Deeplinking URL, JWKS URL)
  2. you can register your tool to moodle, then you can insert moodle's information to your tool as a platform
anubhabmondalDirac commented 1 year ago

@abanghendri Thank you so much. For me, it will be beneficial. But my tool is based on PHP Codeigniter, I never use laravel but will try to implement it as you say. Thanks again!

abanghendri commented 1 year ago

@anubhabmondalDirac not too different I think, I used to use Codeigniter too, since this library is framework agnostic, you can use it on any PHP project even on native PHP I just use ordinary controller and traits which also supported by CI framework

anubhabmondalDirac commented 1 year ago

@abanghendri Thanks, I will try my best.