-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from oat-sa/develop
Develop
- Loading branch information
Showing
6 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
2.4.0 | ||
----- | ||
|
||
* Added Basic Outcome claim handling | ||
|
||
2.3.0 | ||
----- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2020 (original work) Open Assessment Technologies SA; | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OAT\Library\Lti1p3Core\Message\Claim; | ||
|
||
use OAT\Library\Lti1p3Core\Message\LtiMessageInterface; | ||
|
||
/** | ||
* @see https://www.imsglobal.org/spec/lti-bo/v1p1/#integration-with-lti-1-3 | ||
*/ | ||
class BasicOutcomeClaim implements MessageClaimInterface | ||
{ | ||
/** @var string */ | ||
private $lisResultSourcedId; | ||
|
||
/** @var string */ | ||
private $lisOutcomeServiceUrl; | ||
|
||
public function __construct(string $lisResultSourcedId, string $lisOutcomeServiceUrl) | ||
{ | ||
$this->lisResultSourcedId = $lisResultSourcedId; | ||
$this->lisOutcomeServiceUrl = $lisOutcomeServiceUrl; | ||
} | ||
|
||
public static function getClaimName(): string | ||
{ | ||
return LtiMessageInterface::CLAIM_LTI_BASIC_OUTCOME; | ||
} | ||
|
||
public function getLisResultSourcedId(): string | ||
{ | ||
return $this->lisResultSourcedId; | ||
} | ||
|
||
public function getLisOutcomeServiceUrl(): string | ||
{ | ||
return $this->lisOutcomeServiceUrl; | ||
} | ||
|
||
public function normalize(): array | ||
{ | ||
return array_filter([ | ||
'lis_result_sourcedid' => $this->lisResultSourcedId, | ||
'lis_outcome_service_url' => $this->lisOutcomeServiceUrl, | ||
]); | ||
} | ||
|
||
public static function denormalize(array $claimData): BasicOutcomeClaim | ||
{ | ||
return new self( | ||
$claimData['lis_result_sourcedid'], | ||
$claimData['lis_outcome_service_url'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2020 (original work) Open Assessment Technologies SA; | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OAT\Library\Lti1p3Core\Tests\Unit\Message\Claim; | ||
|
||
use OAT\Library\Lti1p3Core\Message\Claim\BasicOutcomeClaim; | ||
use OAT\Library\Lti1p3Core\Message\LtiMessageInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BasicOutcomeClaimTest extends TestCase | ||
{ | ||
/** @var BasicOutcomeClaim */ | ||
private $subject; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->subject = new BasicOutcomeClaim('id', 'url'); | ||
} | ||
|
||
public function testGetClaimName(): void | ||
{ | ||
$this->assertEquals(LtiMessageInterface::CLAIM_LTI_BASIC_OUTCOME, $this->subject::getClaimName()); | ||
} | ||
|
||
public function testGetters(): void | ||
{ | ||
$this->assertEquals('id', $this->subject->getLisResultSourcedId()); | ||
$this->assertEquals('url', $this->subject->getLisOutcomeServiceUrl()); | ||
} | ||
|
||
public function testNormalisation(): void | ||
{ | ||
$this->assertEquals( | ||
[ | ||
'lis_result_sourcedid' => 'id', | ||
'lis_outcome_service_url' => 'url', | ||
], | ||
$this->subject->normalize() | ||
); | ||
} | ||
|
||
public function testDenormalisation(): void | ||
{ | ||
$denormalisation = BasicOutcomeClaim::denormalize([ | ||
'lis_result_sourcedid' => 'id', | ||
'lis_outcome_service_url' => 'url', | ||
]); | ||
|
||
$this->assertInstanceOf(BasicOutcomeClaim::class, $denormalisation); | ||
$this->assertEquals('id', $denormalisation->getLisResultSourcedId()); | ||
$this->assertEquals('url', $denormalisation->getLisOutcomeServiceUrl()); | ||
} | ||
} |