ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCourseStart 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 ilCourseStart:

Public Member Functions

 __construct ($a_course_ref_id, $a_course_obj_id)
 
 setId (int $a_id)
 
 getId ()
 
 setRefId (int $a_ref_id)
 
 getRefId ()
 
 getStartObjects ()
 
 cloneDependencies (int $a_target_id, int $a_copy_id)
 
 delete (int $a_crs_start_id)
 
 exists (int $a_item_ref_id)
 
 add (int $a_item_ref_id)
 
 getPossibleStarters ()
 
 allFullfilled ($user_id)
 
 isFullfilled (int $user_id, int $item_id)
 
 __read ()
 

Protected Attributes

ilDBInterface $db
 
ilLogger $logger
 
ilObjectDataCache $objectDataCache
 
ilTree $tree
 

Private Attributes

int $ref_id
 
int $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

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

Definition at line 23 of file class.ilCourseStart.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseStart::__construct (   $a_course_ref_id,
  $a_course_obj_id 
)

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

References $DIC, __read(), and ILIAS\Repository\logger().

35  {
36  global $DIC;
37 
38  $this->db = $DIC->database();
39  $this->objectDataCache = $DIC['ilObjDataCache'];
40  $this->logger = $DIC->logger()->crs();
41 
42  $this->ref_id = $a_course_ref_id;
43  $this->id = $a_course_obj_id;
44  $this->__read();
45  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilCourseStart::__read ( )

Definition at line 184 of file class.ilCourseStart.php.

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, getId(), and ILIAS\Repository\int().

Referenced by __construct().

184  : void
185  {
186  $this->start_objs = array();
187  $query = "SELECT * FROM crs_start " .
188  "WHERE crs_id = " . $this->db->quote($this->getId(), 'integer') . " ";
189  $res = $this->db->query($query);
190  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
191  if ($this->tree->isInTree((int) $row->item_ref_id)) {
192  $this->start_objs[(int) $row->crs_start_id]['item_ref_id'] = (int) $row->item_ref_id;
193  } else {
194  $this->delete((int) $row->item_ref_id);
195  }
196  }
197  }
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

ilCourseStart::add ( int  $a_item_ref_id)

Definition at line 110 of file class.ilCourseStart.php.

References $query, $res, and getId().

110  : void
111  {
112  if ($a_item_ref_id) {
113  $next_id = $this->db->nextId('crs_start');
114  $query = "INSERT INTO crs_start (crs_start_id,crs_id,item_ref_id) " .
115  "VALUES( " .
116  $this->db->quote($next_id, 'integer') . ", " .
117  $this->db->quote($this->getId(), 'integer') . ", " .
118  $this->db->quote($a_item_ref_id, 'integer') . " " .
119  ")";
120  $res = $this->db->manipulate($query);
121  }
122  }
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:

◆ allFullfilled()

ilCourseStart::allFullfilled (   $user_id)

Definition at line 140 of file class.ilCourseStart.php.

References getStartObjects(), and isFullfilled().

140  : bool
141  {
142  foreach ($this->getStartObjects() as $item) {
143  if (!$this->isFullfilled($user_id, $item['item_ref_id'])) {
144  return false;
145  }
146  }
147  return true;
148  }
isFullfilled(int $user_id, int $item_id)
+ Here is the call graph for this function:

◆ cloneDependencies()

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

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

References $data, ilCopyWizardOptions\_getInstance(), getStartObjects(), and ILIAS\Repository\logger().

