AGS Platform - Result service server
How to use the ResultServiceServerRequestHandler (with the core LtiServiceServer) to provide authenticated AGS endpoint for results retrieval as a platform.
Features
This library provides a ResultServiceServerRequestHandler ready to be use with the core LtiServiceServer to expose results to tools, as a platform.
- it accepts a PSR7 ServerRequestInterface,
- leverages the required IMS LTI 1.3 service authentication,
- and returns a PSR7 ResponseInterface containing the result list representation.
It allows you to provide a result service endpoint as specified in AGS openapi documentation.
Usage
First, you need to provide:
- a LineItemRepositoryInterface implementation, in charge to handle line items, as explained in the interfaces library documentation
- a ResultRepositoryInterface implementation, in charge to handle results, as explained in the interfaces library documentation
Then:
- you can construct the ResultServiceServerRequestHandler (constructed with your LineItemRepositoryInterface and ResultRepositoryInterface implementations)
- to finally expose it to requests using the core LtiServiceServer (constructed with the RequestAccessTokenValidator, from core library)
<?php
use OAT\Library\Lti1p3Ags\Repository\LineItemRepositoryInterface;
use OAT\Library\Lti1p3Ags\Repository\ResultRepositoryInterface;
use OAT\Library\Lti1p3Ags\Service\Result\Server\Handler\ResultServiceServerRequestHandler;
use OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface;
use OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidator;
use OAT\Library\Lti1p3Core\Service\Server\LtiServiceServer;
use Psr\Http\Message\ServerRequestInterface;
/** @var ServerRequestInterface $request */
$request = ...
/** @var RegistrationRepositoryInterface $registrationRepository */
$registrationRepository = ...
/** @var LineItemRepositoryInterface $lineItemRepository */
$lineItemRepository = ...
/** @var ResultRepositoryInterface $scoreRepository */
$resultRepository = ...
$validator = new RequestAccessTokenValidator($registrationRepository);
$handler = new ResultServiceServerRequestHandler($lineItemRepository, $resultRepository);
$server = new LtiServiceServer($validator, $handler);
// Generates an authenticated response containing the result list representation
$response = $server->handle($request);