ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjRemoteTest.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
30 {
31  public const DB_TABLE_NAME = "rtst_settings";
32 
33  public const ACTIVATION_OFFLINE = 0;
34  public const ACTIVATION_UNLIMITED = 1;
35  public const ACTIVATION_LIMITED = 2;
36 
37  protected $availability_type;
38  protected $end;
39  protected $start;
40 
41  public function initType(): void
42  {
43  $this->type = "rtst";
44  }
45 
46  protected function getTableName(): string
47  {
48  return self::DB_TABLE_NAME;
49  }
50 
51  protected function getECSObjectType(): string
52  {
53  return "/campusconnect/tests";
54  }
55 
61  public function setAvailabilityType($a_type)
62  {
63  $this->availability_type = $a_type;
64  }
65 
71  public function getAvailabilityType()
72  {
74  }
75 
81  public function setStartingTime($a_time)
82  {
83  $this->start = $a_time;
84  }
85 
91  public function getStartingTime()
92  {
93  return $this->start;
94  }
95 
101  public function setEndingTime($a_time)
102  {
103  $this->end = $a_time;
104  }
105 
111  public function getEndingTime()
112  {
113  return $this->end;
114  }
115 
122  public static function _lookupOnline($a_obj_id)
123  {
124  global $ilDB;
125 
126  $query = "SELECT * FROM " . self::DB_TABLE_NAME .
127  " WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
128  $res = $ilDB->query($query);
129  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
130  switch ($row->availability_type) {
131  case self::ACTIVATION_UNLIMITED:
132  return true;
133 
134  case self::ACTIVATION_OFFLINE:
135  return false;
136 
137  case self::ACTIVATION_LIMITED:
138  return time() > $row->r_start && time < $row->r_end;
139 
140  default:
141  return false;
142  }
143 
144  return false;
145  }
146 
147  protected function doCreateCustomFields(array &$a_fields): void
148  {
149  $a_fields["availability_type"] = array("integer", 0);
150  $a_fields["availability_start"] = array("integer", 0);
151  $a_fields["availability_end"] = array("integer", 0);
152  }
153 
154  protected function doUpdateCustomFields(array &$a_fields): void
155  {
156  $a_fields["availability_type"] = array("integer", $this->getAvailabilityType());
157  $a_fields["availability_start"] = array("integer",(int) $this->getStartingTime());
158  $a_fields["availability_end"] = array("integer", (int) $this->getEndingTime());
159  }
160 
161  protected function doReadCustomFields($a_row): void
162  {
163  $this->setAvailabilityType($a_row->availability_type);
164  $this->setStartingTime($a_row->availability_start);
165  $this->setEndingTime($a_row->availability_end);
166  }
167 
168  protected function updateCustomFromECSContent(ilECSSetting $a_server, $a_ecs_content): void
169  {
170  // add custom values
171  // $this->setAvailabilityType($a_ecs_content->status == 'online' ? self::ACTIVATION_UNLIMITED : self::ACTIVATION_OFFLINE);
172 
173  // :TODO: ACTIVATION_LIMITED is currently not supported in ECS yet
174  }
175 }
Remote test app class.
$res
Definition: ltiservices.php:69
setEndingTime($a_time)
set ending time
doCreateCustomFields(array &$a_fields)
getEndingTime()
get ending time
setStartingTime($a_time)
set starting time
$query
Remote object app base class.
updateCustomFromECSContent(ilECSSetting $a_server, $a_ecs_content)
setAvailabilityType($a_type)
Set Availability type.
getAvailabilityType()
get availability type
getStartingTime()
get starting time
doUpdateCustomFields(array &$a_fields)
static _lookupOnline($a_obj_id)
Lookup online.