AGS Platform - Score service server
How to use the ScoreServiceServerRequestHandler (with the core LtiServiceServer) to provide authenticated AGS endpoint for score publications as a platform.
Features
This library provides a ScoreServiceServerRequestHandler ready to be use with the core LtiServiceServer to accept scores publications as a platform.
- it accepts a PSR7 ServerRequestInterface,
- leverages the required IMS LTI 1.3 service authentication,
- and returns a PSR7 ResponseInterface containing the score publication response
It allows you to provide a score 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 ScoreRepositoryInterface implementation, in charge to handle scores, as explained in the interfaces library documentation
Then:
- you can construct the ScoreServiceServerRequestHandler (constructed with your LineItemRepositoryInterface and ScoreRepositoryInterface 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\ScoreRepositoryInterface;
use OAT\Library\Lti1p3Ags\Service\Score\Server\Handler\ScoreServiceServerRequestHandler;
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 ScoreRepositoryInterface $scoreRepository */
$scoreRepository = ...
$validator = new RequestAccessTokenValidator($registrationRepository);
$handler = new ScoreServiceServerRequestHandler($lineItemRepository, $scoreRepository);
$server = new LtiServiceServer($validator, $handler);
// Generates an authenticated response containing the score publication result
$response = $server->handle($request);