ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 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 type $ilDB. More...
 

Protected Member Functions

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

Protected Attributes

 $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 18 of file class.ilContainerStartObjects.php.

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

19  {
20  $this->setRefId($a_object_ref_id);
21  $this->setObjId($a_object_id);
22 
23  $this->__read();
24  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __deleteAll()

ilContainerStartObjects::__deleteAll ( )

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

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

146  {
147  global $ilDB;
148 
149  $query = "DELETE FROM crs_start".
150  " WHERE crs_id = ".$ilDB->quote($this->getObjId(), 'integer');
151  $ilDB->manipulate($query);
152  return true;
153  }
global $ilDB
+ Here is the call graph for this function:

◆ __read()

ilContainerStartObjects::__read ( )
protected

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

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

Referenced by __construct().

52  {
53  global $tree, $ilDB;
54 
55  $this->start_objs = array();
56 
57  $query = "SELECT * FROM crs_start".
58  " WHERE crs_id = ".$ilDB->quote($this->getObjId(), 'integer').
59  " ORDER BY pos, crs_start_id";
60  $res = $ilDB->query($query);
61  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
62  {
63  if($tree->isInTree($row->item_ref_id))
64  {
65  $this->start_objs[$row->crs_start_id]['item_ref_id'] = $row->item_ref_id;
66  }
67  else
68  {
69  $this->delete($row->item_ref_id);
70  }
71  }
72  return true;
73  }
Create styles array
The data for the language used.
global $ilDB
+ 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 119 of file class.ilContainerStartObjects.php.

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

Referenced by ilLOSettings\updateStartObjects().

120  {
121  global $ilDB;
122 
123  if($a_item_ref_id)
124  {
125  $max_pos = $ilDB->query("SELECT max(pos) pos FROM crs_start".
126  " WHERE crs_id = ".$ilDB->quote($this->getObjId(), "integer"));
127  $max_pos = $ilDB->fetchAssoc($max_pos);
128  $max_pos = ((int)$max_pos["pos"])+10;
129 
130  $next_id = $ilDB->nextId('crs_start');
131  $query = "INSERT INTO crs_start".
132  " (crs_start_id,crs_id,item_ref_id,pos)".
133  " VALUES".
134  " (".$ilDB->quote($next_id, 'integer').
135  ", ".$ilDB->quote($this->getObjId(), 'integer').
136  ", ".$ilDB->quote($a_item_ref_id, 'integer').
137  ", ".$ilDB->quote($max_pos, 'integer').
138  ")";
139  $ilDB->manipulate($query);
140  return true;
141  }
142  return false;
143  }
global $ilDB
+ 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 188 of file class.ilContainerStartObjects.php.

References getStartObjects(), and isFullfilled().

189  {
190  foreach($this->getStartObjects() as $item)
191  {
192  if(!$this->isFullfilled($a_user_id, $item['item_ref_id']))
193  {
194  return false;
195  }
196  }
197  return true;
198  }
+ Here is the call graph for this function:

◆ cloneDependencies()

ilContainerStartObjects::cloneDependencies (   $a_target_id,
  $a_copy_id 
)

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

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

249  {
250  global $ilObjDataCache, $ilLog;
251 
252  $ilLog->write(__METHOD__.': Begin course start objects...');
253 
254  $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
255  $start = new self($a_target_id, $new_obj_id);
256 
257  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
258  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
259  $mappings = $cwo->getMappings();
260  foreach($this->getStartObjects() as $data)
261  {
262  $item_ref_id = $data['item_ref_id'];
263  if(isset($mappings[$item_ref_id]) and $mappings[$item_ref_id])
264  {
265  $ilLog->write(__METHOD__.': Clone start object nr. '.$item_ref_id);
266  $start->add($mappings[$item_ref_id]);
267  }
268  else
269  {
270  $ilLog->write(__METHOD__.': No mapping found for start object nr. '.$item_ref_id);
271  }
272  }
273  $ilLog->write(__METHOD__.': ... end course start objects');
274  return true;
275  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
+ Here is the call graph for this function:

◆ delete()

ilContainerStartObjects::delete (   $a_crs_start_id)

Delete item by sequence id type $ilDB.

Parameters
type$a_crs_start_id
Returns
boolean

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

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

82  {
83  global $ilDB;
84 
85  $query = "DELETE FROM crs_start".
86  " WHERE crs_start_id = ".$ilDB->quote($a_crs_start_id, 'integer').
87  " AND crs_id = ".$ilDB->quote($this->getObjId(), 'integer');
88  $ilDB->manipulate($query);
89  return true;
90  }
global $ilDB
+ 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 96 of file class.ilContainerStartObjects.php.

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

Referenced by ilLOSettings\updateStartObjects().

97  {
98  global $ilDB;
99 
100  $query = "DELETE FROM crs_start".
101  " WHERE crs_id = ".$ilDB->quote($this->getObjId(), 'integer').
102  " AND item_ref_id = ".$ilDB->quote($a_item_ref_id, 'integer');
103  $ilDB->manipulate($query);
104  return true;
105  }
global $ilDB
+ 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 107 of file class.ilContainerStartObjects.php.

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

Referenced by ilLOSettings\updateStartObjects().

108  {
109  global $ilDB;
110 
111  $query = "SELECT * FROM crs_start".
112  " WHERE crs_id = ".$ilDB->quote($this->getObjId(), 'integer').
113  " AND item_ref_id = ".$ilDB->quote($a_item_ref_id, 'integer');
114  $res = $ilDB->query($query);
115 
116  return $res->numRows() ? true : false;
117  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjId()

ilContainerStartObjects::getObjId ( )

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

References $obj_id.

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

+ Here is the caller graph for this function:

◆ getPossibleStarters()

ilContainerStartObjects::getPossibleStarters ( )

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

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

171  {
172  include_once "Services/Object/classes/class.ilObjectActivation.php";
173  foreach(ilObjectActivation::getItems($this->getRefId(), false) as $node)
174  {
175  switch($node['type'])
176  {
177  case 'lm':
178  case 'sahs':
179  case 'svy':
180  case 'tst':
181  $poss_items[] = $node['ref_id'];
182  break;
183  }
184  }
185  return $poss_items ? $poss_items : array();
186  }
static getItems($a_parent_id, $a_with_list_data=true)
Get sub item data.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getRefId()

ilContainerStartObjects::getRefId ( )

Definition at line 41 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 46 of file class.ilContainerStartObjects.php.

References array.

Referenced by allFullfilled(), and cloneDependencies().

47  {
48  return $this->start_objs ? $this->start_objs : array();
49  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ isFullfilled()

ilContainerStartObjects::isFullfilled (   $a_user_id,
  $a_item_id 
)

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

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

Referenced by allFullfilled().

201  {
202  global $ilObjDataCache;
203 
204  $obj_id = $ilObjDataCache->lookupObjId($a_item_id);
205  $type = $ilObjDataCache->lookupType($obj_id);
206 
207  switch($type)
208  {
209  case 'tst':
210  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
211  if(!ilObjTestAccess::checkCondition($obj_id,'finished','',$a_user_id)) // #14000
212  {
213  return false;
214  }
215  break;
216 
217  case 'svy':
218 
219  include_once './Modules/Survey/classes/class.ilObjSurveyAccess.php';
221  {
222  return false;
223  }
224  break;
225 
226  case 'sahs':
227  include_once 'Services/Tracking/classes/class.ilLPStatus.php';
228  if(!ilLPStatus::_hasUserCompleted($obj_id, $a_user_id))
229  {
230  return false;
231  }
232  break;
233 
234  default:
235  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
236  $lm_continue = new ilCourseLMHistory($this->getRefId(), $a_user_id);
237  $continue_data = $lm_continue->getLMHistory();
238  if(!isset($continue_data[$a_item_id]))
239  {
240  return false;
241  }
242  break;
243  }
244 
245  return true;
246  }
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
class ilCourseLMHistory
+ 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 type $ilDB.

Parameters
type$a_container_id
type$a_item_ref_id
Returns
boolean

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

References $ilDB, $query, and $res.

Referenced by ilLOTestQuestionAdapter\isQualifiedStartRun().

285  {
286  global $ilDB;
287 
288  $query = 'SELECT crs_start_id FROM crs_start '.
289  'WHERE crs_id = '.$ilDB->quote($a_container_id,'integer').' '.
290  'AND item_ref_id = '.$ilDB->quote($a_item_ref_id,'integer');
291  $res = $ilDB->query($query);
292  if($res->numRows() >= 1)
293  {
294  return true;
295  }
296  return false;
297  }
global $ilDB
+ Here is the caller graph for this function:

◆ setObjectPos()

ilContainerStartObjects::setObjectPos (   $a_start_id,
  $a_pos 
)

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

References $ilDB, and getObjId().

156  {
157  global $ilDB;
158 
159  if(!(int)$a_start_id || !(int)$a_pos)
160  {
161  return;
162  }
163 
164  $ilDB->manipulate("UPDATE crs_start".
165  " SET pos = ".$ilDB->quote($a_pos, "integer").
166  " WHERE crs_id = ".$ilDB->quote($this->getObjId(), 'integer').
167  " AND crs_start_id = ".$ilDB->quote($a_start_id, 'integer'));
168  }
global $ilDB
+ Here is the call graph for this function:

◆ setObjId()

ilContainerStartObjects::setObjId (   $a_id)
protected

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

Referenced by __construct().

27  {
28  $this->obj_id = $a_id;
29  }
+ Here is the caller graph for this function:

◆ setRefId()

ilContainerStartObjects::setRefId (   $a_ref_id)
protected

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

Referenced by __construct().

37  {
38  $this->ref_id = $a_ref_id;
39  }
+ Here is the caller graph for this function:

Field Documentation

◆ $obj_id

ilContainerStartObjects::$obj_id
protected

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

Referenced by getObjId(), and isFullfilled().

◆ $ref_id

ilContainerStartObjects::$ref_id
protected

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

Referenced by getRefId().

◆ $start_objs

ilContainerStartObjects::$start_objs = array()
protected

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


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