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