72  : void
73  {
74  $this->logger->debug('Begin course start objects...');
75 
76  $new_obj_id = $this->objectDataCache->lookupObjId($a_target_id);
77  $start = new ilCourseStart($a_target_id, $new_obj_id);
78 
79  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
80  $mappings = $cwo->getMappings();
81  foreach ($this->getStartObjects() as $data) {
82  $item_ref_id = $data['item_ref_id'];
83  if (isset($mappings[$item_ref_id]) && $mappings[$item_ref_id]) {
84  $this->logger->debug('Clone start object nr. ' . $item_ref_id);
85  $start->add($mappings[$item_ref_id]);
86  } else {
87  $this->logger->debug('No mapping found for start object nr. ' . $item_ref_id);
88  }
89  }
90  $this->logger->debug('... end course start objects');
91  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ delete()

ilCourseStart::delete ( int  $a_crs_start_id)

Definition at line 93 of file class.ilCourseStart.php.

References $query, $res, and getId().

93  : void
94  {
95  $query = "DELETE FROM crs_start " .
96  "WHERE crs_start_id = " . $this->db->quote($a_crs_start_id, 'integer') . " " .
97  "AND crs_id = " . $this->db->quote($this->getId(), 'integer') . " ";
98  $res = $this->db->manipulate($query);
99  }
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:

◆ exists()

ilCourseStart::exists ( int  $a_item_ref_id)

Definition at line 101 of file class.ilCourseStart.php.

References $query, $res, and getId().

101  : bool
102  {
103  $query = "SELECT * FROM crs_start " .
104  "WHERE crs_id = " . $this->db->quote($this->getId(), 'integer') . " " .
105  "AND item_ref_id = " . $this->db->quote($a_item_ref_id, 'integer') . " ";
106  $res = $this->db->query($query);
107  return (bool) $res->numRows();
108  }
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:

◆ getId()

ilCourseStart::getId ( )

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

References $id.

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

52  : int
53  {
54  return $this->id;
55  }
+ Here is the caller graph for this function:

◆ getPossibleStarters()

ilCourseStart::getPossibleStarters ( )

Definition at line 124 of file class.ilCourseStart.php.

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

Referenced by ilCourseStartObjectsTableGUI\getPossibleObjects().

124  : array
125  {
126  $poss_items = [];
127  foreach (ilObjectActivation::getItems($this->getRefId(), false) as $node) {
128  switch ($node['type']) {
129  case 'lm':
130  case 'sahs':
131  case 'svy':
132  case 'tst':
133  $poss_items[] = $node['ref_id'];
134  break;
135  }
136  }
137  return $poss_items;
138  }
static getItems(int $parent_id, bool $with_list_data=true)
Get sub item data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefId()

ilCourseStart::getRefId ( )

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

References $ref_id.

Referenced by getPossibleStarters(), and isFullfilled().

62  : int
63  {
64  return $this->ref_id;
65  }
+ Here is the caller graph for this function:

◆ getStartObjects()

ilCourseStart::getStartObjects ( )

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

References $start_objs.

Referenced by allFullfilled(), cloneDependencies(), ilCourseStartObjectsTableGUI\getStartObjects(), and ilCourseContentGUI\showStartObjects().

67  : array
68  {
69  return $this->start_objs;
70  }
+ Here is the caller graph for this function:

◆ isFullfilled()

ilCourseStart::isFullfilled ( int  $user_id,
int  $item_id 
)

Definition at line 150 of file class.ilCourseStart.php.

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

Referenced by allFullfilled(), and ilCourseContentGUI\showStartObjects().

150  : bool
151  {
152  $lm_continue = new ilCourseLMHistory($this->getRefId(), $user_id);
153  $continue_data = $lm_continue->getLMHistory();
154 
155  $obj_id = $this->objectDataCache->lookupObjId($item_id);
156  $type = $this->objectDataCache->lookupType($obj_id);
157 
158  switch ($type) {
159  case 'tst':
160 
162  return false;
163  }
164  break;
165  case 'svy':
166  if (!ilObjSurveyAccess::_lookupFinished($obj_id, $user_id)) {
167  return false;
168  }
169  break;
170  case 'sahs':
171  if (!ilLPStatus::_hasUserCompleted($obj_id, $user_id)) {
172  return false;
173  }
174  break;
175 
176  default:
177  if (!isset($continue_data[$item_id])) {
178  return false;
179  }
180  }
181  return true;
182  }
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
$type
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setId()

ilCourseStart::setId ( int  $a_id)

Definition at line 47 of file class.ilCourseStart.php.

47  : void
48  {
49  $this->id = $a_id;
50  }

◆ setRefId()

ilCourseStart::setRefId ( int  $a_ref_id)

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

57  : void
58  {
59  $this->ref_id = $a_ref_id;
60  }

Field Documentation

◆ $db

ilDBInterface ilCourseStart::$db
protected

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

◆ $id

int ilCourseStart::$id
private

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

Referenced by getId().

◆ $logger

ilLogger ilCourseStart::$logger
protected

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

◆ $objectDataCache

ilObjectDataCache ilCourseStart::$objectDataCache
protected

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

◆ $ref_id

int ilCourseStart::$ref_id
private

Definition at line 25 of file class.ilCourseStart.php.

Referenced by getRefId().

◆ $start_objs

array ilCourseStart::$start_objs = []
private

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

Referenced by getStartObjects().

◆ $tree

ilTree ilCourseStart::$tree
protected

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


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