ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilContainerStartObjects Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilContainerStartObjects:

Public Member Functions

 __construct (int $a_object_ref_id, int $a_object_id)
 
 getObjId ()
 
 getRefId ()
 
 getStartObjects ()
 
 delete (int $a_crs_start_id)
 
 deleteItem (int $a_item_ref_id)
 
 exists (int $a_item_ref_id)
 
 add (int $a_item_ref_id)
 
 setObjectPos (int $a_start_id, int $a_pos)
 
 getPossibleStarters ()
 
 allFullfilled (int $a_user_id)
 
 isFullfilled (int $a_user_id, int $a_item_id)
 
 cloneDependencies (int $a_target_id, int $a_copy_id)
 

Static Public Member Functions

static isStartObject (int $a_container_id, int $a_item_ref_id)
 

Protected Member Functions

 setObjId (int $a_id)
 
 setRefId (int $a_ref_id)
 
 read ()
 

Protected Attributes

ilTree $tree
 
ilDBInterface $db
 
ilObjectDataCache $obj_data_cache
 
ilLogger $log
 
int $ref_id
 
int $obj_id
 
array $start_objs = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning ilContainerStartObjects

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilContainerStartObjects::__construct ( int  $a_object_ref_id,
int  $a_object_id 
)

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

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

37  {
38  global $DIC;
39 
40  $this->tree = $DIC->repositoryTree();
41  $this->db = $DIC->database();
42  $this->obj_data_cache = $DIC["ilObjDataCache"];
43  $this->log = $DIC["ilLog"];
44  $this->setRefId($a_object_ref_id);
45  $this->setObjId($a_object_id);
46 
47  $this->read();
48  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilContainerStartObjects::add ( int  $a_item_ref_id)

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

References $db, $ilDB, getObjId(), and ILIAS\Repository\int().

Referenced by ilLOSettings\updateStartObjects().

127  : bool
128  {
129  $ilDB = $this->db;
130 
131  if ($a_item_ref_id) {
132  $max_pos = $ilDB->query("SELECT max(pos) pos FROM crs_start" .
133  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), "integer"));
134  $max_pos = $ilDB->fetchAssoc($max_pos);
135  $max_pos = ((int) $max_pos["pos"]) + 10;
136 
137  $next_id = $ilDB->nextId('crs_start');
138  $query = "INSERT INTO crs_start" .
139  " (crs_start_id,crs_id,item_ref_id,pos)" .
140  " VALUES" .
141  " (" . $ilDB->quote($next_id, 'integer') .
142  ", " . $ilDB->quote($this->getObjId(), 'integer') .
143  ", " . $ilDB->quote($a_item_ref_id, 'integer') .
144  ", " . $ilDB->quote($max_pos, 'integer') .
145  ")";
146  $ilDB->manipulate($query);
147  return true;
148  }
149  return false;
150  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ allFullfilled()

ilContainerStartObjects::allFullfilled ( int  $a_user_id)

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

References getStartObjects(), and isFullfilled().

185  : bool
186  {
187  foreach ($this->getStartObjects() as $item) {
188  if (!$this->isFullfilled($a_user_id, $item['item_ref_id'])) {
189  return false;
190  }
191  }
192  return true;
193  }
isFullfilled(int $a_user_id, int $a_item_id)
+ Here is the call graph for this function:

◆ cloneDependencies()

ilContainerStartObjects::cloneDependencies ( int  $a_target_id,
int  $a_copy_id 
)

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

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

238  : void {
239  $ilObjDataCache = $this->obj_data_cache;
240  $ilLog = $this->log;
241 
242  $ilLog->write(__METHOD__ . ': Begin course start objects...');
243 
244  $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
245  $start = new self($a_target_id, $new_obj_id);
246 
247  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
248  $mappings = $cwo->getMappings();
249  foreach ($this->getStartObjects() as $data) {
250  $item_ref_id = $data['item_ref_id'];
251  if (isset($mappings[$item_ref_id]) && $mappings[$item_ref_id]) {
252  $ilLog->write(__METHOD__ . ': Clone start object nr. ' . $item_ref_id);
253  $start->add($mappings[$item_ref_id]);
254  } else {
255  $ilLog->write(__METHOD__ . ': No mapping found for start object nr. ' . $item_ref_id);
256  }
257  }
258  $ilLog->write(__METHOD__ . ': ... end course start objects');
259  }
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ delete()

ilContainerStartObjects::delete ( int  $a_crs_start_id)

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

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

95  : void
96  {
97  $ilDB = $this->db;
98 
99  $query = "DELETE FROM crs_start" .
100  " WHERE crs_start_id = " . $ilDB->quote($a_crs_start_id, 'integer') .
101  " AND crs_id = " . $ilDB->quote($this->getObjId(), 'integer');
102  $ilDB->manipulate($query);
103  }
+ Here is the call graph for this function:

◆ deleteItem()

ilContainerStartObjects::deleteItem ( int  $a_item_ref_id)

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

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

Referenced by ilLOSettings\updateStartObjects().

