ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LSItemOnlineStatus.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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 = [
34  self::S_TEST,
35  self::S_SURVEY,
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 }
setOnlineStatus(int $ref_id, bool $status)
static _lookupObjId(int $ref_id)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
getObjectTypeFor(int $ref_id)
$ref_id
Definition: ltiauth.php:65
getOnlineStatus(int $ref_id)
hasChangeableOnlineStatus(int $ref_id)
static array $objs_with_check_for_online_status