Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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 ?>