30 self::PROGRESS_FILTER_ALL,
31 self::PROGRESS_FILTER_IN_PROGRESS,
32 self::PROGRESS_FILTER_COMPLETED,
33 self::PROGRESS_FILTER_FAILED,
34 self::PROGRESS_FILTER_NOT_ATTEMPTED
42 public function deleteProgress(
string $sid, array $ref_ids, array $usr_ids, array $type_filter, array $progress_filter)
47 if (!is_array($usr_ids)) {
48 $usr_ids = (array) $usr_ids;
50 if (!is_array($type_filter)) {
51 $type_filter = (array) $type_filter;
58 if (array_diff($type_filter, self::$DELETE_PROGRESS_FILTER_TYPES)) {
59 return $this->
raiseError(
'Invalid filter type given',
'Client');
63 return $this->
raiseError(
'Invalid user ids given',
'Client');
66 $valid_refs = array();
73 if (
$GLOBALS[
'DIC'][
'objDefinition']->isContainer($type)) {
74 $all_sub_objs = array();
75 foreach (($type_filter) as $type_filter_item) {
76 $sub_objs =
$GLOBALS[
'DIC'][
'tree']->getSubTree(
77 $GLOBALS[
'DIC'][
'tree']->getNodeData($ref_id),
81 $all_sub_objs = array_merge($all_sub_objs, $sub_objs);
84 foreach ($all_sub_objs as $child_ref) {
86 if (!
$GLOBALS[
'DIC'][
'ilAccess']->checkAccess(
'write',
'', $child_ref)) {
88 'Permission denied for : ' . $ref_id .
' -> type ' . $type,
92 $valid_refs[] = $child_ref;
94 } elseif (in_array($type, $type_filter)) {
95 if (!
$GLOBALS[
'DIC'][
'ilAccess']->checkAccess(
'write',
'', $ref_id)) {
96 return $this->
raiseError(
'Permission denied for : ' . $ref_id .
' -> type ' . $type,
'Client');
101 'Invalid object type given for : ' . $ref_id .
' -> type ' . $type,
108 foreach ($valid_refs as $ref_id) {
112 return $this->
raiseError(
'Invalid reference id given : ' . $ref_id .
' -> type ' . $type,
'Client');
118 switch ($obj->getType()) {
136 $obj->removeTestResultsFromSoapLpAdministration(array_values($valid_users));
151 public function getProgressInfo(
string $sid,
int $a_ref_id, array $a_progress_filter)
158 $ilAccess = $DIC->access();
163 'Error ' . self::SOAP_LP_ERROR_AUTHENTICATION .
':' . $this->
getMessage(),
164 self::SOAP_LP_ERROR_AUTHENTICATION
169 if (array_diff($a_progress_filter, self::$PROGRESS_INFO_TYPES)) {
171 'Error ' . self::SOAP_LP_ERROR_INVALID_FILTER .
': Invalid filter type given',
172 self::SOAP_LP_ERROR_INVALID_FILTER
178 'Error ' . self::SOAP_LP_ERROR_LP_NOT_ENABLED .
': Learning progress not enabled in ILIAS',
179 self::SOAP_LP_ERROR_LP_NOT_ENABLED
186 'Error ' . self::SOAP_LP_ERROR_INVALID_REF_ID .
': Invalid reference id ' . $a_ref_id .
' given',
187 self::SOAP_LP_ERROR_INVALID_REF_ID
195 'Error ' . self::SOAP_LP_ERROR_LP_NOT_AVAILABLE .
': Learning progress not available for objects of type ' .
197 self::SOAP_LP_ERROR_LP_NOT_AVAILABLE
205 if (!$ilAccess->checkRbacOrPositionPermissionAccess(
206 'read_learning_progress',
207 'read_learning_progress',
211 'Error ' . self::SOAP_LP_ERROR_NO_PERMISSION .
': No Permission to access learning progress in this object',
212 self::SOAP_LP_ERROR_NO_PERMISSION
217 $writer->xmlStartTag(
218 'LearningProgressInfo',
220 'ref_id' => $obj->getRefId(),
221 'type' => $obj->getType()
225 $writer->xmlStartTag(
'LearningProgressSummary');
227 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
228 self::PROGRESS_FILTER_COMPLETED,
232 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
233 'read_learning_progress',
238 $completed = count($completed);
243 'type' => self::PROGRESS_FILTER_COMPLETED,
248 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
249 self::PROGRESS_FILTER_IN_PROGRESS,
253 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
254 'read_learning_progress',
259 $completed = count($completed);
264 'type' => self::PROGRESS_FILTER_IN_PROGRESS,
269 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
270 self::PROGRESS_FILTER_FAILED,
274 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
275 'read_learning_progress',
280 $completed = count($completed);
285 'type' => self::PROGRESS_FILTER_FAILED,
290 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
291 self::PROGRESS_FILTER_NOT_ATTEMPTED,
295 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
296 'read_learning_progress',
301 $completed = count($completed);
306 'type' => self::PROGRESS_FILTER_NOT_ATTEMPTED,
311 $writer->xmlEndTag(
'LearningProgressSummary');
312 $writer->xmlStartTag(
'UserProgress');
313 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
314 self::PROGRESS_FILTER_COMPLETED,
318 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
319 'read_learning_progress',
325 $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_COMPLETED);
327 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
328 self::PROGRESS_FILTER_IN_PROGRESS,
332 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
333 'read_learning_progress',
338 $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_IN_PROGRESS);
340 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
341 self::PROGRESS_FILTER_FAILED,
345 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
346 'read_learning_progress',
351 $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_FAILED);
353 if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) || in_array(
354 self::PROGRESS_FILTER_NOT_ATTEMPTED,
358 $completed =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
359 'read_learning_progress',
365 $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_NOT_ATTEMPTED);
367 $writer->xmlEndTag(
'UserProgress');
368 $writer->xmlEndTag(
'LearningProgressInfo');
370 return $writer->xmlDumpMem();
385 $writer->
xmlElement(
'Login', array(), (
string) $info[
'login']);
386 $writer->
xmlElement(
'Firstname', array(), (
string) $info[
'firstname']);
387 $writer->
xmlElement(
'Lastname', array(), (
string) $info[
'lastname']);
401 $all_users = array();
402 if (in_array(self::USER_FILTER_ALL, $usr_ids)) {
403 $all_users = array_unique(
411 $all_users = $usr_ids;
414 if (!$filter || in_array(self::PROGRESS_FILTER_ALL, $filter)) {
415 $GLOBALS[
'DIC'][
'log']->write(__METHOD__ .
': Deleting all progress data');
419 $filter_users = array();
420 if (in_array(self::PROGRESS_FILTER_IN_PROGRESS, $filter)) {
421 $GLOBALS[
'DIC'][
'log']->write(__METHOD__ .
': Filtering in progress.');
424 if (in_array(self::PROGRESS_FILTER_COMPLETED, $filter)) {
425 $GLOBALS[
'DIC'][
'log']->write(__METHOD__ .
': Filtering completed.');
428 if (in_array(self::PROGRESS_FILTER_FAILED, $filter)) {
429 $GLOBALS[
'DIC'][
'log']->write(__METHOD__ .
': Filtering failed.');
434 return array_intersect($all_users, $filter_users);
444 $ilDB = $DIC[
'ilDB'];
446 $query =
'DELETE FROM scorm_tracking ' .
447 'WHERE ' .
$ilDB->in(
'user_id', $a_usr_ids,
false,
'integer') .
' ' .
448 'AND obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ';
460 $ilDB = $DIC[
'ilDB'];
462 $query =
'SELECT cp_node_id FROM cp_node ' .
463 'WHERE nodename = ' .
$ilDB->quote(
'item',
'text') .
' ' .
464 'AND cp_node.slm_id = ' .
$ilDB->quote($a_obj_id,
'integer');
469 $scos[] = $row->cp_node_id;
472 $query =
'DELETE FROM cmi_node ' .
473 'WHERE ' .
$ilDB->in(
'user_id', $a_usr_ids,
false,
'integer') .
' ' .
474 'AND ' .
$ilDB->in(
'cp_node_id', $scos,
false,
'integer');
475 $ilDB->manipulate($query);
492 $rbacsystem = $DIC[
'rbacsystem'];
493 $tree = $DIC[
'tree'];
494 $ilLog = $DIC[
'ilLog'];
498 if (is_array($type_filter)) {
499 $types = implode(
",", $type_filter);
505 $writer->setTimestamp($timestamp);
506 $writer->setIncludeRefIds($include_ref_ids);
507 $writer->setTypeFilter($type_filter);
510 return $writer->xmlDumpMem(
true);
512 return $this->
raiseError($e->getMessage(),
'Client');
const PROGRESS_FILTER_IN_PROGRESS
getLearningProgressChanges(string $sid, string $timestamp, bool $include_ref_ids, array $type_filter)
This class handles all DB changes necessary for fraunhofer.
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
deleteScorm2004Tracking(int $a_obj_id, array $a_usr_ids)
Delete scorm 2004 tracking.
const SOAP_LP_ERROR_AUTHENTICATION
raiseError(string $a_message, $a_code)
static array $PROGRESS_INFO_TYPES
const PROGRESS_FILTER_FAILED
static _lookupName(int $a_user_id)
lookup user name
const SOAP_LP_ERROR_INVALID_REF_ID
static array $DELETE_PROGRESS_FILTER_TYPES
const PROGRESS_FILTER_NOT_ATTEMPTED
const SOAP_LP_ERROR_NO_PERMISSION
static _resetInfoCaches($a_obj_id)
static _getInProgress(int $a_obj_id)
Static function to read users who have the status 'in_progress'.
const PROGRESS_FILTER_ALL
static _getNotAttempted(int $a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
const SOAP_LP_ERROR_LP_NOT_AVAILABLE
static _lookupObjId(int $ref_id)
xmlEndTag(string $tag)
Writes an endtag.
const SOAP_LP_ERROR_INVALID_FILTER
static _enabledLearningProgress()
const OP_READ_LEARNING_PROGRESS
XML writer learning progress.
static userExists(array $a_usr_ids=[])
static _getFailed(int $a_obj_id)
Static function to read the users who have the status 'completed'.
checkSession(string $sid)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
addUserProgress(ilXmlWriter $writer, array $users, int $a_type)
static _lookupDBMode(int $a_obj_id)
foreach($mandatory_scripts as $file) $timestamp
applyProgressFilter(int $obj_id, array $usr_ids, array $filter)
Apply progress filter.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
static _lookupType(int $id, bool $reference=false)
const SOAP_LP_ERROR_LP_NOT_ENABLED
deleteScormTracking(int $a_obj_id, array $a_usr_ids)
Delete SCORM Tracking.
const PROGRESS_FILTER_COMPLETED