ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ($cmi_node_values)
 
static getGlobalToSystemObjectiveIdStringForPackage ($packageId)
 

Detailed Description

Member Function Documentation

◆ getGlobalToSystemObjectiveIdStringForPackage()

static ilSCORM2004DeleteData::getGlobalToSystemObjectiveIdStringForPackage (   $packageId)
static

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

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

194  {
195  global $ilDB;
196 
197  $existing_key_template = "";
198  $global_to_system = 1;
199 
200  $res = $ilDB->queryF('SELECT global_to_system FROM cp_package WHERE obj_id = %s',
201  array('integer'),
203  );
204  while($data = $ilDB->fetchAssoc($res))
205  {
206  $global_to_system = $data['global_to_system'];
207  }
208  if ($global_to_system == 0) return "";
209 
210  $res = $ilDB->queryF('
211  SELECT targetobjectiveid
212  FROM cp_mapinfo, cp_node
213  WHERE cp_node.slm_id = %s
214  AND cp_node.nodename = %s
215  AND cp_mapinfo.cp_node_id = cp_node.cp_node_id',
216  array('integer', 'text'),
217  array($packageId, 'mapInfo')
218  );
219  while($data = $ilDB->fetchAssoc($res))
220  {
221  $existing_key_template .= "'".$data['targetobjectiveid']."',";
222  }
223  //remove trailing ','
224  $existing_key_template = substr($existing_key_template, 0, strlen($existing_key_template) - 1);
225 
226  return $existing_key_template;
227  }
Create styles array
The data for the language used.
global $ilDB
$packageId

◆ removeCMIDataForNodes()

static ilSCORM2004DeleteData::removeCMIDataForNodes (   $cmi_node_values)
static

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

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

148  {
149  global $ilDB;
150 
151  //cmi interaction nodes
152  $cmi_inode_values = array();
153 
154  $query = 'SELECT cmi_interaction_id FROM cmi_interaction WHERE '
155  . $ilDB->in('cmi_interaction.cmi_node_id', $cmi_node_values, false, 'integer');
156  $res = $ilDB->query($query);
157  while($data = $ilDB->fetchAssoc($res))
158  {
159  $cmi_inode_values[] = $data['cmi_interaction_id'];
160  }
161 
162  //response
163  $query = 'DELETE FROM cmi_correct_response WHERE '
164  . $ilDB->in('cmi_correct_response.cmi_interaction_id', $cmi_inode_values, false, 'integer');
165  $ilDB->manipulate($query);
166 
167  //objective interaction
168  $query = 'DELETE FROM cmi_objective WHERE '
169  . $ilDB->in('cmi_objective.cmi_interaction_id', $cmi_inode_values, false, 'integer');
170  $ilDB->manipulate($query);
171 
172  //objective
173  $query = 'DELETE FROM cmi_objective WHERE '
174  . $ilDB->in('cmi_objective.cmi_node_id', $cmi_node_values, false, 'integer');
175  $ilDB->manipulate($query);
176 
177  //interaction
178  $query = 'DELETE FROM cmi_interaction WHERE '
179  . $ilDB->in('cmi_interaction.cmi_node_id', $cmi_node_values, false, 'integer');
180  $ilDB->manipulate($query);
181 
182  //comment
183  $query = 'DELETE FROM cmi_comment WHERE '
184  . $ilDB->in('cmi_comment.cmi_node_id', $cmi_node_values, false, 'integer');
185  $ilDB->manipulate($query);
186 
187  //node
188  $query = 'DELETE FROM cmi_node WHERE '
189  . $ilDB->in('cmi_node.cmi_node_id', $cmi_node_values, false, 'integer');
190  $ilDB->manipulate($query);
191 
192  }
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, $ilDB, $packageId, $query, $res, and array.

Referenced by ilSCORM13Package\removeCMIData().

