ILIAS  release_4-4 Revision
ilSoapLearningProgressAdministration Class Reference

This class handles all DB changes necessary for fraunhofer. More...

+ Inheritance diagram for ilSoapLearningProgressAdministration:
+ Collaboration diagram for ilSoapLearningProgressAdministration:

Public Member Functions

 deleteProgress ($sid, $ref_ids, $usr_ids, $type_filter, $progress_filter)
 Delete progress of users and objects Implemented for. More...
 
 getLearningProgressChanges ($sid, $timestamp, $include_ref_ids, $type_filter)
 Get learning progress changes. More...
 
- Public Member Functions inherited from ilSoapAdministration
 ilSoapAdministration ($use_nusoap=true)
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Data Fields

const PROGRESS_FILTER_ALL = 0
 
const PROGRESS_FILTER_IN_PROGRESS = 1
 
const PROGRESS_FILTER_COMPLETED = 2
 
const PROGRESS_FILTER_FAILED = 3
 
const USER_FILTER_ALL = -1
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 

Protected Member Functions

 applyProgressFilter ($obj_id, Array $usr_ids, Array $filter)
 Apply progress filter. More...
 
 deleteScormTracking ($a_obj_id, $a_usr_ids)
 Delete SCORM Tracking type $ilDB. More...
 
 deleteScorm2004Tracking ($a_obj_id, $a_usr_ids)
 Delete scorm 2004 tracking. More...
 

Static Protected Attributes

static $DELETE_PROGRESS_FILTER_TYPES = array('sahs', 'tst')
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

This class handles all DB changes necessary for fraunhofer.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ applyProgressFilter()

ilSoapLearningProgressAdministration::applyProgressFilter (   $obj_id,
Array  $usr_ids,
Array  $filter 
)
protected

Apply progress filter.

Parameters
int$obj_id
array$usr_ids
array$filter
Returns
array $filtered_users

Definition at line 154 of file class.ilSoapLearningProgressAdministration.php.

References $GLOBALS, ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), and ilLPStatusWrapper\_getInProgress().

Referenced by deleteProgress().

155  {
156  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
157 
158 
159  $all_users = array();
160  if(in_array(self::USER_FILTER_ALL, $usr_ids))
161  {
162  $all_users = array_unique(
163  array_merge(
167  )
168  );
169  }
170  else
171  {
172  $all_users = $usr_ids;
173  }
174 
175  if(!$filter or in_array(self::PROGRESS_FILTER_ALL, $filter))
176  {
177  $GLOBALS['log']->write(__METHOD__.': Deleting all progress data');
178  return $all_users;
179  }
180 
181  $filter_users = array();
182  if(in_array(self::PROGRESS_FILTER_IN_PROGRESS, $filter))
183  {
184  $GLOBALS['log']->write(__METHOD__.': Filtering in progress.');
185  $filter_users = array_merge($filter, ilLPStatusWrapper::_getInProgress($obj_id));
186  }
187  if(in_array(self::PROGRESS_FILTER_COMPLETED, $filter))
188  {
189  $GLOBALS['log']->write(__METHOD__.': Filtering completed.');
190  $filter_users = array_merge($filter, ilLPStatusWrapper::_getCompleted($obj_id));
191  }
192  if(in_array(self::PROGRESS_FILTER_FAILED, $filter))
193  {
194  $GLOBALS['log']->write(__METHOD__.': Filtering failed.');
195  $filter_users = array_merge($filter, ilLPStatusWrapper::_getFailed($obj_id));
196  }
197 
198  // Build intersection
199  return array_intersect($all_users, $filter_users);
200  }
_getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
$GLOBALS['ct_recipient']
_getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
_getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteProgress()

ilSoapLearningProgressAdministration::deleteProgress (   $sid,
  $ref_ids,
  $usr_ids,
  $type_filter,
  $progress_filter 
)

Delete progress of users and objects Implemented for.

Definition at line 29 of file class.ilSoapLearningProgressAdministration.php.

