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

Services/Tracking/classes/class.ilLPStatusManual.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 
00035 class ilLPStatusManual extends ilLPStatus
00036 {
00037 
00038         function ilLPStatusManual($a_obj_id)
00039         {
00040                 global $ilDB;
00041 
00042                 parent::ilLPStatus($a_obj_id);
00043                 $this->db =& $ilDB;
00044         }
00045 
00046         function _getNotAttempted($a_obj_id)
00047         {
00048                 global $ilObjDataCache;
00049 
00050                 global $ilBench;
00051                 $ilBench->start('LearningProgress','9161_LPStatusManual_notAttempted');
00052 
00053                 switch($ilObjDataCache->lookupType($a_obj_id))
00054                 {
00055                         case 'crs':
00056 
00057                                 include_once 'course/classes/class.ilCourseMembers.php';
00058                                 
00059                                 $members = ilCourseMembers::_getMembers($a_obj_id);
00060                         
00061                                 // diff in progress and completed (use stored result in LPStatusWrapper)
00062                                 $users = array_diff($members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
00063                                 $users = array_diff($users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
00064 
00065                                 $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
00066                                 return $users;
00067 
00068                         case 'grp':
00069                                 
00070                                 include_once 'classes/class.ilObjGroup.php';
00071 
00072                                 $members = ilObjGroup::_getMembers($a_obj_id);
00073                                 // diff in progress and completed (use stored result in LPStatusWrapper)
00074                                 $users = array_diff($members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
00075                                 $users = array_diff($users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
00076 
00077                                 $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
00078                                 return $users;
00079 
00080                         default:
00081                                 $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
00082                                 return array();
00083                 }
00084         }
00085 
00086         function _getInProgress($a_obj_id)
00087         {
00088                 global $ilObjDataCache;
00089 
00090                 global $ilBench;
00091                 $ilBench->start('LearningProgress','9162_LPStatusManual_inProgress');
00092 
00093 
00094                 switch($ilObjDataCache->lookupType($a_obj_id))
00095                 {
00096                         case 'lm':
00097                         case 'htlm':
00098                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00099                                 return ilLPStatusManual::__getLMInProgress($a_obj_id);
00100 
00101                         case 'crs':
00102                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00103                                 return ilLPStatusManual::__getCourseInProgress($a_obj_id);
00104 
00105                         case 'grp':
00106                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00107                                 return ilLPStatusManual::__getGroupInProgress($a_obj_id);
00108 
00109                         default:
00110                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00111                                 echo "ilLPStatusManual: unknown type ".$ilObjDataCache->lookupType($a_obj_id);
00112                                 
00113                 }
00114                 return array();
00115         }
00116 
00117         function _getCompleted($a_obj_id)
00118         {
00119                 global $ilDB;
00120 
00121                 global $ilBench;
00122                 $ilBench->start('LearningProgress','9163_LPStatusManual_completed');
00123 
00124                 $query = "SELECT DISTINCT(usr_id) as user_id FROM ut_lp_marks ".
00125                         "WHERE obj_id = '".$a_obj_id."' ".
00126                         "AND completed = '1'";
00127 
00128                 $res = $ilDB->query($query);
00129                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00130                 {
00131                         $usr_ids[] = $row->user_id;
00132                 }
00133                 $ilBench->stop('LearningProgress','9163_LPStatusManual_completed');
00134                 return $usr_ids ? $usr_ids : array();
00135         }
00136 
00137         // Private
00138         function __getLMInProgress($a_obj_id)
00139         {
00140                 global $ilDB;
00141 
00142                 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
00143                 $query = "SELECT DISTINCT(user_id) FROM ut_learning_progress ".
00144                         "WHERE obj_id = '".$a_obj_id."'";
00145 
00146                 $res = $ilDB->query($query);
00147                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00148                 {
00149                         if(!in_array($row->user_id,$completed))
00150                         {
00151                                 $user_ids[] = $row->user_id;
00152                         }
00153                 }
00154                 return $user_ids ? $user_ids : array();
00155         }
00156 
00157         function __getCourseInProgress($a_obj_id)
00158         {
00159                 global $ilDB;
00160 
00161                 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
00162                 
00163                 include_once 'course/classes/class.ilCourseMembers.php';
00164                 $members = ilCourseMembers::_getMembers($a_obj_id);
00165 
00166                 $query = "SELECT DISTINCT(user_id) FROM ut_learning_progress ".
00167                         "WHERE obj_id = '".$a_obj_id."' AND obj_type = 'crs'";
00168 
00169                 $res = $ilDB->query($query);
00170                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00171                 {
00172                         if(!in_array($row->user_id,$completed) and in_array($row->user_id,$members))
00173                         {
00174                                 $user_ids[] = $row->user_id;
00175                         }
00176                 }
00177                 return $user_ids ? $user_ids : array();
00178         }
00179 
00180         function __getGroupInProgress($a_obj_id)
00181         {
00182                 global $ilDB;
00183 
00184                 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
00185                 
00186                 include_once 'classes/class.ilObjGroup.php';
00187                 $members = ilObjGroup::_getMembers($a_obj_id);
00188 
00189                 $query = "SELECT DISTINCT(user_id) FROM ut_learning_progress ".
00190                         "WHERE obj_id = '".$a_obj_id."' AND obj_type = 'grp'";
00191 
00192                 $res = $ilDB->query($query);
00193                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00194                 {
00195                         if(!in_array($row->user_id,$completed) and in_array($row->user_id,$members))
00196                         {
00197                                 $user_ids[] = $row->user_id;
00198                         }
00199                 }
00200                 return $user_ids ? $user_ids : array();
00201         }
00202 }       
00203 ?>

Generated on Fri Dec 13 2013 13:52:12 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1