• Main Page
  • Related Pages
  • 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                         default:
00069                                 $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
00070                                 return array();
00071                 }
00072         }
00073 
00074         function _getInProgress($a_obj_id)
00075         {
00076                 global $ilObjDataCache;
00077 
00078                 global $ilBench;
00079                 $ilBench->start('LearningProgress','9162_LPStatusManual_inProgress');
00080 
00081 
00082                 switch($ilObjDataCache->lookupType($a_obj_id))
00083                 {
00084                         case 'lm':
00085                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00086                                 return ilLPStatusManual::__getLMInProgress($a_obj_id);
00087 
00088                         case 'crs':
00089                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00090                                 return ilLPStatusManual::__getCourseInProgress($a_obj_id);
00091 
00092                         default:
00093                                 $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
00094                                 echo "ilLPStatusManual: unknown type ".$ilObjDataCache->lookupType($a_obj_id);
00095                                 
00096                 }
00097                 return array();
00098         }
00099 
00100         function _getCompleted($a_obj_id)
00101         {
00102                 global $ilDB;
00103 
00104                 global $ilBench;
00105                 $ilBench->start('LearningProgress','9163_LPStatusManual_completed');
00106 
00107                 $query = "SELECT DISTINCT(usr_id) as user_id FROM ut_lp_marks ".
00108                         "WHERE obj_id = '".$a_obj_id."' ".
00109                         "AND completed = '1'";
00110 
00111                 $res = $ilDB->query($query);
00112                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00113                 {
00114                         $usr_ids[] = $row->user_id;
00115                 }
00116                 $ilBench->stop('LearningProgress','9163_LPStatusManual_completed');
00117                 return $usr_ids ? $usr_ids : array();
00118         }
00119 
00120         // Private
00121         function __getLMInProgress($a_obj_id)
00122         {
00123                 global $ilDB;
00124 
00125                 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
00126                 $query = "SELECT DISTINCT(user_id) FROM ut_learning_progress ".
00127                         "WHERE obj_id = '".$a_obj_id."'";
00128 
00129                 $res = $ilDB->query($query);
00130                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00131                 {
00132                         if(!in_array($row->user_id,$completed))
00133                         {
00134                                 $user_ids[] = $row->user_id;
00135                         }
00136                 }
00137                 return $user_ids ? $user_ids : array();
00138         }
00139 
00140         function __getCourseInProgress($a_obj_id)
00141         {
00142                 global $ilDB;
00143 
00144                 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
00145                 
00146                 include_once 'course/classes/class.ilCourseMembers.php';
00147                 $members = ilCourseMembers::_getMembers($a_obj_id);
00148 
00149                 $query = "SELECT DISTINCT(user_id) FROM ut_learning_progress ".
00150                         "WHERE obj_id = '".$a_obj_id."' AND obj_type = 'crs'";
00151 
00152                 $res = $ilDB->query($query);
00153                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00154                 {
00155                         if(!in_array($row->user_id,$completed) and in_array($row->user_id,$members))
00156                         {
00157                                 $user_ids[] = $row->user_id;
00158                         }
00159                 }
00160                 return $user_ids ? $user_ids : array();
00161         }
00162 
00163 }       
00164 ?>

Generated on Fri Dec 13 2013 11:57:59 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1