References $GLOBALS, $ref_id, $usr_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_lookupObjId(), ilObjSAHSLearningModule\_lookupSubType(), ilObject\_lookupType(), ilLPStatusWrapper\_refreshStatus(), ilLPStatusWrapper\_resetInfoCaches(), applyProgressFilter(), deleteScorm2004Tracking(), deleteScormTracking(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilObjUser\userExists().

30  {
31  $this->initAuth($sid);
32  $this->initIlias();
33 
34  // Check session
35  if(!$this->__checkSession($sid))
36  {
37  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
38  }
39 
40  // Check filter
41  if(array_diff((array) $type_filter, self::$DELETE_PROGRESS_FILTER_TYPES))
42  {
43  return $this->__raiseError('Invalid filter type given', 'Client');
44  }
45 
46  include_once 'Services/User/classes/class.ilObjUser.php';
47  if(!in_array(self::USER_FILTER_ALL, $usr_ids) and !ilObjUser::userExists($usr_ids))
48  {
49  return $this->__raiseError('Invalid user ids given', 'Client');
50  }
51 
52  $valid_refs = array();
53  foreach((array) $ref_ids as $ref_id)
54  {
55  $obj_id = ilObject::_lookupObjId($ref_id);
56  $type = ilObject::_lookupType($obj_id);
57 
58  // All containers
59  if($GLOBALS['objDefinition']->isContainer($type))
60  {
61  $all_sub_objs = array();
62  foreach(($type_filter) as $type_filter_item)
63  {
64  $sub_objs = $GLOBALS['tree']->getSubTree(
65  $GLOBALS['tree']->getNodeData($ref_id),
66  false,
67  $type_filter_item
68  );
69  $all_sub_objs = array_merge($all_sub_objs, $sub_objs);
70  }
71 
72  foreach($all_sub_objs as $child_ref)
73  {
74  $child_type = ilObject::_lookupType(ilObject::_lookupObjId($child_ref));
75  if(!$GLOBALS['ilAccess']->checkAccess('write', '', $child_ref))
76  {
77  return $this->__raiseError('Permission denied for : '. $ref_id.' -> type '.$type, 'Client');
78  }
79  $valid_refs[] = $child_ref;
80  }
81 
82  }
83  elseif(in_array($type, $type_filter))
84  {
85  if(!$GLOBALS['ilAccess']->checkAccess('write','',$ref_id))
86  {
87  return $this->__raiseError('Permission denied for : '. $ref_id.' -> type '.$type, 'Client');
88  }
89  $valid_refs[] = $ref_id;
90  }
91  else
92  {
93  return $this->__raiseError('Invalid object type given for : '. $ref_id.' -> type '.$type, 'Client');
94  }
95  }
96 
97  // Delete tracking data
98  foreach($valid_refs as $ref_id)
99  {
100  include_once './Services/Object/classes/class.ilObjectFactory.php';
101  $obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
102 
103  if(!$obj instanceof ilObject)
104  {
105  return $this->__raiseError('Invalid reference id given : '. $ref_id.' -> type '.$type, 'Client');
106  }
107 
108  // filter users
109  $valid_users = $this->applyProgressFilter($obj->getId(), (array) $usr_ids, (array) $progress_filter);
110 
111  switch($obj->getType())
112  {
113  case 'sahs':
114  include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
115  $subtype = ilObjSAHSLearningModule::_lookupSubType($obj->getId());
116 
117  switch($subtype)
118  {
119  case 'scorm':
120  $this->deleteScormTracking($obj->getId(),(array) $valid_users);
121  break;
122 
123  case 'scorm2004':
124  $this->deleteScorm2004Tracking($obj->getId(), (array) $valid_users);
125  break;
126  }
127  break;
128 
129  case 'tst':
130  foreach((array) $valid_users as $usr_id)
131  {
132  $obj->removeTestResultsForUser($usr_id);
133  }
134  break;
135  }
136 
137  // Refresh status
138  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
140  ilLPStatusWrapper::_refreshStatus($obj->getId(), $valid_users);
141 
142  }
143  return true;
144  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.
static userExists($a_usr_ids=array())
static _resetInfoCaches($a_obj_id)
$GLOBALS['ct_recipient']
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
_lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
deleteScormTracking($a_obj_id, $a_usr_ids)
Delete SCORM Tracking type $ilDB.
static _lookupType($a_id, $a_reference=false)
lookup object type
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
deleteScorm2004Tracking($a_obj_id, $a_usr_ids)
Delete scorm 2004 tracking.
$ref_id
Definition: sahs_server.php:39
applyProgressFilter($obj_id, Array $usr_ids, Array $filter)
Apply progress filter.
+ Here is the call graph for this function:

◆ deleteScorm2004Tracking()

ilSoapLearningProgressAdministration::deleteScorm2004Tracking (   $a_obj_id,
  $a_usr_ids 
)
protected

Delete scorm 2004 tracking.

Parameters
type$a_obj_id
type$a_usr_ids

Definition at line 225 of file class.ilSoapLearningProgressAdministration.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by deleteProgress().

226  {
227  global $ilDB;
228 
229  $query = 'SELECT cp_node_id FROM cp_node '.
230  'WHERE nodename = '. $ilDB->quote('item','text').' '.
231  'AND cp_node.slm_id = '.$ilDB->quote($a_obj_id,'integer');
232  $res = $ilDB->query($query);
233 
234  $scos = array();
235  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
236  {
237  $scos[] = $row->cp_node_id;
238  }
239 
240  $query = 'DELETE FROM cmi_node '.
241  'WHERE '.$ilDB->in('user_id',(array) $a_usr_ids,false,'integer').' '.
242  'AND '.$ilDB->in('cp_node_id',$scos,false,'integer');
243  $ilDB->manipulate($query);
244 
245  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ deleteScormTracking()

ilSoapLearningProgressAdministration::deleteScormTracking (   $a_obj_id,
  $a_usr_ids 
)
protected

Delete SCORM Tracking type $ilDB.

Parameters
type$a_obj_id
type$a_usr_ids
Returns
boolean

Definition at line 209 of file class.ilSoapLearningProgressAdministration.php.

References $query, and $res.

Referenced by deleteProgress().

210  {
211  global $ilDB;
212 
213  $query = 'DELETE FROM scorm_tracking '.
214  'WHERE '.$ilDB->in('user_id',$a_usr_ids,false,'integer').' '.
215  'AND obj_id = '. $ilDB->quote($a_obj_id,'integer').' ';
216  $res = $ilDB->manipulate($query);
217  return true;
218  }
+ Here is the caller graph for this function:

◆ getLearningProgressChanges()

ilSoapLearningProgressAdministration::getLearningProgressChanges (   $sid,
  $timestamp,
  $include_ref_ids,
  $type_filter 
)

Get learning progress changes.

Definition at line 250 of file class.ilSoapLearningProgressAdministration.php.

References $ilLog, $timestamp, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

251  {
252  $this->initAuth($sid);
253  $this->initIlias();
254 
255  if(!$this->__checkSession($sid))
256  {
257  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
258  }
259  global $rbacsystem, $tree, $ilLog;
260 
261  // check administrator
262  $types = "";
263  if (is_array($type_filter))
264  {
265  $types = implode($type_filter, ",");
266  }
267 
268  // output lp changes as xml
269  try
270  {
271  include_once './Services/Tracking/classes/class.ilLPXmlWriter.php';
272  $writer = new ilLPXmlWriter(true);
273  $writer->setTimestamp($timestamp);
274  $writer->setIncludeRefIds($include_ref_ids);
275  $writer->setTypeFilter($type_filter);
276  $writer->write();
277 
278  return $writer->xmlDumpMem(true);
279  }
280  catch(UnexpectedValueException $e)
281  {
282  return $this->__raiseError($e->getMessage(), 'Client');
283  }
284  }
XML writer learning progress.
__raiseError($a_message, $a_code)
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
+ Here is the call graph for this function:

Field Documentation

◆ $DELETE_PROGRESS_FILTER_TYPES

ilSoapLearningProgressAdministration::$DELETE_PROGRESS_FILTER_TYPES = array('sahs', 'tst')
staticprotected

◆ PROGRESS_FILTER_ALL

const ilSoapLearningProgressAdministration::PROGRESS_FILTER_ALL = 0

◆ PROGRESS_FILTER_COMPLETED

const ilSoapLearningProgressAdministration::PROGRESS_FILTER_COMPLETED = 2

◆ PROGRESS_FILTER_FAILED

const ilSoapLearningProgressAdministration::PROGRESS_FILTER_FAILED = 3

◆ PROGRESS_FILTER_IN_PROGRESS

const ilSoapLearningProgressAdministration::PROGRESS_FILTER_IN_PROGRESS = 1

◆ USER_FILTER_ALL

const ilSoapLearningProgressAdministration::USER_FILTER_ALL = -1

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