ILIAS  release_8 Revision v8.24
class.ilObjRemoteTest.php
Go to the documentation of this file.
1<?php
2
18declare(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
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 {
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) {
132 return true;
133
135 return false;
136
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.
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
$query