ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSCORM2004DeleteData Class Reference

Class ilSCORM2004DeleteData. More...

+ Collaboration diagram for ilSCORM2004DeleteData:

Static Public Member Functions

static removeCMIDataForPackage ($packageId)
 
static removeCMIDataForUser ($user_id)
 
static removeCMIDataForUserAndPackage ($user_id, $packageId)
 
static removeCMIDataForNodes (array $cmi_node_values)
 
static getGlobalToSystemObjectiveIdStringForPackage ($packageId)
 

Detailed Description

Member Function Documentation

◆ getGlobalToSystemObjectiveIdStringForPackage()

static ilSCORM2004DeleteData::getGlobalToSystemObjectiveIdStringForPackage (   $packageId)
static

Definition at line 205 of file class.ilSCORM2004DeleteData.php.

References $data, $DIC, $ilDB, $packageId, and $res.

206  {
207  global $DIC;
208 
209  $ilDB = $DIC->database();
210 
211  $existing_key_template = "";
212  $global_to_system = 1;
213 
214  $res = $ilDB->queryF(
215  'SELECT global_to_system FROM cp_package WHERE obj_id = %s',
216  array('integer'),
217  array($packageId)
218  );
219  while ($data = $ilDB->fetchAssoc($res)) {
220  $global_to_system = $data['global_to_system'];
221  }
222  if ($global_to_system == 0) {
223  return "";
224  }
225 
226  $res = $ilDB->queryF(
227  '
228  SELECT targetobjectiveid
229  FROM cp_mapinfo, cp_node
230  WHERE cp_node.slm_id = %s
231  AND cp_node.nodename = %s
232  AND cp_mapinfo.cp_node_id = cp_node.cp_node_id',
233  array('integer', 'text'),
234  array($packageId, 'mapInfo')
235  );
236  while ($data = $ilDB->fetchAssoc($res)) {
237  $existing_key_template .= "'" . $data['targetobjectiveid'] . "',";
238  }
239  //remove trailing ','
240  $existing_key_template = substr($existing_key_template, 0, strlen($existing_key_template) - 1);
241 
242  return $existing_key_template;
243  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$packageId
$data
Definition: bench.php:6

◆ removeCMIDataForNodes()

static ilSCORM2004DeleteData::removeCMIDataForNodes ( array  $cmi_node_values)
static
Parameters
array$cmi_node_values

Definition at line 158 of file class.ilSCORM2004DeleteData.php.

References $data, $DIC, $ilDB, $query, and $res.

159  {
160  global $DIC;
161 
162  $ilDB = $DIC->database();
163 
164  //cmi interaction nodes
165  $cmi_inode_values = array();
166 
167  $query = 'SELECT cmi_interaction_id FROM cmi_interaction WHERE '
168  . $ilDB->in('cmi_interaction.cmi_node_id', $cmi_node_values, false, 'integer');
169  $res = $ilDB->query($query);
170  while ($data = $ilDB->fetchAssoc($res)) {
171  $cmi_inode_values[] = $data['cmi_interaction_id'];
172  }
173 
174  //response
175  $query = 'DELETE FROM cmi_correct_response WHERE '
176  . $ilDB->in('cmi_correct_response.cmi_interaction_id', $cmi_inode_values, false, 'integer');
177  $ilDB->manipulate($query);
178 
179  //objective interaction
180  $query = 'DELETE FROM cmi_objective WHERE '
181  . $ilDB->in('cmi_objective.cmi_interaction_id', $cmi_inode_values, false, 'integer');
182  $ilDB->manipulate($query);
183 
184  //objective
185  $query = 'DELETE FROM cmi_objective WHERE '
186  . $ilDB->in('cmi_objective.cmi_node_id', $cmi_node_values, false, 'integer');
187  $ilDB->manipulate($query);
188 
189  //interaction
190  $query = 'DELETE FROM cmi_interaction WHERE '
191  . $ilDB->in('cmi_interaction.cmi_node_id', $cmi_node_values, false, 'integer');
192  $ilDB->manipulate($query);
193 
194  //comment
195  $query = 'DELETE FROM cmi_comment WHERE '
196  . $ilDB->in('cmi_comment.cmi_node_id', $cmi_node_values, false, 'integer');
197  $ilDB->manipulate($query);
198 
199  //node
200  $query = 'DELETE FROM cmi_node WHERE '
201  . $ilDB->in('cmi_node.cmi_node_id', $cmi_node_values, false, 'integer');
202  $ilDB->manipulate($query);
203  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
$data
Definition: bench.php:6

◆ removeCMIDataForPackage()

static ilSCORM2004DeleteData::removeCMIDataForPackage (   $packageId)
static

Definition at line 14 of file class.ilSCORM2004DeleteData.php.

References $data, $DIC, $ilDB, $packageId, $query, and $res.

Referenced by ilSCORM13Package\removeCMIData().

15  {
16  global $DIC;
17 
18  $ilDB = $DIC->database();
19 
20  $res = $ilDB->queryF(
21  '
22  SELECT cmi_node.cmi_node_id
23  FROM cmi_node, cp_node
24  WHERE cp_node.slm_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id',
25  array('integer'),
26  array($packageId)
27  );
28  $cmi_node_values = [];
29  while ($data = $ilDB->fetchAssoc($res)) {
30  $cmi_node_values[] = $data['cmi_node_id'];
31  }
32  self::removeCMIDataForNodes($cmi_node_values);
33 
34  //custom
35  //TODO: delete cmi_custom
36  $query = 'DELETE FROM cmi_custom WHERE obj_id = %s';
37  $ilDB->manipulateF($query, array('integer'), array($packageId));
38 
39  //sahs_user
40  $query = 'DELETE FROM sahs_user WHERE obj_id = %s';
41  $ilDB->manipulateF($query, array('integer'), array($packageId));
42 
43  //g_objective
44  $query = 'DELETE FROM cmi_gobjective WHERE scope_id = %s';
45  $ilDB->manipulateF($query, array('integer'), array($packageId));
46 
47  $s_globalObjectiveId = self::getGlobalToSystemObjectiveIdStringForPackage($packageId);
48  if ($s_globalObjectiveId != "") {
49  $ilDB->manipulateF(
50  'DELETE FROM cmi_gobjective WHERE scope_id = %s AND objective_id in (' . $s_globalObjectiveId . ')',
51  array('integer'),
52  array(0)
53  );
54  }
55  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
$packageId
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ removeCMIDataForUser()

static ilSCORM2004DeleteData::removeCMIDataForUser (   $user_id)
static

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

References $data, $DIC, $ilDB, and $res.

Referenced by ilSCORM13Package\_removeTrackingDataForUser().

58  {
59  global $DIC;
60 
61  $ilDB = $DIC->database();
62 
63  //get all cmi_nodes to delete
64  $res = $ilDB->queryF(
65  '
66  SELECT cmi_node.cmi_node_id
67  FROM cmi_node, cp_node
68  WHERE cmi_node.user_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id',
69  array('integer'),
70  array($user_id)
71  );
72 
73  $cmi_node_values = [];
74  while ($data = $ilDB->fetchAssoc($res)) {
75  $cmi_node_values[] = $data['cmi_node_id'];
76  }
77  self::removeCMIDataForNodes($cmi_node_values);
78 
79  //custom
80  //TODO: delete cmi_custom
81  $ilDB->manipulateF(
82  'DELETE FROM cmi_custom WHERE user_id = %s',
83  array('integer'),
84  array($user_id)
85  );
86 
87  //sahs_user
88  $ilDB->manipulateF(
89  'DELETE FROM sahs_user WHERE user_id = %s',
90  array('integer'),
91  array($user_id)
92  );
93 
94  //gobjective
95  $ilDB->manipulateF(
96  'DELETE FROM cmi_gobjective WHERE user_id = %s',
97  array('integer'),
98  array($user_id)
99  );
100  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ removeCMIDataForUserAndPackage()

static ilSCORM2004DeleteData::removeCMIDataForUserAndPackage (   $user_id,
  $packageId 
)
static

Definition at line 102 of file class.ilSCORM2004DeleteData.php.

References $data, $DIC, $ilDB, $packageId, and $res.

Referenced by ilObjSCORM2004LearningModule\deleteTrackingDataOfUsers().

103  {
104  global $DIC;
105 
106  $ilDB = $DIC->database();
107 
108  //get all cmi_nodes to delete
109  $res = $ilDB->queryF(
110  '
111  SELECT cmi_node.cmi_node_id
112  FROM cmi_node, cp_node
113  WHERE cmi_node.user_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id AND cp_node.slm_id = %s',
114  array('integer','integer'),
115  array($user_id,$packageId)
116  );
117  $cmi_node_values = [];
118  while ($data = $ilDB->fetchAssoc($res)) {
119  $cmi_node_values[] = $data['cmi_node_id'];
120  }
121  self::removeCMIDataForNodes($cmi_node_values);
122 
123  //custom
124  //TODO: delete cmi_custom
125  $ilDB->manipulateF(
126  'DELETE FROM cmi_custom WHERE user_id = %s AND obj_id = %s',
127  array('integer','integer'),
128  array($user_id,$packageId)
129  );
130 
131  //sahs_user
132  $ilDB->manipulateF(
133  'DELETE FROM sahs_user WHERE user_id = %s AND obj_id = %s',
134  array('integer','integer'),
135  array($user_id,$packageId)
136  );
137 
138  //gobjective
139  $ilDB->manipulateF(
140  'DELETE FROM cmi_gobjective WHERE user_id = %s AND scope_id = %s',
141  array('integer','integer'),
142  array($user_id,$packageId)
143  );
144 
145  $s_globalObjectiveId = self::getGlobalToSystemObjectiveIdStringForPackage($packageId);
146  if ($s_globalObjectiveId != "") {
147  $ilDB->manipulateF(
148  'DELETE FROM cmi_gobjective WHERE user_id = %s AND scope_id = %s AND objective_id in (' . $s_globalObjectiveId . ')',
149  array('integer','integer'),
150  array($user_id,0)
151  );
152  }
153  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$packageId
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

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