ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilContainerStartObjects Class Reference

ilContainerStartObjects More...

+ Collaboration diagram for ilContainerStartObjects:

Public Member Functions

 __construct ($a_object_ref_id, $a_object_id)
 
 getObjId ()
 
 getRefId ()
 
 getStartObjects ()
 
 delete ($a_crs_start_id)
 Delete item by sequence id @global type $ilDB. More...
 
 deleteItem ($a_item_ref_id)
 Delete item by ref_id. More...
 
 exists ($a_item_ref_id)
 
 add ($a_item_ref_id)
 
 __deleteAll ()
 
 setObjectPos ($a_start_id, $a_pos)
 
 getPossibleStarters ()
 
 allFullfilled ($a_user_id)
 
 isFullfilled ($a_user_id, $a_item_id)
 
 cloneDependencies ($a_target_id, $a_copy_id)
 

Static Public Member Functions

static isStartObject ($a_container_id, $a_item_ref_id)
 Check if object is start object @global type $ilDB. More...
 

Protected Member Functions

 setObjId ($a_id)
 
 setRefId ($a_ref_id)
 
 __read ()
 

Protected Attributes

 $tree
 
 $db
 
 $obj_data_cache
 
 $log
 
 $ref_id
 
 $obj_id
 
 $start_objs = array()
 

Detailed Description

ilContainerStartObjects

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilCourseStart.php 44362 2013-08-22 08:36:03Z jluetzen

Definition at line 12 of file class.ilContainerStartObjects.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerStartObjects::__construct (   $a_object_ref_id,
  $a_object_id 
)

Definition at line 38 of file class.ilContainerStartObjects.php.

39 {
40 global $DIC;
41
42 $this->tree = $DIC->repositoryTree();
43 $this->db = $DIC->database();
44 $this->obj_data_cache = $DIC["ilObjDataCache"];
45 $this->log = $DIC["ilLog"];
46 $this->setRefId($a_object_ref_id);
47 $this->setObjId($a_object_id);
48
49 $this->__read();
50 }
global $DIC
Definition: saml.php:7

References $DIC, __read(), setObjId(), and setRefId().

+ Here is the call graph for this function:

Member Function Documentation

◆ __deleteAll()

ilContainerStartObjects::__deleteAll ( )

Definition at line 167 of file class.ilContainerStartObjects.php.

168 {
170
171 $query = "DELETE FROM crs_start" .
172 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer');
173 $ilDB->manipulate($query);
174 return true;
175 }
$query
global $ilDB

References $db, $ilDB, $query, and getObjId().

+ Here is the call graph for this function:

◆ __read()

ilContainerStartObjects::__read ( )
protected

Definition at line 77 of file class.ilContainerStartObjects.php.

78 {
81
82 $this->start_objs = array();
83
84 $query = "SELECT * FROM crs_start" .
85 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
86 " ORDER BY pos, crs_start_id";
87 $res = $ilDB->query($query);
88 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
89 if ($tree->isInTree($row->item_ref_id)) {
90 $this->start_objs[$row->crs_start_id]['item_ref_id'] = $row->item_ref_id;
91 } else {
92 $this->delete($row->item_ref_id);
93 }
94 }
95 return true;
96 }
foreach($_POST as $key=> $value) $res

References $db, $ilDB, $query, $res, $row, $tree, ilDBConstants\FETCHMODE_OBJECT, and getObjId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

ilContainerStartObjects::add (   $a_item_ref_id)

Definition at line 142 of file class.ilContainerStartObjects.php.

143 {
145
146 if ($a_item_ref_id) {
147 $max_pos = $ilDB->query("SELECT max(pos) pos FROM crs_start" .
148 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), "integer"));
149 $max_pos = $ilDB->fetchAssoc($max_pos);
150 $max_pos = ((int) $max_pos["pos"])+10;
151
152 $next_id = $ilDB->nextId('crs_start');
153 $query = "INSERT INTO crs_start" .
154 " (crs_start_id,crs_id,item_ref_id,pos)" .
155 " VALUES" .
156 " (" . $ilDB->quote($next_id, 'integer') .
157 ", " . $ilDB->quote($this->getObjId(), 'integer') .
158 ", " . $ilDB->quote($a_item_ref_id, 'integer') .
159 ", " . $ilDB->quote($max_pos, 'integer') .
160 ")";
161 $ilDB->manipulate($query);
162 return true;
163 }
164 return false;
165 }

References $db, $ilDB, $query, and getObjId().

Referenced by ilLOSettings\updateStartObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ allFullfilled()

ilContainerStartObjects::allFullfilled (   $a_user_id)

Definition at line 207 of file class.ilContainerStartObjects.php.

