LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
Score.php
1<?php
2
3namespace ceLTIc\LTI\Service;
4
8
17{
18
24 public static $SCOPE = 'https://purl.imsglobal.org/spec/lti-ags/scope/score';
25
32 public function __construct($platform, $endpoint)
33 {
34 parent::__construct($platform, $endpoint, '/scores');
35 $this->scope = self::$SCOPE;
36 $this->mediaType = 'application/vnd.ims.lis.v1.score+json';
37 }
38
47 public function submit($ltiOutcome, $user)
48 {
49 $score = $ltiOutcome->getValue();
50 if (!is_null($score)) {
51 $json = array(
52 'scoreGiven' => $score,
53 'scoreMaximum' => $ltiOutcome->getPointsPossible(),
54 'comment' => $ltiOutcome->comment,
55 'activityProgress' => $ltiOutcome->activityProgress,
56 'gradingProgress' => $ltiOutcome->gradingProgress
57 );
58 } else {
59 $json = array(
60 'activityProgress' => 'Initialized',
61 'gradingProgress' => 'NotReady'
62 );
63 }
64 $json['userId'] = $user->ltiUserId;
65 $date = new \DateTime();
66 $json['timestamp'] = date_format($date, 'Y-m-d\TH:i:s.uP');
67 $data = json_encode($json);
68 $http = $this->send('POST', null, $data);
69
70 return $http->ok;
71 }
72
73}
Class to represent an outcome.
Definition Outcome.php:13
Class to represent a platform.
Definition Platform.php:18
Class to implement the Assignment and Grade services.
Class to implement the Score service.
Definition Score.php:17
__construct($platform, $endpoint)
Class constructor.
Definition Score.php:32
static $SCOPE
Access scope.
Definition Score.php:24
submit($ltiOutcome, $user)
Submit an outcome for a user.
Definition Score.php:47
Class to implement a service.
Definition Service.php:19
send($method, $parameters=array(), $body=null)
Send a service request.
Definition Service.php:119
$endpoint
Service endpoint.
Definition Service.php:33
Class to represent a platform user.
Definition User.php:13