@@ 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 |
@@ 87-101 (lines=15) @@ | ||
84 | * @return type |
|
85 | * @assert ('') === false |
|
86 | */ |
|
87 | public static function get_surveys($course_code, $session_id = 0) |
|
88 | { |
|
89 | $table_survey = Database :: get_course_table(TABLE_SURVEY); |
|
90 | if (empty($course_code)) { |
|
91 | return false; |
|
92 | } |
|
93 | $course_info = api_get_course_info($course_code); |
|
94 | $session_condition = api_get_session_condition($session_id, true, true); |
|
95 | ||
96 | $sql = "SELECT * FROM $table_survey |
|
97 | WHERE c_id = {$course_info['real_id']} $session_condition "; |
|
98 | $result = Database::query($sql); |
|
99 | $result = Database::store_result($result, 'ASSOC'); |
|
100 | return $result; |
|
101 | } |
|
102 | ||
103 | /** |
|
104 | * Retrieves all the survey information |
|
@@ 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 |
@@ 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 |
@@ 1286-1303 (lines=18) @@ | ||
1283 | * @param int $readonly |
|
1284 | * @return boolean true /false |
|
1285 | */ |
|
1286 | function update_existing_document($_course, $documentId, $filesize, $readonly = 0) |
|
1287 | { |
|
1288 | $document_table = Database::get_course_table(TABLE_DOCUMENT); |
|
1289 | $documentId = intval($documentId); |
|
1290 | $filesize = intval($filesize); |
|
1291 | $readonly = intval($readonly); |
|
1292 | $course_id = $_course['real_id']; |
|
1293 | ||
1294 | $sql = "UPDATE $document_table SET |
|
1295 | size = '$filesize', |
|
1296 | readonly = '$readonly' |
|
1297 | WHERE c_id = $course_id AND id = $documentId"; |
|
1298 | if (Database::query($sql)) { |
|
1299 | return true; |
|
1300 | } else { |
|
1301 | return false; |
|
1302 | } |
|
1303 | } |
|
1304 | ||
1305 | /** |
|
1306 | * This function updates the last_edit_date, last edit user id on all folders in a given path |
@@ 5367-5388 (lines=22) @@ | ||
5364 | * @param bool $getAllSessions |
|
5365 | * @return mixed |
|
5366 | */ |
|
5367 | public static function getCountForum( |
|
5368 | $courseId, |
|
5369 | $sessionId = 0, |
|
5370 | $getAllSessions = false |
|
5371 | ) { |
|
5372 | $forum = Database::get_course_table(TABLE_FORUM); |
|
5373 | if ($getAllSessions) { |
|
5374 | $sql = "SELECT count(*) as count |
|
5375 | FROM $forum f |
|
5376 | WHERE f.c_id = %s"; |
|
5377 | } else { |
|
5378 | $sql = "SELECT count(*) as count |
|
5379 | FROM $forum f |
|
5380 | WHERE f.c_id = %s and f.session_id = %s"; |
|
5381 | } |
|
5382 | ||
5383 | $sql = sprintf($sql, intval($courseId), intval($sessionId)); |
|
5384 | $result = Database::query($sql); |
|
5385 | $row = Database::fetch_array($result); |
|
5386 | ||
5387 | return $row['count']; |
|
5388 | } |
|
5389 | ||
5390 | /** |
|
5391 | * @param int $userId |