Skip to content

Commit

Permalink
Add submissionStarted and submissionCompleted properties to Outcome
Browse files Browse the repository at this point in the history
  • Loading branch information
spvickers committed Aug 29, 2024
1 parent f4f4154 commit ab9dee9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Outcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ class Outcome
*/
public ?string $comment = null;

/**
* Date submission started.
*
* @var DateTime|null $submissionStarted
*/
public ?\DateTime $submissionStarted = null;

/**
* Date submission completed.
*
* @var DateTime|null $submissionCompleted
*/
public ?\DateTime $submissionCompleted = null;

/**
* Outcome data source value.
*
Expand Down
9 changes: 9 additions & 0 deletions src/Service/Score.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public function submit(Outcome $ltiOutcome, User $user): bool
$json['scoreGiven'] = $score;
$json['scoreMaximum'] = $ltiOutcome->getPointsPossible();
}
if (!empty($ltiOutcome->submissionStarted) || !empty($ltiOutcome->submissionCompleted)) {
$json['submission'] = [];
if (!empty($ltiOutcome->submissionStarted)) {
$json['submission']['startedAt'] = date_format($ltiOutcome->submissionStarted, 'Y-m-d\TH:i:s.uP');
}
if (!empty($ltiOutcome->submissionStarted)) {
$json['submission']['submittedAt'] = date_format($ltiOutcome->submissionCompleted, 'Y-m-d\TH:i:s.uP');
}
}
$data = json_encode($json);
$http = $this->send('POST', null, $data);

Expand Down

0 comments on commit ab9dee9

Please sign in to comment.