5include_once 
'./webservice/soap/classes/class.ilSoapAdministration.php';
 
   32        self::PROGRESS_FILTER_ALL,
 
   33        self::PROGRESS_FILTER_IN_PROGRESS,
 
   34        self::PROGRESS_FILTER_COMPLETED,
 
   35        self::PROGRESS_FILTER_FAILED,
 
   36        self::PROGRESS_FILTER_NOT_ATTEMPTED
 
   47    public function deleteProgress($sid, $ref_ids, $usr_ids, $type_filter, $progress_filter)
 
   52        if (!is_array($usr_ids)) {
 
   53            $usr_ids = (array) $usr_ids;
 
   55        if (!is_array($type_filter)) {
 
   56            $type_filter = (array) $type_filter;
 
   60        if (!$this->__checkSession($sid)) {
 
   65        if (array_diff((array) $type_filter, self::$DELETE_PROGRESS_FILTER_TYPES)) {
 
   66            return $this->
__raiseError(
'Invalid filter type given', 
'Client');
 
   69        include_once 
'Services/User/classes/class.ilObjUser.php';
 
   71            return $this->
__raiseError(
'Invalid user ids given', 
'Client');
 
   74        $valid_refs = array();
 
   75        foreach ((array) $ref_ids as $ref_id) {
 
   81                $all_sub_objs = array();
 
   82                foreach (($type_filter) as $type_filter_item) {
 
   83                    $sub_objs = 
$GLOBALS[
'tree']->getSubTree(
 
   84                        $GLOBALS[
'tree']->getNodeData($ref_id),
 
   88                    $all_sub_objs = array_merge($all_sub_objs, $sub_objs);
 
   91                foreach ($all_sub_objs as $child_ref) {
 
   93                    if (!
$GLOBALS[
'ilAccess']->checkAccess(
'write', 
'', $child_ref)) {
 
   94                        return $this->
__raiseError(
'Permission denied for : ' . $ref_id . 
' -> type ' . 
$type, 
'Client');
 
   96                    $valid_refs[] = $child_ref;
 
   98            } elseif (in_array(
$type, $type_filter)) {
 
   99                if (!
$GLOBALS[
'ilAccess']->checkAccess(
'write', 
'', $ref_id)) {
 
  100                    return $this->
__raiseError(
'Permission denied for : ' . $ref_id . 
' -> type ' . 
$type, 
'Client');
 
  102                $valid_refs[] = $ref_id;
 
  104                return $this->
__raiseError(
'Invalid object type given for : ' . $ref_id . 
' -> type ' . 
$type, 
'Client');
 
  109        foreach ($valid_refs as $ref_id) {
 
  110            include_once 
'./Services/Object/classes/class.ilObjectFactory.php';
 
  114                return $this->
__raiseError(
'Invalid reference id given : ' . $ref_id . 
' -> type ' . 
$type, 
'Client');
 
  118            $valid_users = $this->
applyProgressFilter($obj->getId(), (array) $usr_ids, (array) $progress_filter);
 
  120            switch ($obj->getType()) {
 
  122                    include_once 
'./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
 
  139                    $obj->removeTestResultsFromSoapLpAdministration(array_values((array) $valid_users));
 
  144            include_once 
'./Services/Tracking/classes/class.ilLPStatusWrapper.php';
 
  151    public function getProgressInfo($sid, $a_ref_id, $a_progress_filter)
 
  158        if (!$this->__checkSession($sid)) {
 
  160                'Error ' . self::SOAP_LP_ERROR_AUTHENTICATION . 
':' . $this->
__getMessage(),
 
  161                self::SOAP_LP_ERROR_AUTHENTICATION
 
  166        if (array_diff((array) $a_progress_filter, self::$PROGRESS_INFO_TYPES)) {
 
  168                'Error ' . self::SOAP_LP_ERROR_INVALID_FILTER . 
': Invalid filter type given',
 
  169                self::SOAP_LP_ERROR_INVALID_FILTER
 
  173        include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
 
  176                'Error ' . self::SOAP_LP_ERROR_LP_NOT_ENABLED . 
': Learning progress not enabled in ILIAS',
 
  177                self::SOAP_LP_ERROR_LP_NOT_ENABLED
 
  181        include_once 
'./Services/Object/classes/class.ilObjectFactory.php';
 
  185                'Error ' . self::SOAP_LP_ERROR_INVALID_REF_ID . 
': Invalid reference id ' . $a_ref_id . 
' given',
 
  186                self::SOAP_LP_ERROR_INVALID_REF_ID
 
  191        include_once 
'./Services/Tracking/classes/class.ilLPObjSettings.php';
 
  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(
'read_learning_progress', 
'read_learning_progress', $a_ref_id)) {
 
  207                'Error ' . self::SOAP_LP_ERROR_NO_PERMISSION . 
': No Permission to access learning progress in this object',
 
  208                self::SOAP_LP_ERROR_NO_PERMISSION
 
  212        include_once 
'./Services/Xml/classes/class.ilXmlWriter.php';
 
  214        $writer->xmlStartTag(
 
  215            'LearningProgressInfo',
 
  217                    'ref_id' => $obj->getRefId(),
 
  218                    'type' => $obj->getType()
 
  222        $writer->xmlStartTag(
'LearningProgressSummary');
 
  224        include_once 
'./Services/Tracking/classes/class.ilLPStatusWrapper.php';
 
  225        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_COMPLETED, $a_progress_filter)) {
 
  227            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  228                'read_learning_progress',
 
  233            $completed = count($completed);
 
  238                        'type'  => self::PROGRESS_FILTER_COMPLETED,
 
  239                        'num'   => (
int) $completed
 
  243        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_IN_PROGRESS, $a_progress_filter)) {
 
  245            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  246                'read_learning_progress',
 
  251            $completed = count($completed);
 
  256                        'type'  => self::PROGRESS_FILTER_IN_PROGRESS,
 
  257                        'num'   => (
int) $completed
 
  261        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_FAILED, $a_progress_filter)) {
 
  263            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  264                'read_learning_progress',
 
  269            $completed = count($completed);
 
  274                        'type'  => self::PROGRESS_FILTER_FAILED,
 
  275                        'num'   => (
int) $completed
 
  279        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_NOT_ATTEMPTED, $a_progress_filter)) {
 
  281            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  282                'read_learning_progress',
 
  287            $completed = count($completed);
 
  292                        'type'  => self::PROGRESS_FILTER_NOT_ATTEMPTED,
 
  293                        'num'   => (
int) $completed
 
  297        $writer->xmlEndTag(
'LearningProgressSummary');
 
  300        $writer->xmlStartTag(
'UserProgress');
 
  301        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_COMPLETED, $a_progress_filter)) {
 
  303            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  304                'read_learning_progress',
 
  310            $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_COMPLETED);
 
  312        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_IN_PROGRESS, $a_progress_filter)) {
 
  314            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  315                'read_learning_progress',
 
  320            $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_IN_PROGRESS);
 
  322        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_FAILED, $a_progress_filter)) {
 
  324            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  325                'read_learning_progress',
 
  330            $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_FAILED);
 
  332        if (in_array(self::PROGRESS_FILTER_ALL, $a_progress_filter) or in_array(self::PROGRESS_FILTER_NOT_ATTEMPTED, $a_progress_filter)) {
 
  334            $completed = 
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
 
  335                'read_learning_progress',
 
  341            $this->
addUserProgress($writer, $completed, self::PROGRESS_FILTER_NOT_ATTEMPTED);
 
  343        $writer->xmlEndTag(
'UserProgress');
 
  344        $writer->xmlEndTag(
'LearningProgressInfo');
 
  346        return $writer->xmlDumpMem();
 
  351        foreach (
$users  as $user_id) {
 
  362            $writer->
xmlElement(
'Firstname', array(), (
string) 
$info[
'firstname']);
 
  379        include_once 
'./Services/Tracking/classes/class.ilLPStatusWrapper.php';
 
  382        $all_users = array();
 
  383        if (in_array(self::USER_FILTER_ALL, $usr_ids)) {
 
  384            $all_users = array_unique(
 
  392            $all_users = $usr_ids;
 
  395        if (!$filter or in_array(self::PROGRESS_FILTER_ALL, $filter)) {
 
  396            $GLOBALS[
'log']->write(__METHOD__ . 
': Deleting all progress data');
 
  400        $filter_users = array();
 
  401        if (in_array(self::PROGRESS_FILTER_IN_PROGRESS, $filter)) {
 
  402            $GLOBALS[
'log']->write(__METHOD__ . 
': Filtering  in progress.');
 
  405        if (in_array(self::PROGRESS_FILTER_COMPLETED, $filter)) {
 
  406            $GLOBALS[
'log']->write(__METHOD__ . 
': Filtering  completed.');
 
  409        if (in_array(self::PROGRESS_FILTER_FAILED, $filter)) {
 
  410            $GLOBALS[
'log']->write(__METHOD__ . 
': Filtering  failed.');
 
  415        return array_intersect($all_users, $filter_users);
 
  429        $query = 
'DELETE FROM scorm_tracking ' .
 
  430            'WHERE ' . 
$ilDB->in(
'user_id', $a_usr_ids, 
false, 
'integer') . 
' ' .
 
  431            'AND obj_id = ' . 
$ilDB->quote($a_obj_id, 
'integer') . 
' ';
 
  445        $query = 
'SELECT cp_node_id FROM cp_node ' .
 
  446            'WHERE nodename = ' . 
$ilDB->quote(
'item', 
'text') . 
' ' .
 
  447            'AND cp_node.slm_id = ' . 
$ilDB->quote($a_obj_id, 
'integer');
 
  452            $scos[] = 
$row->cp_node_id;
 
  455        $query = 
'DELETE FROM cmi_node ' .
 
  456                'WHERE ' . 
$ilDB->in(
'user_id', (array) $a_usr_ids, 
false, 
'integer') . 
' ' .
 
  457                'AND ' . 
$ilDB->in(
'cp_node_id', $scos, 
false, 
'integer');
 
  469        if (!$this->__checkSession($sid)) {
 
  472        global $rbacsystem, $tree, 
$ilLog;
 
  476        if (is_array($type_filter)) {
 
  477            $types = implode($type_filter, 
",");
 
  482            include_once 
'./Services/Tracking/classes/class.ilLPXmlWriter.php';
 
  485            $writer->setIncludeRefIds($include_ref_ids);
 
  486            $writer->setTypeFilter($type_filter);
 
  489            return $writer->xmlDumpMem(
true);
 
  490        } 
catch (UnexpectedValueException $e) {
 
foreach($mandatory_scripts as $file) $timestamp
An exception for terminatinating execution or to throw for unit testing.
static _lookupDBMode($a_obj_id)
static _getNotAttempted($a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
static _resetInfoCaches($a_obj_id)
static _getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static _getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
XML writer learning progress.
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
static _enabledLearningProgress()
check wether learing progress is enabled or not
static userExists($a_usr_ids=array())
static _lookupName($a_user_id)
lookup user name
static 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 _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
const OP_READ_LEARNING_PROGRESS
initAuth($sid)
Init authentication.
__raiseError($a_message, $a_code)
This class handles all DB changes necessary for fraunhofer.
const PROGRESS_FILTER_IN_PROGRESS
const SOAP_LP_ERROR_LP_NOT_AVAILABLE
const PROGRESS_FILTER_COMPLETED
const PROGRESS_FILTER_NOT_ATTEMPTED
deleteScorm2004Tracking($a_obj_id, $a_usr_ids)
Delete scorm 2004 tracking.
const SOAP_LP_ERROR_LP_NOT_ENABLED
addUserProgress(ilXmlWriter $writer, $users, $a_type)
getLearningProgressChanges($sid, $timestamp, $include_ref_ids, $type_filter)
Get learning progress changes.
const PROGRESS_FILTER_ALL
const PROGRESS_FILTER_FAILED
const SOAP_LP_ERROR_INVALID_REF_ID
const SOAP_LP_ERROR_INVALID_FILTER
applyProgressFilter($obj_id, array $usr_ids, array $filter)
Apply progress filter.
static $PROGRESS_INFO_TYPES
static $DELETE_PROGRESS_FILTER_TYPES
const SOAP_LP_ERROR_AUTHENTICATION
const SOAP_LP_ERROR_NO_PERMISSION
deleteScormTracking($a_obj_id, $a_usr_ids)
Delete SCORM Tracking @global type $ilDB.
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res