15  {
16  global $ilDB;
17 
18  $res = $ilDB->queryF('
19  SELECT cmi_node.cmi_node_id
20  FROM cmi_node, cp_node
21  WHERE cp_node.slm_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id',
22  array('integer'),
24  );
25  while($data = $ilDB->fetchAssoc($res))
26  {
27  $cmi_node_values[] = $data['cmi_node_id'];
28  }
29  self::removeCMIDataForNodes($cmi_node_values);
30 
31  //custom
32  //TODO: delete cmi_custom
33  $query = 'DELETE FROM cmi_custom WHERE obj_id = %s';
34  $ilDB->manipulateF($query, array('integer'), array($packageId));
35 
36  //sahs_user
37  $query = 'DELETE FROM sahs_user WHERE obj_id = %s';
38  $ilDB->manipulateF($query, array('integer'), array($packageId));
39 
40  //g_objective
41  $query = 'DELETE FROM cmi_gobjective WHERE scope_id = %s';
42  $ilDB->manipulateF($query, array('integer'), array($packageId));
43 
44  $s_globalObjectiveId=self::getGlobalToSystemObjectiveIdStringForPackage($packageId);
45  if ($s_globalObjectiveId != "") {
46  $ilDB->manipulateF(
47  'DELETE FROM cmi_gobjective WHERE scope_id = %s AND objective_id in ('.$s_globalObjectiveId.')',
48  array('integer'),
49  array(0)
50  );
51  }
52  }
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 54 of file class.ilSCORM2004DeleteData.php.

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

Referenced by ilSCORM13Package\_removeTrackingDataForUser().

55  {
56  global $ilDB;
57 
58  //get all cmi_nodes to delete
59  $res = $ilDB->queryF('
60  SELECT cmi_node.cmi_node_id
61  FROM cmi_node, cp_node
62  WHERE cmi_node.user_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id',
63  array('integer'),
64  array($user_id)
65  );
66 
67  while($data = $ilDB->fetchAssoc($res))
68  {
69  $cmi_node_values[] = $data['cmi_node_id'];
70  }
71  self::removeCMIDataForNodes($cmi_node_values);
72 
73  //custom
74  //TODO: delete cmi_custom
75  $ilDB->manipulateF(
76  'DELETE FROM cmi_custom WHERE user_id = %s',
77  array('integer'),
78  array($user_id)
79  );
80 
81  //sahs_user
82  $ilDB->manipulateF(
83  'DELETE FROM sahs_user WHERE user_id = %s',
84  array('integer'),
85  array($user_id)
86  );
87 
88  //gobjective
89  $ilDB->manipulateF(
90  'DELETE FROM cmi_gobjective WHERE user_id = %s',
91  array('integer'),
92  array($user_id)
93  );
94 
95  }
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 97 of file class.ilSCORM2004DeleteData.php.

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

Referenced by ilObjSCORM2004LearningModule\deleteTrackingDataOfUsers().

98  {
99  global $ilDB;
100 
101  //get all cmi_nodes to delete
102  $res = $ilDB->queryF('
103  SELECT cmi_node.cmi_node_id
104  FROM cmi_node, cp_node
105  WHERE cmi_node.user_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id AND cp_node.slm_id = %s',
106  array('integer','integer'),
107  array($user_id,$packageId)
108  );
109  while($data = $ilDB->fetchAssoc($res))
110  {
111  $cmi_node_values[] = $data['cmi_node_id'];
112  }
113  self::removeCMIDataForNodes($cmi_node_values);
114 
115  //custom
116  //TODO: delete cmi_custom
117  $ilDB->manipulateF(
118  'DELETE FROM cmi_custom WHERE user_id = %s AND obj_id = %s',
119  array('integer','integer'),
120  array($user_id,$packageId)
121  );
122 
123  //sahs_user
124  $ilDB->manipulateF(
125  'DELETE FROM sahs_user WHERE user_id = %s AND obj_id = %s',
126  array('integer','integer'),
127  array($user_id,$packageId)
128  );
129 
130  //gobjective
131  $ilDB->manipulateF(
132  'DELETE FROM cmi_gobjective WHERE user_id = %s AND scope_id = %s',
133  array('integer','integer'),
134  array($user_id,$packageId)
135  );
136 
137  $s_globalObjectiveId=self::getGlobalToSystemObjectiveIdStringForPackage($packageId);
138  if ($s_globalObjectiveId != "") {
139  $ilDB->manipulateF(
140  'DELETE FROM cmi_gobjective WHERE user_id = %s AND scope_id = %s AND objective_id in ('.$s_globalObjectiveId.')',
141  array('integer','integer'),
142  array($user_id,0)
143  );
144  }
145  }
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: