| @@ 1588-1606 (lines=19) @@ | ||
| 1585 | * @param int $course_id |
|
| 1586 | * @return bool |
|
| 1587 | */ |
|
| 1588 | public static function is_user_filled_survey($user_id, $survey_id, $course_id) |
|
| 1589 | { |
|
| 1590 | $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); |
|
| 1591 | ||
| 1592 | $user_id = intval($user_id); |
|
| 1593 | $course_id = intval($course_id); |
|
| 1594 | $survey_id = intval($survey_id); |
|
| 1595 | ||
| 1596 | $sql = "SELECT DISTINCT user FROM $table_survey_answer |
|
| 1597 | WHERE |
|
| 1598 | c_id = $course_id AND |
|
| 1599 | user = $user_id AND |
|
| 1600 | survey_id = $survey_id"; |
|
| 1601 | $result = Database::query($sql); |
|
| 1602 | if (Database::num_rows($result)) { |
|
| 1603 | return true; |
|
| 1604 | } |
|
| 1605 | return false; |
|
| 1606 | } |
|
| 1607 | ||
| 1608 | /** |
|
| 1609 | * This function gets all the persons who have filled the survey |
|
| @@ 1305-1320 (lines=16) @@ | ||
| 1302 | * @param int $group_id iid |
|
| 1303 | * @return int Number of students in the given group. |
|
| 1304 | */ |
|
| 1305 | public static function number_of_students($group_id, $course_id = null) |
|
| 1306 | { |
|
| 1307 | $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); |
|
| 1308 | $group_id = intval($group_id); |
|
| 1309 | if (empty($course_id)) { |
|
| 1310 | $course_id = api_get_course_int_id(); |
|
| 1311 | } else { |
|
| 1312 | $course_id = intval($course_id); |
|
| 1313 | } |
|
| 1314 | $sql = "SELECT COUNT(*) AS number_of_students |
|
| 1315 | FROM $table_group_user |
|
| 1316 | WHERE c_id = $course_id AND group_id = $group_id"; |
|
| 1317 | $result = Database::query($sql); |
|
| 1318 | $db_object = Database::fetch_object($result); |
|
| 1319 | ||
| 1320 | return $db_object->number_of_students; |
|
| 1321 | } |
|
| 1322 | ||
| 1323 | /** |
|
| @@ 1733-1751 (lines=19) @@ | ||
| 1730 | * @todo use the function user_has_access that includes this function |
|
| 1731 | * @author Patrick Cool <[email protected]>, Ghent University |
|
| 1732 | */ |
|
| 1733 | public static function is_tutor_of_group($user_id, $group_id) |
|
| 1734 | { |
|
| 1735 | $table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR); |
|
| 1736 | $user_id = intval($user_id); |
|
| 1737 | $group_id = intval($group_id); |
|
| 1738 | $course_id = api_get_course_int_id(); |
|
| 1739 | ||
| 1740 | $sql = "SELECT * FROM $table_group_tutor |
|
| 1741 | WHERE |
|
| 1742 | c_id = $course_id AND |
|
| 1743 | user_id = $user_id AND |
|
| 1744 | group_id = $group_id"; |
|
| 1745 | $result = Database::query($sql); |
|
| 1746 | if (Database::num_rows($result) > 0) { |
|
| 1747 | return true; |
|
| 1748 | } else { |
|
| 1749 | return false; |
|
| 1750 | } |
|
| 1751 | } |
|
| 1752 | ||
| 1753 | /** |
|
| 1754 | * Is the user part of this group? This can be a tutor or a normal member |
|
| @@ 163-181 (lines=19) @@ | ||
| 160 | * Get the maximum display order of the thematic item |
|
| 161 | * @return int Maximum display order |
|
| 162 | */ |
|
| 163 | public function get_max_thematic_item($use_session = true) |
|
| 164 | { |
|
| 165 | // Database table definition |
|
| 166 | $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
| 167 | $session_id = api_get_session_id(); |
|
| 168 | if ($use_session) { |
|
| 169 | $condition_session = api_get_session_condition($session_id); |
|
| 170 | } else { |
|
| 171 | $condition_session = ''; |
|
| 172 | } |
|
| 173 | $course_id = api_get_course_int_id(); |
|
| 174 | $sql = "SELECT MAX(display_order) |
|
| 175 | FROM $tbl_thematic |
|
| 176 | WHERE c_id = $course_id AND active = 1 $condition_session"; |
|
| 177 | $rs = Database::query($sql); |
|
| 178 | $row = Database::fetch_array($rs); |
|
| 179 | ||
| 180 | return $row[0]; |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Move a thematic |
|
| @@ 911-938 (lines=28) @@ | ||
| 908 | * @param int $annoucement_id |
|
| 909 | * @return array |
|
| 910 | */ |
|
| 911 | public static function get_by_id($course_id, $annoucement_id) |
|
| 912 | { |
|
| 913 | $annoucement_id = intval($annoucement_id); |
|
| 914 | $course_id = $course_id ? intval($course_id) : api_get_course_int_id(); |
|
| 915 | ||
| 916 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
| 917 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
| 918 | ||
| 919 | $sql = "SELECT DISTINCT |
|
| 920 | announcement.id, |
|
| 921 | announcement.title, |
|
| 922 | announcement.content |
|
| 923 | FROM $tbl_announcement announcement |
|
| 924 | INNER JOIN $tbl_item_property ip |
|
| 925 | ON |
|
| 926 | announcement.id = ip.ref AND |
|
| 927 | announcement.c_id = ip.c_id |
|
| 928 | WHERE |
|
| 929 | announcement.c_id = $course_id AND |
|
| 930 | ip.tool='announcement' AND |
|
| 931 | announcement.id = $annoucement_id |
|
| 932 | "; |
|
| 933 | $result = Database::query($sql); |
|
| 934 | if (Database::num_rows($result)) { |
|
| 935 | return Database::fetch_array($result); |
|
| 936 | } |
|
| 937 | return array(); |
|
| 938 | } |
|
| 939 | ||
| 940 | /** |
|
| 941 | * this function gets all the users of the course, |
|
| @@ 5424-5441 (lines=18) @@ | ||
| 5421 | * @param int $userId |
|
| 5422 | * @return array |
|
| 5423 | */ |
|
| 5424 | public static function getCourseAccessPerSessionAndUser($sessionId, $userId, $limit = null) |
|
| 5425 | { |
|
| 5426 | $table = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
| 5427 | ||
| 5428 | $sessionId = intval($sessionId); |
|
| 5429 | $userId = intval($userId); |
|
| 5430 | ||
| 5431 | $sql = "SELECT * FROM $table |
|
| 5432 | WHERE session_id = $sessionId AND user_id = $userId"; |
|
| 5433 | ||
| 5434 | if (!empty($limit)) { |
|
| 5435 | $limit = intval($limit); |
|
| 5436 | $sql .= " LIMIT $limit"; |
|
| 5437 | } |
|
| 5438 | $result = Database::query($sql); |
|
| 5439 | ||
| 5440 | return Database::store_result($result); |
|
| 5441 | } |
|
| 5442 | ||
| 5443 | /** |
|
| 5444 | * Get information from the track_e_course_access table |
|