Skip to content

Commit

Permalink
Merge pull request #106 from JonathanGawrych/jag/add-grades-released
Browse files Browse the repository at this point in the history
Add gradesReleased to LtiLineItem
  • Loading branch information
dbhynds authored Oct 19, 2023
2 parents 3971fb9 + a1312a7 commit 65855b0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/LtiLineitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LtiLineitem
private $tag;
private $start_date_time;
private $end_date_time;
private ?bool $grades_released;

public function __construct(array $lineitem = null)
{
Expand All @@ -23,6 +24,7 @@ public function __construct(array $lineitem = null)
$this->tag = $lineitem['tag'] ?? null;
$this->start_date_time = $lineitem['startDateTime'] ?? null;
$this->end_date_time = $lineitem['endDateTime'] ?? null;
$this->grades_released = $lineitem['gradesReleased'] ?? null;
}

public function __toString()
Expand All @@ -37,6 +39,7 @@ public function __toString()
'tag' => $this->tag,
'startDateTime' => $this->start_date_time,
'endDateTime' => $this->end_date_time,
'gradesReleased' => $this->grades_released,
], '\Packback\Lti1p3\Helpers\Helpers::checkIfNullValue'));
}

Expand Down Expand Up @@ -143,4 +146,16 @@ public function setEndDateTime($value)

return $this;
}

public function getGradesReleased(): ?bool
{
return $this->grades_released;
}

public function setGradesReleased(?bool $value): self
{
$this->grades_released = $value;

return $this;
}
}
38 changes: 38 additions & 0 deletions tests/LtiLineitemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class LtiLineitemTest extends TestCase
{
private LtiLineitem $lineItem;

public function setUp(): void
{
$this->lineItem = new LtiLineitem();
Expand Down Expand Up @@ -175,6 +177,41 @@ public function testItSetsEndDateTime()
$this->assertEquals($expected, $this->lineItem->getEndDateTime());
}

public function testItGetsGradesReleased(): void
{
$expected = true;
$grade = new LtiLineitem(['gradesReleased' => $expected]);

$result = $grade->getGradesReleased();

$this->assertEquals($expected, $result);
}

public function testItSetsGradesReleased(): void
{
$expected = false;

$this->lineItem->setGradesReleased($expected);

$this->assertEquals($expected, $this->lineItem->getGradesReleased());
}

public function testGradesReleasedConstructedNullable(): void
{
$grade = new LtiLineitem();

$result = $grade->getGradesReleased();

$this->assertNull($result);
}

public function testGradesReleasedSetNullable(): void
{
$this->lineItem->setGradesReleased(null);

$this->assertNull($this->lineItem->getGradesReleased());
}

public function testItCastsFullObjectToString()
{
$expected = [
Expand All @@ -186,6 +223,7 @@ public function testItCastsFullObjectToString()
'tag' => 'Tag',
'startDateTime' => 'StartDateTime',
'endDateTime' => 'EndDateTime',
'gradesReleased' => true,
];

$lineItem = new LtiLineitem($expected);
Expand Down

0 comments on commit 65855b0

Please sign in to comment.