Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.94 KB

tool.md

File metadata and controls

49 lines (33 loc) · 1.94 KB

AGS Tool - Score service client

How to use the ScoreServiceClient to perform authenticated AGS scores publications as a tool.

Table of contents

Features

This library provides a ScoreServiceClient (based on the core LtiServiceClient) that allow scores publications as a tool.

Usage

To publish a score:

<?php

use OAT\Library\Lti1p3Ags\Model\Score\Score;
use OAT\Library\Lti1p3Ags\Service\Score\Client\ScoreServiceClient;
use OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface;

// Related registration
/** @var RegistrationRepositoryInterface $registrationRepository */
$registration = $registrationRepository->find(...);

$scoreClient = new ScoreServiceClient();

$score = new Score(...);

$isPublished = $scoreClient->publishScore(
    $registration,                                      // [required] as the tool, it will call the platform of this registration
    $score,                                             // [required] AGS score to publish
    'https://example.com/ags/contexts/1/lineitems/1'    // [required] AGS line item url to publish the score to
);

// Check score publication success
if ($isPublished) {
    // Publication success
}

Notes:

  • you can use the method publishScoreForClaim() to work directly with an AGS claim received at launch
  • you can use the method publishScoreForPayload() to work directly with an LTI message payload received at launch
  • you can use the ScoreFactory to ease your score creation