Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Outcomes

Stephen Vickers edited this page May 18, 2016 · 1 revision

A grade book for a specific user is identified by their associated result sourcedid; this value is passed when the user launches the tool and is automatically retained by the library for future use. The result sourcedid for the current user could be saved as a session variable as part of the onLaunch method, but the value may be obtained by loading the User record from its user ID:

$user = ToolProvider\User::fromResourceLink($resource_link, $user_id);

The user's grade may be retrieved from the grade book in the tool consumer using a read operation:

$outcome = new ToolProvider\Outcome();
if ($resource_link->doOutcomesService(ToolProvider\ResourceLink::EXT_READ, $outcome, $user)) {
  $score = $outcome->getValue();
}

The user's grade may be saved to the grade book in the tool consumer using a write operation:

$outcome = new Outcome($score);
$ok = $resource_link->doOutcomesService(ResourceLink::EXT_WRITE, $outcome, $user);

The score should normally be a decimal value between 0 and 1, but the doOutcomesService method makes every effort to convert the value passed to a format which is accepted by the tool consumer; for example, a percentage of 65% may be converted to a decimal 0.65. If the value cannot be converted to a decimal and the tool consumer supports the Outcomes extension service then an attempt will be made to use this service instead.

The delete operation can be used to remove a grade from the grade book.

Clone this wiki locally