105  : void
106  {
107  $ilDB = $this->db;
108 
109  $query = "DELETE FROM crs_start" .
110  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
111  " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
112  $ilDB->manipulate($query);
113  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exists()

ilContainerStartObjects::exists ( int  $a_item_ref_id)

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

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

Referenced by ilLOSettings\updateStartObjects().

115  : bool
116  {
117  $ilDB = $this->db;
118 
119  $query = "SELECT * FROM crs_start" .
120  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
121  " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
122  $res = $ilDB->query($query);
123 
124  return (bool) $res->numRows();
125  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjId()

ilContainerStartObjects::getObjId ( )

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

References $obj_id.

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

55  : int
56  {
57  return $this->obj_id;
58  }
+ Here is the caller graph for this function:

◆ getPossibleStarters()

ilContainerStartObjects::getPossibleStarters ( )

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

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

168  : array
169  {
170  $poss_items = [];
171  foreach (ilObjectActivation::getItems($this->getRefId(), false) as $node) {
172  switch ($node['type']) {
173  case 'lm':
174  case 'sahs':
175  case 'svy':
176  case 'copa':
177  case 'tst':
178  $poss_items[] = $node['ref_id'];
179  break;
180  }
181  }
182  return $poss_items;
183  }
static getItems(int $parent_id, bool $with_list_data=true)
Get sub item data.
+ Here is the call graph for this function:

◆ getRefId()

ilContainerStartObjects::getRefId ( )

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

References $ref_id.

Referenced by getPossibleStarters(), and isFullfilled().

65  : int
66  {
67  return $this->ref_id;
68  }
+ Here is the caller graph for this function:

◆ getStartObjects()

ilContainerStartObjects::getStartObjects ( )

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

Referenced by allFullfilled(), and cloneDependencies().

70  : array
71  {
72  return $this->start_objs ?: [];
73  }
+ Here is the caller graph for this function:

◆ isFullfilled()

ilContainerStartObjects::isFullfilled ( int  $a_user_id,
int  $a_item_id 
)

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

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

Referenced by allFullfilled().

195  : bool
196  {
197  $ilObjDataCache = $this->obj_data_cache;
198 
199  $obj_id = $ilObjDataCache->lookupObjId($a_item_id);
200  $type = $ilObjDataCache->lookupType($obj_id);
201 
202  switch ($type) {
203  case 'tst':
204  if (!ilObjTestAccess::checkCondition($obj_id, 'finished', '', $a_user_id)) { // #14000
205  return false;
206  }
207  break;
208 
209  case 'svy':
210 
211  if (!ilObjSurveyAccess::_lookupFinished($obj_id, $a_user_id)) {
212  return false;
213  }
214  break;
215 
216  case 'copa':
217  case 'sahs':
218  if (!ilLPStatus::_hasUserCompleted($obj_id, $a_user_id)) {
219  return false;
220  }
221  break;
222 
223  default:
224  $lm_continue = new ilCourseLMHistory($this->getRefId(), $a_user_id);
225  $continue_data = $lm_continue->getLMHistory();
226  if (!isset($continue_data[$a_item_id])) {
227  return false;
228  }
229  break;
230  }
231 
232  return true;
233  }
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
static _lookupFinished(int $a_obj_id, int $a_user_id=0)
get finished status
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $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 ( int  $a_container_id,
int  $a_item_ref_id 
)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilLOTestQuestionAdapter\isQualifiedStartRun().

264  : bool {
265  global $DIC;
266 
267  $ilDB = $DIC->database();
268 
269  $query = 'SELECT crs_start_id FROM crs_start ' .
270  'WHERE crs_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
271  'AND item_ref_id = ' . $ilDB->quote($a_item_ref_id, 'integer');
272  $res = $ilDB->query($query);
273 
274  return $res->numRows() >= 1;
275  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ read()

ilContainerStartObjects::read ( )
protected

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

References $db, $ilDB, $res, $tree, ilDBConstants\FETCHMODE_OBJECT, getObjId(), ILIAS\Repository\int(), and ilTree\isInTree().

Referenced by __construct().

75  : void
76  {
78  $ilDB = $this->db;
79 
80  $this->start_objs = [];
81 
82  $query = "SELECT * FROM crs_start" .
83  " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
84  " ORDER BY pos, crs_start_id";
85  $res = $ilDB->query($query);
86  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87  if ($tree->isInTree($row->item_ref_id)) {
88  $this->start_objs[$row->crs_start_id]['item_ref_id'] = (int) $row->item_ref_id;
89  } else {
90  $this->delete((int) $row->item_ref_id);
91  }
92  }
93  }
$res
Definition: ltiservices.php:66
isInTree(?int $a_node_id)
get all information of a node.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjectPos()

ilContainerStartObjects::setObjectPos ( int  $a_start_id,
int  $a_pos 
)

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

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

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

◆ setObjId()

ilContainerStartObjects::setObjId ( int  $a_id)
protected

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

Referenced by __construct().

50  : void
51  {
52  $this->obj_id = $a_id;
53  }
+ Here is the caller graph for this function:

◆ setRefId()

ilContainerStartObjects::setRefId ( int  $a_ref_id)
protected

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

Referenced by __construct().

60  : void
61  {
62  $this->ref_id = $a_ref_id;
63  }
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilContainerStartObjects::$db
protected

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

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

◆ $log

ilLogger ilContainerStartObjects::$log
protected

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

Referenced by cloneDependencies().

◆ $obj_data_cache

ilObjectDataCache ilContainerStartObjects::$obj_data_cache
protected

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

Referenced by cloneDependencies(), and isFullfilled().

◆ $obj_id

int ilContainerStartObjects::$obj_id
protected

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

Referenced by getObjId().

◆ $ref_id

int ilContainerStartObjects::$ref_id
protected

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

Referenced by getRefId().

◆ $start_objs

array ilContainerStartObjects::$start_objs = []
protected

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

◆ $tree

ilTree ilContainerStartObjects::$tree
protected

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

Referenced by read().


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