ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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. 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. 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.

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

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
+ Here is the call graph for this function:

Member Function Documentation

◆ __deleteAll()

ilContainerStartObjects::__deleteAll ( )

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

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

167  {
168  $ilDB = $this->db;
169 
170  $query = "DELETE FROM crs_start" .
171  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer');
172  $ilDB->manipulate($query);
173  return true;
174  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ __read()

ilContainerStartObjects::__read ( )
protected

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

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

Referenced by __construct().

78  {
80  $ilDB = $this->db;
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
$query
$row
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 141 of file class.ilContainerStartObjects.php.

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

Referenced by ilLOSettings\updateStartObjects().

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

References getStartObjects(), and isFullfilled().

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  }
+ Here is the call graph for this function:

◆ cloneDependencies()

ilContainerStartObjects::cloneDependencies (   $a_target_id,
  $a_copy_id 
)

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

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

267  {
268  $ilObjDataCache = $this->obj_data_cache;
269  $ilLog = $this->log;
270 
271  $ilLog->write(__METHOD__ . ': Begin course start objects...');
272 
273  $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
274  $start = new self($a_target_id, $new_obj_id);
275 
276  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
277  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
278  $mappings = $cwo->getMappings();
279  foreach ($this->getStartObjects() as $data) {
280  $item_ref_id = $data['item_ref_id'];
281  if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
282  $ilLog->write(__METHOD__ . ': Clone start object nr. ' . $item_ref_id);
283  $start->add($mappings[$item_ref_id]);
284  } else {
285  $ilLog->write(__METHOD__ . ': No mapping found for start object nr. ' . $item_ref_id);
286  }
287  }
288  $ilLog->write(__METHOD__ . ': ... end course start objects');
289  return true;
290  }
$start
Definition: bench.php:8
static _getInstance($a_copy_id)
Get instance of copy wizard options.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ delete()

ilContainerStartObjects::delete (   $a_crs_start_id)

Delete item by sequence id.

Parameters
type$a_crs_start_id
Returns
boolean

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

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

104  {
105  $ilDB = $this->db;
106 
107  $query = "DELETE FROM crs_start" .
108  " WHERE crs_start_id = " . $ilDB->quote($a_crs_start_id, 'integer') .
109  " AND crs_id = " . $ilDB->quote($this->getObjId(), 'integer');
110  $ilDB->manipulate($query);
111  return true;
112  }
$query
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 118 of file class.ilContainerStartObjects.php.

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

Referenced by ilLOSettings\updateStartObjects().

119  {
120  $ilDB = $this->db;
121 
122  $query = "DELETE FROM crs_start" .
123  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
124  " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
125  $ilDB->manipulate($query);
126  return true;
127  }
$query
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 129 of file class.ilContainerStartObjects.php.

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

Referenced by ilLOSettings\updateStartObjects().

130  {
131  $ilDB = $this->db;
132 
133  $query = "SELECT * FROM crs_start" .
134  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
135  " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
136  $res = $ilDB->query($query);
137 
138  return $res->numRows() ? true : false;
139  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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(), exists(), and setObjectPos().

+ Here is the caller graph for this function:

◆ getPossibleStarters()

ilContainerStartObjects::getPossibleStarters ( )

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

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

191  {
192  include_once "Services/Object/classes/class.ilObjectActivation.php";
193  foreach (ilObjectActivation::getItems($this->getRefId(), false) as $node) {
194  switch ($node['type']) {
195  case 'lm':
196  case 'sahs':
197  case 'copa':
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.
+ 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.

Referenced by allFullfilled(), and cloneDependencies().

73  {
74  return $this->start_objs ? $this->start_objs : array();
75  }
+ 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.

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

Referenced by allFullfilled().

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';
235  if (!ilObjSurveyAccess::_lookupFinished($obj_id, $a_user_id)) {
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  case 'copa':
248  if (!ilLPStatus::_hasUserCompleted($obj_id, $a_user_id)) {
249  return false;
250  }
251  break;
252 
253  default:
254  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
255  $lm_continue = new ilCourseLMHistory($this->getRefId(), $a_user_id);
256  $continue_data = $lm_continue->getLMHistory();
257  if (!isset($continue_data[$a_item_id])) {
258  return false;
259  }
260  break;
261  }
262 
263  return true;
264  }
$type
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.

Parameters
type$a_container_id
type$a_item_ref_id
Returns
boolean

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

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

Referenced by ilLOTestQuestionAdapter\isQualifiedStartRun().

299  {
300  global $DIC;
301 
302  $ilDB = $DIC->database();
303 
304  $query = 'SELECT crs_start_id FROM crs_start ' .
305  'WHERE crs_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
306  'AND item_ref_id = ' . $ilDB->quote($a_item_ref_id, 'integer');
307  $res = $ilDB->query($query);
308  if ($res->numRows() >= 1) {
309  return true;
310  }
311  return false;
312  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ setObjectPos()

ilContainerStartObjects::setObjectPos (   $a_start_id,
  $a_pos 
)

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

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

177  {
178  $ilDB = $this->db;
179 
180  if (!(int) $a_start_id || !(int) $a_pos) {
181  return;
182  }
183 
184  $ilDB->manipulate("UPDATE crs_start" .
185  " SET pos = " . $ilDB->quote($a_pos, "integer") .
186  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
187  " AND crs_start_id = " . $ilDB->quote($a_start_id, 'integer'));
188  }
global $ilDB
+ Here is the call graph for this function:

◆ setObjId()

ilContainerStartObjects::setObjId (   $a_id)
protected

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

Referenced by __construct().

53  {
54  $this->obj_id = $a_id;
55  }
+ Here is the caller graph for this function:

◆ setRefId()

ilContainerStartObjects::setRefId (   $a_ref_id)
protected

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

Referenced by __construct().

63  {
64  $this->ref_id = $a_ref_id;
65  }
+ 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: