46 public static string $SCOPE =
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem';
51 public static string $SCOPE_READONLY =
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem.readonly';
86 $this->limit = $limit;
87 $this->pagingMode = $pagingMode;
88 $this->scope = self::$SCOPE;
114 if (is_null($limit)) {
115 $limit = $this->limit;
117 if (is_null($limit)) {
118 $limit = self::$defaultLimit;
120 if (!empty($limit)) {
123 $lineItems = array();
126 $this->scope = self::$SCOPE_READONLY;
127 $this->mediaType = self::MEDIA_TYPE_LINE_ITEMS;
129 $this->scope = self::$SCOPE;
132 if (!empty(
$http->responseJson)) {
133 foreach (
$http->responseJson as $lineItem) {
134 $lineItems[] = self::toLineItem($this->
getPlatform(), $lineItem);
137 if (!$this->pagingMode &&
$http->hasRelativeLink(
'next')) {
139 $this->endpoint =
$url;
158 $lineItem->endpoint = null;
159 $this->mediaType = self::MEDIA_TYPE_LINE_ITEM;
161 $http = $this->
send(
'POST', [], self::toJson($lineItem));
162 $ok =
$http->ok && !empty(
$http->responseJson);
165 foreach (get_object_vars($newLineItem) as
$key => $value) {
166 $lineItem->$key = $value;
180 $this->mediaType = self::MEDIA_TYPE_LINE_ITEM;
182 $http = $this->
send(
'PUT', [], self::toJson($lineItem));
184 if ($ok && !empty(
$http->responseJson)) {
185 $savedLineItem = self::toLineItem($this->
getPlatform(),
$http->responseJson);
186 foreach (get_object_vars($savedLineItem) as
$key => $value) {
187 $lineItem->$key = $value;
201 $this->mediaType = self::MEDIA_TYPE_LINE_ITEM;
216 $service->scope = self::$SCOPE_READONLY;
217 $service->mediaType = self::MEDIA_TYPE_LINE_ITEM;
220 if (
$http->ok && !empty(
$http->responseJson)) {
221 $lineItem = self::toLineItem($platform,
$http->responseJson);
241 if (!empty($json->id) && !empty($json->label) && !empty($json->scoreMaximum)) {
243 $lineItem = new \ILIAS\LTI\ToolProvider\LineItem($platform, $json->label, $json->scoreMaximum);
244 if (!empty($json->id)) {
245 $lineItem->endpoint = $json->id;
247 if (!empty($json->resourceLinkId)) {
248 $lineItem->ltiResourceLinkId = $json->resourceLinkId;
250 if (!empty($json->resourceId)) {
251 $lineItem->resourceId = $json->resourceId;
253 if (!empty($json->tag)) {
254 $lineItem->tag = $json->tag;
256 if (!empty($json->startDateTime)) {
257 $lineItem->submitFrom = strtotime($json->startDateTime);
259 if (!empty($json->endDateTime)) {
260 $lineItem->submitUntil = strtotime($json->endDateTime);
276 $json = new \stdClass();
277 if (!empty($lineItem->endpoint)) {
278 $json->id = $lineItem->endpoint;
280 if (!empty($lineItem->label)) {
281 $json->label = $lineItem->label;
283 if (!empty($lineItem->pointsPossible)) {
284 $json->scoreMaximum = $lineItem->pointsPossible;
286 if (!empty($lineItem->ltiResourceLinkId)) {
287 $json->resourceLinkId = $lineItem->ltiResourceLinkId;
289 if (!empty($lineItem->resourceId)) {
290 $json->resourceId = $lineItem->resourceId;
292 if (!empty($lineItem->tag)) {
293 $json->tag = $lineItem->tag;
295 if (!empty($lineItem->submitFrom)) {
296 $json->startDateTime = date(
'Y-m-d\TH:i:sP', $lineItem->submitFrom);
298 if (!empty($lineItem->submitUntil)) {
299 $json->endDateTime = date(
'Y-m-d\TH:i:sP', $lineItem->submitUntil);
302 return json_encode($json);
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params