Skip to content

Commit

Permalink
Merge pull request #16 from oat-sa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ekkinox committed Apr 6, 2021
2 parents 38f5a5a + 5787a36 commit ea5ae77
Show file tree
Hide file tree
Showing 31 changed files with 759 additions and 693 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ before_script:
script:
- mkdir -p build/logs
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- ./vendor/bin/psalm --shepherd

after_script:
- ./vendor/bin/php-coveralls -v
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
CHANGELOG
=========

3.0.0
-----

* Added psalm support
* Deleted BasicOutcomeServiceServer in favor to BasicOutcomeServiceServerRequestHandler (to be used with core LtiServiceServer)
* Updated oat-sa/lib-lti1p3-core dependency to version 5.0
* Updated BasicOutcomeServiceServerProcessorInterface methods parameters to work with registration
* Updated overall constructors to handle nullable parameters
* Updated documentation

2.0.0
-----

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[![Latest Version](https://img.shields.io/github/tag/oat-sa/lib-lti1p3-basic-outcome.svg?style=flat&label=release)](https://github.com/oat-sa/lib-lti1p3-basic-outcome/tags)
[![License GPL2](http://img.shields.io/badge/licence-GPL%202.0-blue.svg)](http://www.gnu.org/licenses/gpl-2.0.html)
[![Build Status](https://travis-ci.org/oat-sa/lib-lti1p3-basic-outcome.svg?branch=master)](https://travis-ci.org/oat-sa/lib-lti1p3-basic-outcome)
[![Coverage Status](https://coveralls.io/repos/github/oat-sa/lib-lti1p3-basic-outcome/badge.svg?branch=master)](https://coveralls.io/github/oat-sa/lib-lti1p3-basic-outcome?branch=master)
[![Test Coverage Status](https://coveralls.io/repos/github/oat-sa/lib-lti1p3-basic-outcome/badge.svg?branch=master)](https://coveralls.io/github/oat-sa/lib-lti1p3-basic-outcome?branch=master)
[![Psalm Level Status](https://shepherd.dev/github/oat-sa/lib-lti1p3-basic-outcome/level.svg)](https://shepherd.dev/github/oat-sa/lib-lti1p3-basic-outcome)
[![Packagist Downloads](http://img.shields.io/packagist/dt/oat-sa/lib-lti1p3-basic-outcome.svg)](https://packagist.org/packages/oat-sa/lib-lti1p3-basic-outcome)

> PHP library for [LTI 1.3 Basic Outcome](https://www.imsglobal.org/spec/lti-bo/v1p1) implementations as platforms and / or as tools, based on [LTI 1.3 Core library](https://github.com/oat-sa/lib-lti1p3-core).
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"require": {
"ext-json": "*",
"php": ">=7.2.0",
"oat-sa/lib-lti1p3-core": "^4.0",
"oat-sa/lib-lti1p3-core": "^5.0",
"psr/http-server-handler": "^1.0",
"symfony/dom-crawler": "^4.4 || ^5.1",
"twig/twig": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5.14",
"php-coveralls/php-coveralls": "^2.4"
"php-coveralls/php-coveralls": "^2.4",
"psalm/plugin-phpunit": "^0.15.1",
"vimeo/psalm": "^4.6"
},
"autoload": {
"psr-4": {
Expand All @@ -25,5 +27,8 @@
"OAT\\Library\\Lti1p3BasicOutcome\\Tests\\": "tests/",
"OAT\\Library\\Lti1p3Core\\Tests\\": "vendor/oat-sa/lib-lti1p3-core/tests/"
}
},
"config": {
"sort-packages": true
}
}
58 changes: 35 additions & 23 deletions doc/platform.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic Outcome Platform - Basic Outcome Service Server

> How to use the [BasicOutcomeServiceServer](../src/Service/Server/BasicOutcomeServiceServer.php) to serve authenticated Basic Outcome service endpoints as a platform.
> How to use the [BasicOutcomeServiceServerRequestHandler](../src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php) (with the core [LtiServiceServer](https://github.com/oat-sa/lib-lti1p3-core/blob/master/src/Service/Server/LtiServiceServer.php)) to serve authenticated Basic Outcome service endpoints as a platform.
## Table of contents

Expand All @@ -9,7 +9,7 @@

## Features

This library provides a [BasicOutcomeServiceServer](../src/Service/Server/BasicOutcomeServiceServer.php) ready to handle basic outcome operations.
This library provides a [BasicOutcomeServiceServerRequestHandler](../src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php) ready to be use with the core [LtiServiceServer](https://github.com/oat-sa/lib-lti1p3-core/blob/master/src/Service/Server/LtiServiceServer.php) to handle basic outcome operations.

- it accepts a [PSR7 ServerRequestInterface](https://www.php-fig.org/psr/psr-7/#321-psrhttpmessageserverrequestinterface) containing the basic outcome request,
- leverages the [required IMS LTI 1.3 service authentication](https://www.imsglobal.org/spec/security/v1p0/#securing_web_services),
Expand All @@ -23,24 +23,33 @@ First, you need to provide a [BasicOutcomeServiceServerProcessorInterface](../sr
<?php

use OAT\Library\Lti1p3BasicOutcome\Service\Server\Processor\BasicOutcomeServiceServerProcessorInterface;
use OAT\Library\Lti1p3BasicOutcome\Service\Server\Processor\BasicOutcomeServiceServerProcessorResult;
use OAT\Library\Lti1p3BasicOutcome\Service\Server\Processor\Result\BasicOutcomeServiceServerProcessorResult;
use OAT\Library\Lti1p3Core\Registration\RegistrationInterface;

/** @var BasicOutcomeServiceServerProcessorInterface $processor */
$processor = new class() implements BasicOutcomeServiceServerProcessorInterface
{
public function processReadResult(string $sourcedId) : BasicOutcomeServiceServerProcessorResult
{
// Logic for readResult basic outcome operations
public function processReadResult(
RegistrationInterface $registration,
string $sourcedId
) : BasicOutcomeServiceServerProcessorResult {
// @todo: Logic for readResult basic outcome operations
}

public function processReplaceResult(string $sourcedId, float $score, string $language = 'en') : BasicOutcomeServiceServerProcessorResult
{
// Logic for replaceResult basic outcome operations
public function processReplaceResult(
RegistrationInterface $registration,
string $sourcedId,
float $score,
string $language = 'en'
) : BasicOutcomeServiceServerProcessorResult {
// @todo: Logic for replaceResult basic outcome operations
}

public function processDeleteResult(string $sourcedId) : BasicOutcomeServiceServerProcessorResult
{
// Logic for deleteResult basic outcome operations
public function processDeleteResult(
RegistrationInterface $registration,
string $sourcedId
) : BasicOutcomeServiceServerProcessorResult {
// @todo: Logic for deleteResult basic outcome operations
}
};
```
Expand All @@ -49,32 +58,35 @@ You can then construct the [BasicOutcomeServiceServer](../src/Service/Server/Bas
- the [AccessTokenRequestValidator](https://github.com/oat-sa/lib-lti1p3-core/blob/master/src/Service/Server/Validator/AccessTokenRequestValidator.php) (from lti1p3-core)
- the [BasicOutcomeServiceServerHandler](../src/Service/Server/Handler/BasicOutcomeServiceServerHandler.php) that will use your `BasicOutcomeServiceServerProcessorInterface` implementation

To finally expose it to requests:
Then:
- you can construct the [BasicOutcomeServiceServerRequestHandler](../src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php) (constructed with your [BasicOutcomeServiceServerProcessorInterface](../src/Service/Server/Processor/BasicOutcomeServiceServerProcessorInterface.php) implementation)
- to finally expose it to requests using the core [LtiServiceServer](https://github.com/oat-sa/lib-lti1p3-core/blob/master/src/Service/Server/LtiServiceServer.php) (constructed with the [RequestAccessTokenValidator](https://github.com/oat-sa/lib-lti1p3-core/blob/master/src/Security/OAuth2/Validator/RequestAccessTokenValidator.php), from core library)

```php
<?php

use OAT\Library\Lti1p3BasicOutcome\Service\Server\BasicOutcomeServiceServer;
use OAT\Library\Lti1p3BasicOutcome\Service\Server\Handler\BasicOutcomeServiceServerHandler;
use OAT\Library\Lti1p3BasicOutcome\Service\Server\Handler\BasicOutcomeServiceServerRequestHandler;
use OAT\Library\Lti1p3BasicOutcome\Service\Server\Processor\BasicOutcomeServiceServerProcessorInterface;
use OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface;
use OAT\Library\Lti1p3Core\Service\Server\Validator\AccessTokenRequestValidator;
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 $repository */
$repository = ...

/** @var BasicOutcomeServiceServerProcessorInterface $processor */
$processor = ...

$validator = new AccessTokenRequestValidator($repository);
$validator = new RequestAccessTokenValidator($repository);

$handler = new BasicOutcomeServiceServerHandler($processor);
$handler = new BasicOutcomeServiceServerRequestHandler($processor);

$basicOutcomeServiceServer = new BasicOutcomeServiceServer($validator, $handler);

/** @var ServerRequestInterface $request */
$request = ...
$server = new LtiServiceServer($validator, $handler);

// Generates a response containing the basic outcome operation result
$response = $basicOutcomeServiceServer->handle($request);
$response = $server->handle($request);
```
2 changes: 1 addition & 1 deletion doc/tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Features

This library provides a [BasicOutcomeServiceClient](../src/Service/Client/BasicOutcomeServiceClient.php) (based on the [core service client](https://github.com/oat-sa/lib-lti1p3-core/blob/master/doc/service/service-client.md)) that allow the following outcome operations:
This library provides a [BasicOutcomeServiceClient](../src/Service/Client/BasicOutcomeServiceClient.php) (based on the [LtiServiceClient](https://github.com/oat-sa/lib-lti1p3-core/blob/master/doc/service/service-client.md)) that allow the following outcome operations:
- [read result](https://www.imsglobal.org/spec/lti-bo/v1p1#readresult)
- [replace result](https://www.imsglobal.org/spec/lti-bo/v1p1#replaceresult)
- [delete result](https://www.imsglobal.org/spec/lti-bo/v1p1#deleteresult)
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
</php>

<testsuites>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
Expand Down
25 changes: 25 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<psalm
autoloader="vendor/autoload.php"
errorLevel="3"
hideExternalErrors="true"
useDocblockTypes="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="doc"/>
<directory name="tests"/>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<mockClasses>
<class name="PHPUnit\Framework\MockObject\MockObject"/>
</mockClasses>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>
2 changes: 1 addition & 1 deletion src/Factory/AbstractBasicOutcomeMessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class AbstractBasicOutcomeMessageFactory
/** @var IdGeneratorInterface */
protected $generator;

public function __construct(IdGeneratorInterface $generator = null)
public function __construct(?IdGeneratorInterface $generator = null)
{
$this->generator = $generator ?? new IdGenerator();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Factory/Request/BasicOutcomeRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class BasicOutcomeRequestFactory extends AbstractBasicOutcomeMessageFactory impl
public function create(
string $type,
string $sourcedId,
float $score = null,
string $language = null,
string $identifier = null
?float $score = null,
?string $language = null,
?string $identifier = null
): BasicOutcomeRequestInterface {
return new BasicOutcomeRequest(
$identifier ?? $this->generator->generate(),
Expand Down
6 changes: 3 additions & 3 deletions src/Factory/Request/BasicOutcomeRequestFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ interface BasicOutcomeRequestFactoryInterface
public function create(
string $type,
string $sourcedId,
float $score = null,
string $language = null,
string $identifier = null
?float $score = null,
?string $language = null,
?string $identifier = null
): BasicOutcomeRequestInterface;
}
8 changes: 4 additions & 4 deletions src/Factory/Response/BasicOutcomeResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function create(
bool $success,
string $referenceRequestIdentifier,
string $referenceRequestType,
string $description = null,
float $score = null,
string $language = null,
string $identifier = null
?string $description = null,
?float $score = null,
?string $language = null,
?string $identifier = null
): BasicOutcomeResponseInterface {
return new BasicOutcomeResponse(
$identifier ?? $this->generator->generate(),
Expand Down
8 changes: 4 additions & 4 deletions src/Factory/Response/BasicOutcomeResponseFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function create(
bool $success,
string $referenceRequestIdentifier,
string $referenceRequestType,
string $description = null,
float $score = null,
string $language = null,
string $identifier = null
?string $description = null,
?float $score = null,
?string $language = null,
?string $identifier = null
): BasicOutcomeResponseInterface;
}
4 changes: 2 additions & 2 deletions src/Message/Request/BasicOutcomeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function __construct(
string $identifier,
string $type,
string $sourcedId,
float $score = null,
string $language = null
?float $score = null,
?string $language = null
) {
parent::__construct($identifier, $type);

Expand Down
6 changes: 3 additions & 3 deletions src/Message/Response/BasicOutcomeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function __construct(
bool $success,
string $referenceRequestIdentifier,
string $referenceRequestType,
string $description = null,
float $score = null,
string $language = null
?string $description = null,
?float $score = null,
?string $language = null
) {
parent::__construct($identifier, $type);

Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/AbstractBasicOutcomeMessageSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class AbstractBasicOutcomeMessageSerializer
/** @var Crawler */
protected $crawler;

public function __construct(Environment $twig = null, Crawler $crawler = null)
public function __construct(?Environment $twig = null, ?Crawler $crawler = null)
{
$this->twig = $twig ?? new Environment(new FilesystemLoader(__DIR__ . '/../../templates'));
$this->crawler = $crawler ?? new Crawler();
Expand Down
6 changes: 3 additions & 3 deletions src/Serializer/Request/BasicOutcomeRequestSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class BasicOutcomeRequestSerializer extends AbstractBasicOutcomeMessageSerialize
private $factory;

public function __construct(
BasicOutcomeRequestFactoryInterface $factory = null,
Environment $twig = null,
Crawler $crawler = null
?BasicOutcomeRequestFactoryInterface $factory = null,
?Environment $twig = null,
?Crawler $crawler = null
) {
parent::__construct($twig, $crawler);

Expand Down
6 changes: 3 additions & 3 deletions src/Serializer/Response/BasicOutcomeResponseSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class BasicOutcomeResponseSerializer extends AbstractBasicOutcomeMessageSerializ
private $factory;

public function __construct(
BasicOutcomeResponseFactoryInterface $factory = null,
Environment $twig = null,
Crawler $crawler = null
?BasicOutcomeResponseFactoryInterface $factory = null,
?Environment $twig = null,
?Crawler $crawler = null
) {
parent::__construct($twig, $crawler);

Expand Down
1 change: 1 addition & 0 deletions src/Service/BasicOutcomeServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

interface BasicOutcomeServiceInterface
{
public const NAME = 'basic-outcome';
public const AUTHORIZATION_SCOPE_BASIC_OUTCOME = 'https://purl.imsglobal.org/spec/lti-bo/scope/basicoutcome';
public const CONTENT_TYPE_BASIC_OUTCOME = 'application/vnd.ims.lti.v1.outcome+xml';
}
Loading

0 comments on commit ea5ae77

Please sign in to comment.