| @@ 1091-1106 (lines=16) @@ | ||
| 1088 | * @param int $group_id |
|
| 1089 | * @return array |
|
| 1090 | */ |
|
| 1091 | public static function getTutors($group_id) |
|
| 1092 | { |
|
| 1093 | $tutor_user_table = Database :: get_course_table(TABLE_GROUP_TUTOR); |
|
| 1094 | $course_id = api_get_course_int_id(); |
|
| 1095 | $group_id = intval($group_id); |
|
| 1096 | ||
| 1097 | $sql = "SELECT user_id FROM $tutor_user_table |
|
| 1098 | WHERE c_id = $course_id AND group_id = $group_id"; |
|
| 1099 | $res = Database::query($sql); |
|
| 1100 | ||
| 1101 | $users = array(); |
|
| 1102 | while ($obj = Database::fetch_object($res)) { |
|
| 1103 | $users[] = api_get_user_info($obj->user_id); |
|
| 1104 | } |
|
| 1105 | return $users; |
|
| 1106 | } |
|
| 1107 | ||
| 1108 | /** |
|
| 1109 | * Get only students from a group (not tutors) |
|
| @@ 1113-1127 (lines=15) @@ | ||
| 1110 | * @param int $group_id |
|
| 1111 | * @return array |
|
| 1112 | */ |
|
| 1113 | public static function getStudents($group_id) |
|
| 1114 | { |
|
| 1115 | $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); |
|
| 1116 | $course_id = api_get_course_int_id(); |
|
| 1117 | $group_id = intval($group_id); |
|
| 1118 | $sql = "SELECT user_id FROM $group_user_table |
|
| 1119 | WHERE c_id = $course_id AND group_id = $group_id"; |
|
| 1120 | $res = Database::query($sql); |
|
| 1121 | $users = array(); |
|
| 1122 | ||
| 1123 | while ($obj = Database::fetch_object($res)) { |
|
| 1124 | $users[] = api_get_user_info($obj->user_id); |
|
| 1125 | } |
|
| 1126 | return $users; |
|
| 1127 | } |
|
| 1128 | ||
| 1129 | /** |
|
| 1130 | * Returns users belonging to any of the group |
|
| @@ 1281-1296 (lines=16) @@ | ||
| 1278 | * @param int $group_id |
|
| 1279 | * @return int Number of students in the given group. |
|
| 1280 | */ |
|
| 1281 | public static function number_of_students($group_id, $course_id = null) |
|
| 1282 | { |
|
| 1283 | $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); |
|
| 1284 | $group_id = intval($group_id); |
|
| 1285 | if (empty($course_id)) { |
|
| 1286 | $course_id = api_get_course_int_id(); |
|
| 1287 | } else { |
|
| 1288 | $course_id = intval($course_id); |
|
| 1289 | } |
|
| 1290 | $sql = "SELECT COUNT(*) AS number_of_students |
|
| 1291 | FROM $table_group_user |
|
| 1292 | WHERE c_id = $course_id AND group_id = $group_id"; |
|
| 1293 | $db_result = Database::query($sql); |
|
| 1294 | $db_object = Database::fetch_object($db_result); |
|
| 1295 | return $db_object->number_of_students; |
|
| 1296 | } |
|
| 1297 | ||
| 1298 | /** |
|
| 1299 | * Maximum number of students in a group |
|
| @@ 157-175 (lines=19) @@ | ||
| 154 | * Get the maximum display order of the thematic item |
|
| 155 | * @return int Maximum display order |
|
| 156 | */ |
|
| 157 | public function get_max_thematic_item($use_session = true) |
|
| 158 | { |
|
| 159 | // Database table definition |
|
| 160 | $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
| 161 | $session_id = api_get_session_id(); |
|
| 162 | if ($use_session) { |
|
| 163 | $condition_session = api_get_session_condition($session_id); |
|
| 164 | } else { |
|
| 165 | $condition_session = ''; |
|
| 166 | } |
|
| 167 | $course_id = api_get_course_int_id(); |
|
| 168 | $sql = "SELECT MAX(display_order) |
|
| 169 | FROM $tbl_thematic |
|
| 170 | WHERE c_id = $course_id AND active = 1 $condition_session"; |
|
| 171 | $rs = Database::query($sql); |
|
| 172 | $row = Database::fetch_array($rs); |
|
| 173 | ||
| 174 | return $row[0]; |
|
| 175 | } |
|
| 176 | ||
| 177 | /** |
|
| 178 | * Move a thematic |
|
| @@ 1590-1608 (lines=19) @@ | ||
| 1587 | * @param int $course_id |
|
| 1588 | * @return bool |
|
| 1589 | */ |
|
| 1590 | public static function is_user_filled_survey($user_id, $survey_id, $course_id) |
|
| 1591 | { |
|
| 1592 | $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); |
|
| 1593 | ||
| 1594 | $user_id = intval($user_id); |
|
| 1595 | $course_id = intval($course_id); |
|
| 1596 | $survey_id = intval($survey_id); |
|
| 1597 | ||
| 1598 | $sql = "SELECT DISTINCT user FROM $table_survey_answer |
|
| 1599 | WHERE |
|
| 1600 | c_id = $course_id AND |
|
| 1601 | user = $user_id AND |
|
| 1602 | survey_id = $survey_id"; |
|
| 1603 | $result = Database::query($sql); |
|
| 1604 | if (Database::num_rows($result)) { |
|
| 1605 | return true; |
|
| 1606 | } |
|
| 1607 | return false; |
|
| 1608 | } |
|
| 1609 | ||
| 1610 | /** |
|
| 1611 | * This function gets all the persons who have filled the survey |
|
| @@ 5098-5115 (lines=18) @@ | ||
| 5095 | * @param int $userId |
|
| 5096 | * @return array |
|
| 5097 | */ |
|
| 5098 | public static function getCourseAccessPerSessionAndUser($sessionId, $userId, $limit = null) |
|
| 5099 | { |
|
| 5100 | $table = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
| 5101 | ||
| 5102 | $sessionId = intval($sessionId); |
|
| 5103 | $userId = intval($userId); |
|
| 5104 | ||
| 5105 | $sql = "SELECT * FROM $table |
|
| 5106 | WHERE session_id = $sessionId AND user_id = $userId"; |
|
| 5107 | ||
| 5108 | if (!empty($limit)) { |
|
| 5109 | $limit = intval($limit); |
|
| 5110 | $sql .= " LIMIT $limit"; |
|
| 5111 | } |
|
| 5112 | $result = Database::query($sql); |
|
| 5113 | ||
| 5114 | return Database::store_result($result); |
|
| 5115 | } |
|
| 5116 | ||
| 5117 | /** |
|
| 5118 | * Get information from the track_e_course_access table |
|