ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Conditions\Export\Repository Class Reference
+ Collaboration diagram for ILIAS\Conditions\Export\Repository:

Public Member Functions

 __construct (protected ilDBInterface $db)
 
 writeByInfos (InfoCollection $infos,)
 
 getInfosByObjectIds (array $object_ids)
 
 updateCourseValuesResultRangePercentage (int $course_ref_id, ilImportMapping $mapping)
 

Detailed Description

Definition at line 31 of file Repository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Conditions\Export\Repository::__construct ( protected ilDBInterface  $db)

Definition at line 33 of file Repository.php.

35 {
36 }

Member Function Documentation

◆ getInfosByObjectIds()

ILIAS\Conditions\Export\Repository::getInfosByObjectIds ( array  $object_ids)
Parameters
int[]$object_ids

Definition at line 71 of file Repository.php.

73 : InfoCollection {
74 $infos = [];
75 $query = 'SELECT * FROM conditions WHERE ' . $this->db->in('target_obj_id', $object_ids, false, ilDBConstants::T_INTEGER);
76 $result = $this->db->query($query);
77 $data = [];
78 while ($row = $result->fetchAssoc()) {
79 $obj_id = (int) $row['target_obj_id'];
80 if (!isset($data[$obj_id])) {
81 $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
89 ];
90 }
91 $data[$obj_id]['all_obligatory'] = $data[$obj_id]['all_obligatory'] && ((bool) $row['obligatory']);
92 $condition_trigger = new ilConditionTrigger(
93 (int) $row['trigger_ref_id'],
94 (int) $row['trigger_obj_id'],
95 $row['trigger_type']
96 );
97 $condition = (new ilCondition(
98 $condition_trigger,
99 $row['operator'],
100 $row['value']
101 ))
102 ->withId((int) $row['condition_id'])
103 ->withObligatory((bool) $row['obligatory']);
104 $data[$obj_id]['preconditions'][] = $condition;
105 }
106 $info_collection = new InfoCollection();
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();
113 }
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));
119 }
120 return $info_collection;
121 }
Condition set Note: This object currently focuses on repository objects as targets.
Represents a condition trigger object.
Condition class.

References $data, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ updateCourseValuesResultRangePercentage()

ILIAS\Conditions\Export\Repository::updateCourseValuesResultRangePercentage ( int  $course_ref_id,
ilImportMapping  $mapping 
)

Definition at line 123 of file Repository.php.

126 : void {
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);
128 $new_values = [];
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'])) {
134 continue;
135 }
136 $value['objective'] = $mapping->getMapping(
137 'components/ILIAS/Course',
138 'objectives',
139 $value['objective']
140 );
141 $new_values[$condition_id] = serialize($value);
142 }
143 if (count($new_values) === 0) {
144 return;
145 }
146 foreach ($new_values as $condition_id => $new_value) {
147 $query = 'UPDATE conditions SET value = ' . $this->db->quote($new_value, ilDBConstants::T_TEXT) . ' WHERE condition_id = ' . $this->db->quote($condition_id, ilDBConstants::T_INTEGER);
148 $this->db->manipulate($query);
149 }
150 }
getMapping(string $a_comp, string $a_entity, string $a_old_id)

References ilImportMapping\getMapping(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ writeByInfos()

ILIAS\Conditions\Export\Repository::writeByInfos ( InfoCollection  $infos)

Definition at line 38 of file Repository.php.

40 : void {
41 $values = [];
42 foreach ($infos as $info) {
43 foreach ($info->getConditionSet()->getConditions() as $condition) {
44 $next_id = $this->db->nextId('conditions');
45 $value_str = '(' . $this->db->quote($next_id, ilDBConstants::T_INTEGER) . ', ';
46 $value_str .= $this->db->quote($info->getReferenceId(), ilDBConstants::T_INTEGER) . ', ';
47 $value_str .= $this->db->quote($info->getObjectId(), ilDBConstants::T_INTEGER) . ', ';
48 $value_str .= $this->db->quote($info->getObjectType(), ilDBConstants::T_TEXT) . ', ';
49 $value_str .= $this->db->quote($condition->getTrigger()->getRefId(), ilDBConstants::T_INTEGER) . ', ';
50 $value_str .= $this->db->quote($condition->getTrigger()->getObjId(), ilDBConstants::T_INTEGER) . ', ';
51 $value_str .= $this->db->quote($condition->getTrigger()->getType(), ilDBConstants::T_TEXT) . ', ';
52 $value_str .= $this->db->quote($condition->getOperator(), ilDBConstants::T_TEXT) . ', ';
53 $value_str .= $this->db->quote($condition->getValue(), ilDBConstants::T_TEXT) . ', ';
54 $value_str .= $this->db->quote(0, ilDBConstants::T_INTEGER) . ', ';
55 $value_str .= $this->db->quote($condition->getObligatory(), ilDBConstants::T_INTEGER) . ', ';
56 $value_str .= $this->db->quote($info->getConditionSet()->getNumObligatory(), ilDBConstants::T_INTEGER) . ', ';
57 $value_str .= $this->db->quote($info->getConditionSet()->getHiddenStatus(), ilDBConstants::T_INTEGER) . ')';
58 $values[] = $value_str;
59 }
60 }
61 if (count($values) === 0) {
62 return;
63 }
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);
66 }
$info
Definition: entry_point.php:21

References $info, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.


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