ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjRemoteTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
31{
32 public const DB_TABLE_NAME = "rtst_settings";
33
34 public const ACTIVATION_OFFLINE = 0;
35 public const ACTIVATION_UNLIMITED = 1;
36 public const ACTIVATION_LIMITED = 2;
37
39 protected $end;
40 protected $start;
41
42 public function initType(): void
43 {
44 $this->type = "rtst";
45 }
46
47 protected function getTableName(): string
48 {
50 }
51
52 protected function getECSObjectType(): string
53 {
54 return "/campusconnect/tests";
55 }
56
62 public function setAvailabilityType($a_type)
63 {
64 $this->availability_type = $a_type;
65 }
66
72 public function getAvailabilityType()
73 {
75 }
76
82 public function setStartingTime($a_time)
83 {
84 $this->start = $a_time;
85 }
86
92 public function getStartingTime()
93 {
94 return $this->start;
95 }
96
102 public function setEndingTime($a_time)
103 {
104 $this->end = $a_time;
105 }
106
112 public function getEndingTime()
113 {
114 return $this->end;
115 }
116
123 public static function _lookupOnline($a_obj_id)
124 {
125 global $ilDB;
126
127 $query = "SELECT * FROM " . self::DB_TABLE_NAME .
128 " WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
129 $res = $ilDB->query($query);
130 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
131 switch ($row->availability_type) {
133 return true;
134
136 return false;
137
139 return time() > $row->r_start && time < $row->r_end;
140
141 default:
142 return false;
143 }
144
145 return false;
146 }
147
148 protected function doCreateCustomFields(array &$a_fields): void
149 {
150 $a_fields["availability_type"] = array("integer", 0);
151 $a_fields["availability_start"] = array("integer", 0);
152 $a_fields["availability_end"] = array("integer", 0);
153 }
154
155 protected function doUpdateCustomFields(array &$a_fields): void
156 {
157 $a_fields["availability_type"] = array("integer", $this->getAvailabilityType());
158 $a_fields["availability_start"] = array("integer",(int) $this->getStartingTime());
159 $a_fields["availability_end"] = array("integer", (int) $this->getEndingTime());
160 }
161
162 protected function doReadCustomFields($a_row): void
163 {
164 $this->setAvailabilityType($a_row->availability_type);
165 $this->setStartingTime($a_row->availability_start);
166 $this->setEndingTime($a_row->availability_end);
167 }
168
169 protected function updateCustomFromECSContent(ilECSSetting $a_server, $a_ecs_content): void
170 {
171 // add custom values
172 // $this->setAvailabilityType($a_ecs_content->status == 'online' ? self::ACTIVATION_UNLIMITED : self::ACTIVATION_OFFLINE);
173
174 // :TODO: ACTIVATION_LIMITED is currently not supported in ECS yet
175 }
176}
Remote test app class.
setEndingTime($a_time)
set ending time
getECSObjectType()
Get ECS resource identifier, e.g.
doCreateCustomFields(array &$a_fields)
Add custom fields to db insert.
updateCustomFromECSContent(ilECSSetting $a_server, $a_ecs_content)
update remote object settings from ecs content
getTableName()
Get db table name.
getStartingTime()
get starting time
static _lookupOnline($a_obj_id)
Lookup online.
setStartingTime($a_time)
set starting time
setAvailabilityType($a_type)
Set Availability type.
getAvailabilityType()
get availability type
doUpdateCustomFields(array &$a_fields)
Add custom fields to db update.
getEndingTime()
get ending time
Remote object app base class.
$res
Definition: ltiservices.php:69