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;
160 $http = $this->
send(
'POST', null, self::toJson($lineItem));
161 $ok =
$http->ok && !empty(
$http->responseJson);
164 foreach (get_object_vars($newLineItem) as
$key => $value) {
165 $lineItem->$key = $value;
179 $this->mediaType = self::MEDIA_TYPE_LINE_ITEM;
180 $http = $this->
send(
'PUT', null, self::toJson($lineItem));
182 if ($ok && !empty(
$http->responseJson)) {
183 $savedLineItem = self::toLineItem($this->
getPlatform(),
$http->responseJson);
184 foreach (get_object_vars($savedLineItem) as
$key => $value) {
185 $lineItem->$key = $value;
199 $this->mediaType = self::MEDIA_TYPE_LINE_ITEM;
214 $service->scope = self::$SCOPE_READONLY;
215 $service->mediaType = self::MEDIA_TYPE_LINE_ITEM;
218 if (
$http->ok && !empty(
$http->responseJson)) {
219 $lineItem = self::toLineItem($platform,
$http->responseJson);
239 if (!empty($json->id) && !empty($json->label) && !empty($json->scoreMaximum)) {
241 $lineItem = new \ILIAS\LTI\ToolProvider\LineItem($platform, $json->label, $json->scoreMaximum);
242 if (!empty($json->id)) {
243 $lineItem->endpoint = $json->id;
245 if (!empty($json->resourceLinkId)) {
246 $lineItem->ltiResourceLinkId = $json->resourceLinkId;
248 if (!empty($json->resourceId)) {
249 $lineItem->resourceId = $json->resourceId;
251 if (!empty($json->tag)) {
252 $lineItem->tag = $json->tag;
254 if (!empty($json->startDateTime)) {
255 $lineItem->submitFrom = strtotime($json->startDateTime);
257 if (!empty($json->endDateTime)) {
258 $lineItem->submitUntil = strtotime($json->endDateTime);
274 $json = new \stdClass();
275 if (!empty($lineItem->endpoint)) {
276 $json->id = $lineItem->endpoint;
278 if (!empty($lineItem->label)) {
279 $json->label = $lineItem->label;
281 if (!empty($lineItem->pointsPossible)) {
282 $json->scoreMaximum = $lineItem->pointsPossible;
284 if (!empty($lineItem->ltiResourceLinkId)) {
285 $json->resourceLinkId = $lineItem->ltiResourceLinkId;
287 if (!empty($lineItem->resourceId)) {
288 $json->resourceId = $lineItem->resourceId;
290 if (!empty($lineItem->tag)) {
291 $json->tag = $lineItem->tag;
293 if (!empty($lineItem->submitFrom)) {
294 $json->startDateTime = date(
'Y-m-d\TH:i:sP', $lineItem->submitFrom);
296 if (!empty($lineItem->submitUntil)) {
297 $json->endDateTime = date(
'Y-m-d\TH:i:sP', $lineItem->submitUntil);
300 return json_encode($json);
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(Container $dic, ilPlugin $plugin)