ILIAS  release_8 Revision v8.24
Score.php
Go to the documentation of this file.
1<?php
2
20
22
31{
35 public static string $SCOPE = 'https://purl.imsglobal.org/spec/lti-ags/scope/score';
36
42 public function __construct(\ILIAS\LTI\ToolProvider\Platform $platform, string $endpoint)
43 {
45 $this->scope = self::$SCOPE;
46 $this->mediaType = 'application/vnd.ims.lis.v1.score+json';
47 }
48
55 public function submit(ToolProvider\Outcome $ltiOutcome, ToolProvider\User $user): bool
56 {
57 $score = $ltiOutcome->getValue();
58 if (!is_null($score)) {
59 $json = array(
60 'scoreGiven' => $score,
61 'scoreMaximum' => $ltiOutcome->getPointsPossible(),
62 'comment' => $ltiOutcome->comment,
63 'activityProgress' => $ltiOutcome->activityProgress,
64 'gradingProgress' => $ltiOutcome->gradingProgress
65 );
66 } else {
67 $json = array(
68 'activityProgress' => 'Initialized',
69 'gradingProgress' => 'NotReady'
70 );
71 }
72 $json['userId'] = $user->ltiUserId;
73 $date = new \DateTime();
74 $json['timestamp'] = date_format($date, 'Y-m-d\TH:i:s.uP');
75 $data = json_encode($json);
76 // UK changed from $http = $this->send('POST', null, $data);
77 $http = $this->send('POST', [], $data);
78
79 return $http->ok;
80 }
81}
Class to represent an outcome.
Definition: Outcome.php:29
Class to represent a platform.
Definition: Platform.php:36
Class to implement the Assignment and Grade services.
Class to implement the Score service.
Definition: Score.php:31
static string $SCOPE
Access scope.
Definition: Score.php:35
submit(ToolProvider\Outcome $ltiOutcome, ToolProvider\User $user)
Submit an outcome for a user.
Definition: Score.php:55
__construct(\ILIAS\LTI\ToolProvider\Platform $platform, string $endpoint)
Class constructor.
Definition: Score.php:42
string $endpoint
Service endpoint.
Definition: Service.php:47
HTTPMessage $http
HttpMessage object for last service request.
Definition: Service.php:75
send(string $method, array $parameters=array(), string $body=null)
Send a service request.
Definition: Service.php:130
Platform $platform
Platform for this service request.
Definition: Service.php:68
Class to represent a platform user.
Definition: User.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AccessToken.php:19
Class ChatMainBarProvider \MainMenu\Provider.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...