• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Tracking/classes/class.ilLPStatusCollection.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00033 include_once './Services/Tracking/classes/class.ilLPStatus.php';
00034 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
00035 
00036 class ilLPStatusCollection extends ilLPStatus
00037 {
00038 
00039         function ilLPStatusCollection($a_obj_id)
00040         {
00041                 global $ilDB;
00042 
00043                 parent::ilLPStatus($a_obj_id);
00044                 $this->db =& $ilDB;
00045         }
00046 
00047         function _getNotAttempted($a_obj_id)
00048         {
00049                 global $ilObjDataCache;
00050 
00051                 switch($ilObjDataCache->lookupType($a_obj_id))
00052                 {
00053                         case 'crs':
00054                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00055                                 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00056                                 $members = $member_obj->getParticipants();
00057                                 
00058                                 // diff in progress and completed (use stored result in LPStatusWrapper)
00059                                 $users = array_diff((array) $members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
00060                                 $users = array_diff((array) $users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
00061                                 $users = array_diff((array) $users,$fai = ilLPStatusWrapper::_getFailed($a_obj_id));
00062                                 return $users;
00063 
00064                         case 'grp':
00065                                 include_once 'classes/class.ilObjGroup.php';
00066                                 $members = ilObjGroup::_getMembers($a_obj_id);
00067 
00068                                 // diff in progress and completed (use stored result in LPStatusWrapper)
00069                                 $users = array_diff((array) $members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
00070                                 $users = array_diff((array) $users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
00071                                 $users = array_diff((array) $users,$fai = ilLPStatusWrapper::_getFailed($a_obj_id));
00072                                 return $users;
00073 
00074                         default:
00075                                 return array();
00076                 }
00077         }
00078 
00079         function _getInProgress($a_obj_id)
00080         {
00081                 include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
00082                 include_once './Services/Tracking/classes/class.ilLPEventCollections.php';
00083 
00084 
00085                 global $ilBench,$ilObjDataCache;
00086                 $ilBench->start('LearningProgress','9172_LPStatusCollection_inProgress');
00087 
00088                 $in_progress = 0;
00089                 foreach(ilLPCollectionCache::_getItems($a_obj_id) as $item_id)
00090                 {
00091                         $item_id = $ilObjDataCache->lookupObjId($item_id);
00092 
00093                         // merge arrays of users with status 'in progress'
00094                         $users = array_unique(array_merge((array) $users,ilLPStatusWrapper::_getInProgress($item_id)));
00095                         $users = array_unique(array_merge((array) $users,ilLPStatusWrapper::_getCompleted($item_id)));
00096                 }
00097 
00098                 // Handle status of events
00099                 foreach(ilLPEventCollections::_getItems($a_obj_id) as $event_id)
00100                 {
00101                         #var_dump("<pre>","EVENT_ID: ",$event_id,"<pre>");
00102                         $users = array_unique(array_merge((array) $users,ilLPStatusWrapper::_getInProgressByType($event_id,'event')));
00103                         $users = array_unique(array_merge((array) $users,ilLPStatusWrapper::_getCompletedByType($event_id,'event')));
00104                 }
00105 
00106                 // Exclude all users with status completed.
00107                 $users = array_diff((array) $users,ilLPStatusWrapper::_getCompleted($a_obj_id));
00108                 // Exclude all users with status failed.
00109                 $users = array_diff((array) $users,ilLPStatusWrapper::_getFailed($a_obj_id));
00110 
00111                 switch($ilObjDataCache->lookupType($a_obj_id))
00112                 {
00113                         case 'crs':
00114                                 // Exclude all non members
00115                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00116                                 $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00117                                 $members = $members_obj->getParticipants();
00118                                 $users = array_intersect($members,(array) $users);
00119                                 break;
00120                                 
00121                         case 'grp':
00122                                 include_once 'classes/class.ilObjGroup.php';
00123                                 $members = ilObjGroup::_getMembers($a_obj_id);
00124                                 $users = array_intersect($members,(array) $users);
00125                                 break;
00126                 }
00127 
00128                 $ilBench->stop('LearningProgress','9172_LPStatusCollection_inProgress');
00129                 return $users;
00130         }
00131 
00132         function _getCompleted($a_obj_id)
00133         {
00134                 include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
00135                 include_once './Services/Tracking/classes/class.ilLPEventCollections.php';
00136 
00137                 global $ilBench,$ilObjDataCache;
00138                 $ilBench->start('LearningProgress','9173_LPStatusCollection_completed');
00139 
00140                 $counter = 0;
00141                 $users = array();
00142                 foreach(ilLPCollectionCache::_getItems($a_obj_id) as $item_id)
00143                 {
00144                         $item_id = $ilObjDataCache->lookupObjId($item_id);
00145 
00146                         $tmp_users = ilLPStatusWrapper::_getCompleted($item_id);
00147                         if(!$counter++)
00148                         {
00149                                 $users = $tmp_users;
00150                         }
00151                         else
00152                         {
00153                                 $users = array_intersect($users,$tmp_users);
00154                         }
00155 
00156                 }
00157                 foreach(ilLPEventCollections::_getItems($a_obj_id) as $event_id)
00158                 {
00159                         $tmp_users = ilLPStatusWrapper::_getCompletedByType($event_id,'event');
00160                         if(!$counter++)
00161                         {
00162                                 $users = $tmp_users;
00163                         }
00164                         else
00165                         {
00166                                 $users = array_intersect($users,$tmp_users);
00167                         }
00168                 }
00169 
00170                 switch($ilObjDataCache->lookupType($a_obj_id))
00171                 {
00172                         case 'crs':
00173                                 // Exclude all non members
00174                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00175                                 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00176                                 $users = array_intersect($member_obj->getParticipants(),(array) $users);
00177                                 break;
00178 
00179                         case 'grp':
00180                                 include_once 'classes/class.ilObjGroup.php';
00181                                 $members = ilObjGroup::_getMembers($a_obj_id);
00182                                 $users = array_intersect($members,(array) $users);
00183                                 break;
00184                 }
00185                 $users = array_diff($users,ilLPStatusWrapper::_getFailed($a_obj_id));
00186                 $ilBench->stop('LearningProgress','9173_LPStatusCollection_completed');
00187                 return (array) $users;
00188         }
00189 
00190         function _getFailed($a_obj_id)
00191         {
00192                 global $ilObjDataCache;
00193 
00194                 include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
00195 
00196                 $users = array();
00197                 foreach(ilLPCollectionCache::_getItems($a_obj_id) as $item_id)
00198                 {
00199                         $item_id = $ilObjDataCache->lookupObjId($item_id);
00200                         $tmp_users = ilLPStatusWrapper::_getFailed($item_id);
00201                         $users = array_merge($users,$tmp_users);
00202                 }
00203                 
00204                 switch($ilObjDataCache->lookupType($a_obj_id))
00205                 {
00206                         case 'crs':
00207                                 // Exclude all non members
00208                                 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
00209                                 $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00210                                 $members = $members_obj->getParticipants();
00211                 
00212                                 $users = array_intersect($members,(array) $users);
00213                                 break;
00214                                 
00215                         case 'grp':
00216                                 include_once 'classes/class.ilObjGroup.php';
00217                                 $members = ilObjGroup::_getMembers($a_obj_id);
00218                                 $users = array_intersect($members,(array) $users);
00219                                 break;
00220                 }
00221                 
00222                 return array_unique($users);
00223         }
00224                 
00225 
00226         function _getStatusInfo($a_obj_id)
00227         {
00228                 include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
00229                 include_once './Services/Tracking/classes/class.ilLPEventCollections.php';
00230 
00231                 $status_info['collections'] = ilLPCollectionCache::_getItems($a_obj_id);
00232                 $status_info['event_collections'] = ilLPEventCollections::_getItems($a_obj_id);
00233 
00234                 $status_info['num_collections'] = count($status_info['collections']) + count($status_info['event_collections']);
00235                 return $status_info;
00236         }
00237 
00238         function _getTypicalLearningTime($a_obj_id)
00239         {
00240                 global $ilObjDataCache;
00241 
00242                 if($ilObjDataCache->lookupType($a_obj_id) == 'sahs')
00243                 {
00244                         return parent::_getTypicalLearningTime($a_obj_id);
00245                 }
00246 
00247                 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
00248                 foreach($status_info['collections'] as $item)
00249                 {
00250                         $tlt += ilLPStatusWrapper::_getTypicalLearningTime($ilObjDataCache->lookupObjId($item));
00251                 }
00252                 return $tlt;
00253         }
00254 
00255 }       
00256 ?>

Generated on Fri Dec 13 2013 17:57:01 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1