40 $this->tree = $DIC->repositoryTree();
41 $this->db = $DIC->database();
42 $this->obj_data_cache = $DIC[
"ilObjDataCache"];
43 $this->log = $DIC[
"ilLog"];
52 $this->obj_id = $a_id;
60 protected function setRefId(
int $a_ref_id): void
62 $this->ref_id = $a_ref_id;
72 return $this->start_objs ?: [];
75 protected function read(): void
80 $this->start_objs = [];
82 $query =
"SELECT * FROM crs_start" .
83 " WHERE crs_id = " .
$ilDB->quote($this->
getObjId(),
'integer') .
84 " ORDER BY pos, crs_start_id";
87 if ($tree->
isInTree($row->item_ref_id)) {
88 $this->start_objs[$row->crs_start_id][
'item_ref_id'] = (
int) $row->item_ref_id;
90 $this->
delete((
int) $row->item_ref_id);
95 public function delete(
int $a_crs_start_id):
void 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');
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');
115 public function exists(
int $a_item_ref_id): bool
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');
124 return (
bool)
$res->numRows();
127 public function add(
int $a_item_ref_id): bool
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;
137 $next_id =
$ilDB->nextId(
'crs_start');
138 $query =
"INSERT INTO crs_start" .
139 " (crs_start_id,crs_id,item_ref_id,pos)" .
141 " (" .
$ilDB->quote($next_id,
'integer') .
143 ", " .
$ilDB->quote($a_item_ref_id,
'integer') .
144 ", " .
$ilDB->quote($max_pos,
'integer') .
158 if (!$a_start_id || !$a_pos) {
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'));
172 switch ($node[
'type']) {
178 $poss_items[] = $node[
'ref_id'];
188 if (!$this->
isFullfilled($a_user_id, $item[
'item_ref_id'])) {
199 $obj_id = $ilObjDataCache->
lookupObjId($a_item_id);
200 $type = $ilObjDataCache->lookupType($obj_id);
225 $continue_data = $lm_continue->getLMHistory();
226 if (!isset($continue_data[$a_item_id])) {
242 $ilLog->
write(__METHOD__ .
': Begin course start objects...');
244 $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
245 $start =
new self($a_target_id, $new_obj_id);
248 $mappings = $cwo->getMappings();
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]);
255 $ilLog->write(__METHOD__ .
': No mapping found for start object nr. ' . $item_ref_id);
258 $ilLog->write(__METHOD__ .
': ... end course start objects');
267 $ilDB = $DIC->database();
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');
274 return $res->numRows() >= 1;
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
isInTree(?int $a_node_id)
get all information of a node.
write(string $a_message, $a_level=ilLogLevel::INFO)
write log message
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupFinished(int $a_obj_id, int $a_user_id=0)
get finished status
deleteItem(int $a_item_ref_id)
isFullfilled(int $a_user_id, int $a_item_id)
allFullfilled(int $a_user_id)
static getItems(int $parent_id, bool $with_list_data=true)
Get sub item data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setObjectPos(int $a_start_id, int $a_pos)
ilObjectDataCache $obj_data_cache
exists(int $a_item_ref_id)
static isStartObject(int $a_container_id, int $a_item_ref_id)
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
check condition
cloneDependencies(int $a_target_id, int $a_copy_id)
static _getInstance(int $a_copy_id)
__construct(int $a_object_ref_id, int $a_object_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...