19declare(strict_types=1);
42 foreach ($infos as
$info) {
43 foreach (
$info->getConditionSet()->getConditions() as $condition) {
44 $next_id = $this->db->nextId(
'conditions');
58 $values[] = $value_str;
61 if (count($values) === 0) {
64 $query =
'INSERT INTO conditions(condition_id, target_ref_id, target_obj_id, target_type, trigger_ref_id, trigger_obj_id, trigger_type, operator, value, ref_handling, obligatory, num_obligatory, hidden_status) VALUES ' . implode(
', ', $values);
65 $this->db->manipulate($query);
75 $query =
'SELECT * FROM conditions WHERE ' . $this->db->in(
'target_obj_id', $object_ids,
false,
ilDBConstants::T_INTEGER);
76 $result = $this->db->query($query);
78 while ($row = $result->fetchAssoc()) {
79 $obj_id = (
int) $row[
'target_obj_id'];
80 if (!isset(
$data[$obj_id])) {
82 'object_id' => $obj_id,
83 'ref_id' => (
int) $row[
'target_ref_id'],
84 'target_type' => $row[
'target_type'],
85 'num_obligatory' => (
int) $row[
'num_obligatory'],
86 'hidden_status' => (bool) $row[
'hidden_status'],
87 'preconditions' => [],
88 'all_obligatory' =>
true
91 $data[$obj_id][
'all_obligatory'] =
$data[$obj_id][
'all_obligatory'] && ((bool) $row[
'obligatory']);
93 (
int) $row[
'trigger_ref_id'],
94 (
int) $row[
'trigger_obj_id'],
102 ->withId((
int) $row[
'condition_id'])
103 ->withObligatory((
bool) $row[
'obligatory']);
104 $data[$obj_id][
'preconditions'][] = $condition;
107 foreach (
$data as $data_entry) {
108 $condition_set = (
new ilConditionSet($data_entry[
'preconditions']))
109 ->withHiddenStatus($data_entry[
'hidden_status'])
110 ->withNumObligatory($data_entry[
'num_obligatory']);
111 if ($data_entry[
'all_obligatory']) {
112 $condition_set = $condition_set->withAllObligatory();
114 $info_collection = $info_collection->withInfo((
new Info())
115 ->withObjectId($data_entry[
'object_id'])
116 ->withReferenceId($data_entry[
'ref_id'])
117 ->withObjectType($data_entry[
'target_type'])
118 ->withConditionSet($condition_set));
120 return $info_collection;
127 $query =
'SELECT condition_id, value FROM conditions WHERE operator = "result_range_percentage" AND target_ref_id = ' . $this->db->quote($course_ref_id,
ilDBConstants::T_INTEGER);
129 $result = $this->db->query($query);
130 while ($row = $result->fetchAssoc()) {
131 $value = unserialize($row[
'value']);
132 $condition_id = (
int) $row[
'condition_id'];
133 if (!isset($value[
'objective'])) {
137 'components/ILIAS/Course',
141 $new_values[$condition_id] = serialize($value);
143 if (count($new_values) === 0) {
146 foreach ($new_values as $condition_id => $new_value) {
148 $this->db->manipulate($query);
updateCourseValuesResultRangePercentage(int $course_ref_id, ilImportMapping $mapping)
__construct(protected ilDBInterface $db)
getInfosByObjectIds(array $object_ids)
writeByInfos(InfoCollection $infos,)
Condition set Note: This object currently focuses on repository objects as targets.
Represents a condition trigger object.
getMapping(string $a_comp, string $a_entity, string $a_old_id)