ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LSItemOnlineStatus.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public const S_LEARNMODULE_IL = "lm";
24 public const S_LEARNMODULE_HTML = "htlm";
25 public const S_SAHS = "sahs";
26 public const S_TEST = "tst";
27 public const S_SURVEY = "svy";
28 public const S_CONTENTPAGE = "copa";
29 public const S_EXERCISE = "exc";
30 public const S_IND_ASSESSMENT = "iass";
31 public const S_FILE = "file";
32
33 private static array $objs_with_check_for_online_status = [
36 ];
37
38 public function setOnlineStatus(int $ref_id, bool $status): void
39 {
40 $obj = $this->getObject($ref_id);
41 $props = $obj->getObjectProperties()->getPropertyIsOnline();
42 $props = $status ? $props->withOnline() : $props->withOffline();
43 $obj->getObjectProperties()->storePropertyIsOnline($props);
44 }
45
46 public function getOnlineStatus(int $ref_id): bool
47 {
49 }
50
51 public function hasChangeableOnlineStatus(int $ref_id): bool
52 {
53 $obj_type = $this->getObjectTypeFor($ref_id);
54 if(! in_array($obj_type, self::$objs_with_check_for_online_status)) {
55 return true;
56 }
57
58 $obj = $this->getObject($ref_id);
59 if($obj_type === self::S_SURVEY) {
60 return $obj->hasQuestions();
61 }
62 if($obj_type === self::S_TEST) {
63 return count($obj->getQuestions()) > 0;
64 }
65 return false;
66 }
67
68 protected function getObjectTypeFor(int $ref_id): string
69 {
70 return \ilObject::_lookupType($ref_id, true);
71 }
72
73 protected function getObject(int $ref_id): \ilObject
74 {
75 return \ilObjectFactory::getInstanceByRefId($ref_id);
76 }
77
78}
hasChangeableOnlineStatus(int $ref_id)
static array $objs_with_check_for_online_status
getObjectTypeFor(int $ref_id)
setOnlineStatus(int $ref_id, bool $status)
getOnlineStatus(int $ref_id)
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
$ref_id
Definition: ltiauth.php:66