Skip to content

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 allows you to provide a score service endpoint as specified in AGS openapi documentation.

Usage

First, you need to provide:

Then:

<?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);