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

Services/Tracking/classes/class.ilLPStatusObjectives.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 ilLPStatusObjectives extends ilLPStatus
00036 {
00037 
00038         function ilLPStatusObjectives($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','9171_LPStatusObjectives_notAttempted');
00052 
00053                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00054                 $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00055                 $members = $members_obj->getParticipants();
00056                         
00057                 // diff in progress and completed (use stored result in LPStatusWrapper)
00058                 $users = array_diff($members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
00059                 $users = array_diff($users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
00060 
00061                 $ilBench->stop('LearningProgress','9171_LPStatusObjectives_notAttempted');
00062                 return $users ? $users : array();
00063         }
00064 
00065         function _getInProgress($a_obj_id)
00066         {
00067                 global $ilDB;
00068 
00069                 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
00070                 
00071                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00072                 $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00073                 $members = $members_obj->getParticipants();
00074 
00075                 $query = "SELECT DISTINCT(user_id) FROM ut_learning_progress ".
00076                         "WHERE obj_id = '".$a_obj_id."' AND obj_type = 'crs'";
00077 
00078                 $res = $ilDB->query($query);
00079                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00080                 {
00081                         if(!in_array($row->user_id,$completed) and in_array($row->user_id,$members))
00082                         {
00083                                 $user_ids[] = $row->user_id;
00084                         }
00085                 }
00086                 return $user_ids ? $user_ids : array();
00087         }
00088 
00089         function _getCompleted($a_obj_id)
00090         {
00091                 global $ilDB;
00092 
00093                 global $ilBench;
00094                 $ilBench->start('LearningProgress','9173_LPStatusObjectives_completed');
00095 
00096                 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
00097                 foreach($status_info['objective_result'] as $user_id => $completed)
00098                 {
00099                         if(count($completed) == $status_info['num_objectives'])
00100                         {
00101                                 $usr_ids[] = $user_id;
00102                         }
00103                 }
00104                 $ilBench->stop('LearningProgress','9173_LPStatusObjectives_completed');
00105                 return $usr_ids ? $usr_ids : array();
00106         }
00107 
00108 
00109         function _getStatusInfo($a_obj_id)
00110         {
00111                 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
00112 
00113                 global $ilDB;
00114 
00115                 $status_info['objective_result'] = array();
00116                 $status_info['objectives'] = ilCourseObjective::_getObjectiveIds($a_obj_id);
00117                 $status_info['num_objectives'] = count($status_info['objectives']);
00118 
00119                 if(!$status_info['num_objectives'])
00120                 {
00121                         return $status_info;
00122                 }
00123                 else
00124                 {
00125                         $in = "objective_id IN('".implode("','",$status_info['objectives'])."') ";
00126                 }
00127 
00128                 $query = "SELECT * FROM crs_objective_status ".
00129                         "WHERE ".$in;
00130 
00131                 $res = $ilDB->query($query);
00132                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00133                 {
00134                         $status_info['completed'][$row->objective_id][] = $row->user_id;
00135                         $status_info['objective_result'][$row->user_id][$row->objective_id] = $row->objective_id;
00136                 }
00137 
00138                 // Read title/description
00139                 $query = "SELECT * FROM crs_objectives ".
00140                         "WHERE ".$in;
00141                 $res = $ilDB->query($query);
00142                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00143                 {
00144                         $status_info['objective_title'][$row->objective_id] = $row->title;
00145                         $status_info['objective_description'][$row->objective_id] = $row->description;
00146                 }
00147                 return $status_info;
00148         }
00149 }
00150                 
00151 
00152 ?>

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