ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
LineItem.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\LTI\ToolProvider;
20 
22 
30 class LineItem
31 {
37  public ?string $label = null;
38 
44  public int $pointsPossible = 1;
45 
51  public ?string $ltiResourceLinkId = null;
52 
58  public ?string $resourceId = null;
59 
65  public ?string $tag = null;
66 
72  public ?int $submitFrom = null;
73 
79  public ?int $submitUntil = null;
80 
86  public ?string $endpoint = null;
87 
93  private ?Platform $platform = null;
94 
101  public function __construct(Platform $platform, string $label, int $pointsPossible)
102  {
103  $this->platform = $platform;
104  $this->label = $label;
105  $this->pointsPossible = $pointsPossible;
106  }
107 
113  public function getPlatform(): ?Platform
114  {
115  return $this->platform;
116  }
117 
123  public function save(): bool
124  {
125  $service = new Service\LineItem($this->platform, $this->endpoint);
126  return $service->saveLineItem($this);
127  }
128 
134  public function delete(): bool
135  {
136  $service = new Service\LineItem($this->platform, $this->endpoint);
137  return $service->deleteLineItem($this);
138  }
139 
145  public function getOutcomes(int $limit = null)
146  {
147  $resultService = new Service\Result($this->platform, $this->endpoint);
148  return $resultService->getAll();
149  }
150 
156  public function readOutcome(User $user)
157  {
158  $resultService = new Service\Result($this->platform, $this->endpoint);
159  return $resultService->get($user);
160  }
161 
168  public function submitOutcome(Outcome $ltiOutcome, User $user): bool
169  {
170  $scoreService = new Service\Score($this->platform, $this->endpoint);
171  return $scoreService->submit($ltiOutcome, $user);
172  }
173 
179  public function deleteOutcome(User $user): bool
180  {
181  $ltiOutcome = new Outcome();
182  $scoreService = new Service\Score($this->platform, $this->endpoint);
183  return $scoreService->submit($ltiOutcome, $user);
184  }
185 
192  public static function fromEndpoint(Platform $platform, string $endpoint)
193  {
194  return Service\LineItem::getLineItem($platform, $endpoint);
195  }
196 }
submitOutcome(Outcome $ltiOutcome, User $user)
Submit the outcome for a user.
Definition: LineItem.php:168
Platform $platform
Platform for this line item.
Definition: LineItem.php:93
Class to represent a platform.
Definition: Platform.php:35
string $resourceId
Tool resource ID associated with the line item.
Definition: LineItem.php:58
Class to represent a platform user.
Definition: User.php:30
string $ltiResourceLinkId
LTI Resource Link ID with which the line item is associated.
Definition: LineItem.php:51
Class to represent a line item.
Definition: LineItem.php:30
readOutcome(User $user)
Retrieve the outcome for a user.
Definition: LineItem.php:156
Class to implement the Result service.
Definition: Result.php:31
deleteOutcome(User $user)
Delete the outcome for a user.
Definition: LineItem.php:179
int $submitFrom
Outcome start submit timestamp.
Definition: LineItem.php:72
string $tag
Tag value.
Definition: LineItem.php:65
int $submitUntil
Outcome end submit timestamp.
Definition: LineItem.php:79
int $pointsPossible
Points possible value.
Definition: LineItem.php:44
save()
Save the line item to the platform.
Definition: LineItem.php:123
string $label
Label value.
Definition: LineItem.php:37
getOutcomes(int $limit=null)
Retrieve all outcomes.
Definition: LineItem.php:145
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AccessToken.php:19
string $endpoint
Line item endpoint.
Definition: LineItem.php:86
__construct(Platform $platform, string $label, int $pointsPossible)
Class constructor.
Definition: LineItem.php:101
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class to represent an outcome.
Definition: Outcome.php:28
Class to implement the Score service.
Definition: Score.php:30
static fromEndpoint(Platform $platform, string $endpoint)
Retrieve a line item definition.
Definition: LineItem.php:192
$service
Definition: ltiservices.php:43