208 {
209 foreach ($this->getStartObjects() as $item) {
210 if (!$this->isFullfilled($a_user_id, $item['item_ref_id'])) {
211 return false;
212 }
213 }
214 return true;
215 }

References getStartObjects(), and isFullfilled().

+ Here is the call graph for this function:

◆ cloneDependencies()

ilContainerStartObjects::cloneDependencies (   $a_target_id,
  $a_copy_id 
)

Definition at line 260 of file class.ilContainerStartObjects.php.

261 {
262 $ilObjDataCache = $this->obj_data_cache;
264
265 $ilLog->write(__METHOD__ . ': Begin course start objects...');
266
267 $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
268 $start = new self($a_target_id, $new_obj_id);
269
270 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
271 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
272 $mappings = $cwo->getMappings();
273 foreach ($this->getStartObjects() as $data) {
274 $item_ref_id = $data['item_ref_id'];
275 if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
276 $ilLog->write(__METHOD__ . ': Clone start object nr. ' . $item_ref_id);
277 $start->add($mappings[$item_ref_id]);
278 } else {
279 $ilLog->write(__METHOD__ . ': No mapping found for start object nr. ' . $item_ref_id);
280 }
281 }
282 $ilLog->write(__METHOD__ . ': ... end course start objects');
283 return true;
284 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.

References $data, $ilLog, $log, $obj_data_cache, ilCopyWizardOptions\_getInstance(), and getStartObjects().

+ Here is the call graph for this function:

◆ delete()

ilContainerStartObjects::delete (   $a_crs_start_id)

Delete item by sequence id @global type $ilDB.

Parameters
type$a_crs_start_id
Returns
boolean

Definition at line 104 of file class.ilContainerStartObjects.php.

105 {
107
108 $query = "DELETE FROM crs_start" .
109 " WHERE crs_start_id = " . $ilDB->quote($a_crs_start_id, 'integer') .
110 " AND crs_id = " . $ilDB->quote($this->getObjId(), 'integer');
111 $ilDB->manipulate($query);
112 return true;
113 }

References $db, $ilDB, $query, and getObjId().

+ Here is the call graph for this function:

◆ deleteItem()

ilContainerStartObjects::deleteItem (   $a_item_ref_id)

Delete item by ref_id.

Parameters
type$a_item_ref_id

Definition at line 119 of file class.ilContainerStartObjects.php.

120 {
122
123 $query = "DELETE FROM crs_start" .
124 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
125 " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
126 $ilDB->manipulate($query);
127 return true;
128 }

References $db, $ilDB, $query, and getObjId().

Referenced by ilLOSettings\updateStartObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exists()

ilContainerStartObjects::exists (   $a_item_ref_id)

Definition at line 130 of file class.ilContainerStartObjects.php.

131 {
133
134 $query = "SELECT * FROM crs_start" .
135 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
136 " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
137 $res = $ilDB->query($query);
138
139 return $res->numRows() ? true : false;
140 }

References $db, $ilDB, $query, $res, and getObjId().

Referenced by ilLOSettings\updateStartObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjId()

ilContainerStartObjects::getObjId ( )

Definition at line 57 of file class.ilContainerStartObjects.php.

References $obj_id.

Referenced by __deleteAll(), __read(), add(), delete(), deleteItem(), and exists().

+ Here is the caller graph for this function:

◆ getPossibleStarters()

ilContainerStartObjects::getPossibleStarters ( )

Definition at line 191 of file class.ilContainerStartObjects.php.

192 {
193 include_once "Services/Object/classes/class.ilObjectActivation.php";
194 foreach (ilObjectActivation::getItems($this->getRefId(), false) as $node) {
195 switch ($node['type']) {
196 case 'lm':
197 case 'sahs':
198 case 'svy':
199 case 'tst':
200 $poss_items[] = $node['ref_id'];
201 break;
202 }
203 }
204 return $poss_items ? $poss_items : array();
205 }
static getItems($a_parent_id, $a_with_list_data=true)
Get sub item data.

References ilObjectActivation\getItems(), and getRefId().

+ Here is the call graph for this function:

◆ getRefId()

ilContainerStartObjects::getRefId ( )

Definition at line 67 of file class.ilContainerStartObjects.php.

References $ref_id.

Referenced by getPossibleStarters(), and isFullfilled().

+ Here is the caller graph for this function:

◆ getStartObjects()

ilContainerStartObjects::getStartObjects ( )

Definition at line 72 of file class.ilContainerStartObjects.php.

73 {
74 return $this->start_objs ? $this->start_objs : array();
75 }

Referenced by allFullfilled(), and cloneDependencies().

+ Here is the caller graph for this function:

