/**
  * Get participant ids for given object
  *
  * @param	int		$a_ref_id
  * @return	array
  */
 public static function getParticipantsForObject($a_ref_id)
 {
     global $tree;
     $obj_id = ilObject::_lookupObjectId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     // try to get participants from (parent) course/group
     switch ($obj_type) {
         case "crs":
             include_once "Modules/Course/classes/class.ilCourseParticipants.php";
             $member_obj = ilCourseParticipants::_getInstanceByObjId($obj_id);
             return $member_obj->getMembers();
         case "grp":
             include_once "Modules/Group/classes/class.ilGroupParticipants.php";
             $member_obj = ilGroupParticipants::_getInstanceByObjId($obj_id);
             return $member_obj->getMembers();
         default:
             // walk path to find course or group object and use members of that object
             $path = $tree->getPathId($a_ref_id);
             array_pop($path);
             foreach (array_reverse($path) as $path_ref_id) {
                 $type = ilObject::_lookupType($path_ref_id, true);
                 if ($type == "crs" || $type == "grp") {
                     return self::getParticipantsForObject($path_ref_id);
                 }
             }
             break;
     }
     $a_users = null;
     // no participants possible: use tracking/object data where possible
     switch ($obj_type) {
         case "sahs":
             include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
             $subtype = ilObjSAHSLearningModule::_lookupSubType($obj_id);
             if ($subtype == "scorm2004") {
                 // based on cmi_node/cp_node, used for scorm tracking data views
                 include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
                 $mod = new ilObjSCORM2004LearningModule($obj_id, false);
                 $all = $mod->getTrackedUsers("");
                 if ($all) {
                     $a_users = array();
                     foreach ($all as $item) {
                         $a_users[] = $item["user_id"];
                     }
                 }
             } else {
                 include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php";
                 $a_users = ilObjSCORMTracking::_getTrackedUsers($obj_id);
             }
             break;
         case "exc":
             include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php";
             include_once "./Modules/Exercise/classes/class.ilObjExercise.php";
             $exc = new ilObjExercise($obj_id, false);
             $members = new ilExerciseMembers($exc);
             $a_users = $members->getMembers();
             break;
         case "tst":
             include_once "./Services/Tracking/classes/class.ilLPStatusTestFinished.php";
             $a_users = ilLPStatusTestFinished::getParticipants($obj_id);
             break;
         default:
             // no sensible data: return null
             break;
     }
     return $a_users;
 }
Пример #2
0
 function refreshStatus($a_obj_id)
 {
     parent::refreshStatus($a_obj_id);
     // this is restricted to SCOs in the current collection
     include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
     $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
     $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
     $failed = ilLPStatusWrapper::_getFailed($a_obj_id);
     $all_active_users = array_unique(array_merge($in_progress, $completed, $failed));
     // get all tracked users regardless of SCOs
     include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
     $subtype = ilObjSAHSLearningModule::_lookupSubType($a_obj_id);
     if ($subtype != "scorm2004") {
         include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php";
         $all_tracked_users = ilObjSCORMTracking::_getTrackedUsers($a_obj_id);
     } else {
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php";
         $all_tracked_users = ilSCORM2004Tracking::_getTrackedUsers($a_obj_id);
     }
     $not_attempted_users = array_diff($all_tracked_users, $all_active_users);
     unset($all_tracked_users);
     unset($all_active_users);
     // reset all users which have no data for the current SCOs
     if ($not_attempted_users) {
         foreach ($not_attempted_users as $usr_id) {
             // this will update any (parent) collections if necessary
             ilLPStatus::writeStatus($a_obj_id, $usr_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, 0);
         }
     }
 }