ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 208 of file class.ilSCORM2004DeleteData.php.

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

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

◆ removeCMIDataForNodes()

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

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

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

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

◆ removeCMIDataForPackage()

static ilSCORM2004DeleteData::removeCMIDataForPackage (   $packageId)
static

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

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

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'),
27  );
28 
29  $cmi_node_values = [];
30  while ($data = $ilDB->fetchAssoc($res)) {
31  $cmi_node_values[] = $data['cmi_node_id'];
32  }
33  self::removeCMIDataForNodes($cmi_node_values);
34 
35  //custom
36  //TODO: delete cmi_custom
37  $query = 'DELETE FROM cmi_custom WHERE obj_id = %s';
38  $ilDB->manipulateF($query, array('integer'), array($packageId));
39 
40  //sahs_user
41  $query = 'DELETE FROM sahs_user WHERE obj_id = %s';
42  $ilDB->manipulateF($query, array('integer'), array($packageId));
43 
44  //g_objective
45  $query = 'DELETE FROM cmi_gobjective WHERE scope_id = %s';
46  $ilDB->manipulateF($query, array('integer'), array($packageId));
47 
48  $s_globalObjectiveId=self::getGlobalToSystemObjectiveIdStringForPackage($packageId);
49  if ($s_globalObjectiveId != "") {
50  $ilDB->manipulateF(
51  'DELETE FROM cmi_gobjective WHERE scope_id = %s AND objective_id in (' . $s_globalObjectiveId . ')',
52  array('integer'),
53  array(0)
54  );
55  }
56  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
$packageId
+ Here is the caller graph for this function:

◆ removeCMIDataForUser()

static ilSCORM2004DeleteData::removeCMIDataForUser (   $user_id)
static

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

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

Referenced by ilSCORM13Package\_removeTrackingDataForUser().

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

◆ removeCMIDataForUserAndPackage()

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

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

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

Referenced by ilObjSCORM2004LearningModule\deleteTrackingDataOfUsers().

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

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