◆ isFullfilled()

ilContainerStartObjects::isFullfilled (   $a_user_id,
  $a_item_id 
)

Definition at line 217 of file class.ilContainerStartObjects.php.

218 {
219 $ilObjDataCache = $this->obj_data_cache;
220
221 $obj_id = $ilObjDataCache->lookupObjId($a_item_id);
222 $type = $ilObjDataCache->lookupType($obj_id);
223
224 switch ($type) {
225 case 'tst':
226 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
227 if (!ilObjTestAccess::checkCondition($obj_id, 'finished', '', $a_user_id)) { // #14000
228 return false;
229 }
230 break;
231
232 case 'svy':
233
234 include_once './Modules/Survey/classes/class.ilObjSurveyAccess.php';
236 return false;
237 }
238 break;
239
240 case 'sahs':
241 include_once 'Services/Tracking/classes/class.ilLPStatus.php';
242 if (!ilLPStatus::_hasUserCompleted($obj_id, $a_user_id)) {
243 return false;
244 }
245 break;
246
247 default:
248 include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
249 $lm_continue = new ilCourseLMHistory($this->getRefId(), $a_user_id);
250 $continue_data = $lm_continue->getLMHistory();
251 if (!isset($continue_data[$a_item_id])) {
252 return false;
253 }
254 break;
255 }
256
257 return true;
258 }
class ilCourseLMHistory
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static _lookupFinished($a_obj_id, $a_user_id="")
get finished status
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
$type

References $obj_data_cache, $obj_id, $type, ilLPStatus\_hasUserCompleted(), ilObjSurveyAccess\_lookupFinished(), ilObjTestAccess\checkCondition(), and getRefId().

Referenced by allFullfilled().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isStartObject()

static ilContainerStartObjects::isStartObject (   $a_container_id,
  $a_item_ref_id 
)
static

Check if object is start object @global type $ilDB.

Parameters
type$a_container_id
type$a_item_ref_id
Returns
boolean

Definition at line 293 of file class.ilContainerStartObjects.php.

294 {
295 global $DIC;
296
297 $ilDB = $DIC->database();
298
299 $query = 'SELECT crs_start_id FROM crs_start ' .
300 'WHERE crs_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
301 'AND item_ref_id = ' . $ilDB->quote($a_item_ref_id, 'integer');
302 $res = $ilDB->query($query);
303 if ($res->numRows() >= 1) {
304 return true;
305 }
306 return false;
307 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilLOTestQuestionAdapter\isQualifiedStartRun().

+ Here is the caller graph for this function:

◆ setObjectPos()

ilContainerStartObjects::setObjectPos (   $a_start_id,
  $a_pos 
)

Definition at line 177 of file class.ilContainerStartObjects.php.

178 {
180
181 if (!(int) $a_start_id || !(int) $a_pos) {
182 return;
183 }
184
185 $ilDB->manipulate("UPDATE crs_start" .
186 " SET pos = " . $ilDB->quote($a_pos, "integer") .
187 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
188 " AND crs_start_id = " . $ilDB->quote($a_start_id, 'integer'));
189 }

References $db, and $ilDB.

◆ setObjId()

ilContainerStartObjects::setObjId (   $a_id)
protected

Definition at line 52 of file class.ilContainerStartObjects.php.

53 {
54 $this->obj_id = $a_id;
55 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRefId()

ilContainerStartObjects::setRefId (   $a_ref_id)
protected

Definition at line 62 of file class.ilContainerStartObjects.php.

63 {
64 $this->ref_id = $a_ref_id;
65 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilContainerStartObjects::$db
protected

◆ $log

ilContainerStartObjects::$log
protected

Definition at line 32 of file class.ilContainerStartObjects.php.

Referenced by cloneDependencies().

◆ $obj_data_cache

ilContainerStartObjects::$obj_data_cache
protected

Definition at line 27 of file class.ilContainerStartObjects.php.

Referenced by cloneDependencies(), and isFullfilled().

◆ $obj_id

ilContainerStartObjects::$obj_id
protected

Definition at line 35 of file class.ilContainerStartObjects.php.

Referenced by getObjId(), and isFullfilled().

◆ $ref_id

ilContainerStartObjects::$ref_id
protected

Definition at line 34 of file class.ilContainerStartObjects.php.

Referenced by getRefId().

◆ $start_objs

ilContainerStartObjects::$start_objs = array()
protected

Definition at line 36 of file class.ilContainerStartObjects.php.

◆ $tree

ilContainerStartObjects::$tree
protected

Definition at line 17 of file class.ilContainerStartObjects.php.

Referenced by __read().


The documentation for this class was generated from the following file: