| @@ 1674-1690 (lines=17) @@ | ||
| 1671 | * |
|
| 1672 | * @return array |
|
| 1673 | */ |
|
| 1674 | public static function getAllExerciseEventByExeId($exe_id) |
|
| 1675 | { |
|
| 1676 | $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
| 1677 | $exe_id = intval($exe_id); |
|
| 1678 | $list = array(); |
|
| 1679 | ||
| 1680 | $sql = "SELECT * FROM $table_track_attempt |
|
| 1681 | WHERE exe_id = $exe_id |
|
| 1682 | ORDER BY position"; |
|
| 1683 | $res_question = Database::query($sql); |
|
| 1684 | if (Database::num_rows($res_question)) { |
|
| 1685 | while ($row = Database::fetch_array($res_question, 'ASSOC')) { |
|
| 1686 | $list[$row['question_id']][] = $row; |
|
| 1687 | } |
|
| 1688 | } |
|
| 1689 | return $list; |
|
| 1690 | } |
|
| 1691 | ||
| 1692 | /** |
|
| 1693 | * |
|
| @@ 1625-1644 (lines=20) @@ | ||
| 1622 | * |
|
| 1623 | * @return array |
|
| 1624 | */ |
|
| 1625 | public static function get_all_exercises_from_lp($lp_id, $course_id) |
|
| 1626 | { |
|
| 1627 | $lp_item_table = Database::get_course_table(TABLE_LP_ITEM); |
|
| 1628 | $course_id = intval($course_id); |
|
| 1629 | $lp_id = intval($lp_id); |
|
| 1630 | $sql = "SELECT * FROM $lp_item_table |
|
| 1631 | WHERE |
|
| 1632 | c_id = $course_id AND |
|
| 1633 | lp_id = '".$lp_id."' AND |
|
| 1634 | item_type = 'quiz' |
|
| 1635 | ORDER BY parent_item_id, display_order"; |
|
| 1636 | $res = Database::query($sql); |
|
| 1637 | ||
| 1638 | $my_exercise_list = array(); |
|
| 1639 | while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
| 1640 | $my_exercise_list[] = $row; |
|
| 1641 | } |
|
| 1642 | ||
| 1643 | return $my_exercise_list; |
|
| 1644 | } |
|
| 1645 | ||
| 1646 | /** |
|
| 1647 | * This function gets the comments of an exercise |
|
| @@ 6214-6234 (lines=21) @@ | ||
| 6211 | * |
|
| 6212 | * @return array |
|
| 6213 | */ |
|
| 6214 | public static function getDeletedDocuments($courseInfo, $sessionId = 0) |
|
| 6215 | { |
|
| 6216 | $table = Database::get_course_table(TABLE_DOCUMENT); |
|
| 6217 | $courseId = $courseInfo['real_id']; |
|
| 6218 | $sessionCondition = api_get_session_condition($sessionId); |
|
| 6219 | $sql = "SELECT * FROM $table |
|
| 6220 | WHERE |
|
| 6221 | path LIKE '%DELETED%' AND |
|
| 6222 | c_id = $courseId |
|
| 6223 | $sessionCondition |
|
| 6224 | ORDER BY path |
|
| 6225 | "; |
|
| 6226 | ||
| 6227 | $result = Database::query($sql); |
|
| 6228 | $files = array(); |
|
| 6229 | while ($document = Database::fetch_array($result, 'ASSOC')) { |
|
| 6230 | $files[] = $document; |
|
| 6231 | } |
|
| 6232 | ||
| 6233 | return $files; |
|
| 6234 | } |
|
| 6235 | ||
| 6236 | /** |
|
| 6237 | * @param int $id |
|
| @@ 5729-5745 (lines=17) @@ | ||
| 5726 | * @author Julio Montoya <[email protected]> |
|
| 5727 | * @return int user id |
|
| 5728 | */ |
|
| 5729 | function api_get_access_url_from_user($user_id) { |
|
| 5730 | $user_id = intval($user_id); |
|
| 5731 | $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
| 5732 | $table_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL); |
|
| 5733 | $sql = "SELECT access_url_id |
|
| 5734 | FROM $table_url_rel_user url_rel_user |
|
| 5735 | INNER JOIN $table_url u |
|
| 5736 | ON (url_rel_user.access_url_id = u.id) |
|
| 5737 | WHERE user_id = ".intval($user_id); |
|
| 5738 | $result = Database::query($sql); |
|
| 5739 | $list = array(); |
|
| 5740 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
| 5741 | $list[] = $row['access_url_id']; |
|
| 5742 | } |
|
| 5743 | return $list; |
|
| 5744 | } |
|
| 5745 | ||
| 5746 | /** |
|
| 5747 | * Gets the status of a user in a course |
|
| 5748 | * @param int $user_id |
|
| @@ 3976-3990 (lines=15) @@ | ||
| 3973 | * @param int $userId |
|
| 3974 | * @return array |
|
| 3975 | */ |
|
| 3976 | public static function get_user_course_categories($userId = 0) |
|
| 3977 | { |
|
| 3978 | $userId = empty($userId) ? api_get_user_id() : (int) $userId; |
|
| 3979 | $table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); |
|
| 3980 | $sql = "SELECT * FROM $table_category |
|
| 3981 | WHERE user_id = $userId |
|
| 3982 | ORDER BY sort ASC |
|
| 3983 | "; |
|
| 3984 | $result = Database::query($sql); |
|
| 3985 | $output = array(); |
|
| 3986 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
| 3987 | $output[$row['id']] = $row; |
|
| 3988 | } |
|
| 3989 | return $output; |
|
| 3990 | } |
|
| 3991 | ||
| 3992 | /** |
|
| 3993 | * Return an array the user_category id and title for the course $courseId for user $userId |
|
| @@ 709-728 (lines=20) @@ | ||
| 706 | * @param int $limit |
|
| 707 | * @return array |
|
| 708 | */ |
|
| 709 | public function searchByField($tag, $field_id, $limit = 10) |
|
| 710 | { |
|
| 711 | $field_id = intval($field_id); |
|
| 712 | $limit = intval($limit); |
|
| 713 | $tag = Database::escape_string($tag); |
|
| 714 | $sql = "SELECT DISTINCT id, option_display_text |
|
| 715 | FROM {$this->table} |
|
| 716 | WHERE |
|
| 717 | field_id = '".$field_id."' AND |
|
| 718 | option_value LIKE '%$tag%' |
|
| 719 | ORDER BY option_value |
|
| 720 | LIMIT 0, $limit |
|
| 721 | "; |
|
| 722 | $result = Database::query($sql); |
|
| 723 | $values = array(); |
|
| 724 | if (Database::num_rows($result)) { |
|
| 725 | $values = Database::store_result($result, 'ASSOC'); |
|
| 726 | } |
|
| 727 | ||
| 728 | return $values; |
|
| 729 | } |
|
| 730 | ||
| 731 | ||
| @@ 654-668 (lines=15) @@ | ||
| 651 | * @param string $course_code The course (default = current course) |
|
| 652 | * @return array |
|
| 653 | */ |
|
| 654 | public static function get_categories($course_code = null) |
|
| 655 | { |
|
| 656 | $course_info = api_get_course_info($course_code); |
|
| 657 | $course_id = $course_info['real_id']; |
|
| 658 | $table_group_cat = Database::get_course_table(TABLE_GROUP_CATEGORY); |
|
| 659 | $sql = "SELECT * FROM $table_group_cat |
|
| 660 | WHERE c_id = $course_id |
|
| 661 | ORDER BY display_order"; |
|
| 662 | $res = Database::query($sql); |
|
| 663 | $cats = array (); |
|
| 664 | while ($cat = Database::fetch_array($res)) { |
|
| 665 | $cats[] = $cat; |
|
| 666 | } |
|
| 667 | return $cats; |
|
| 668 | } |
|
| 669 | ||
| 670 | /** |
|
| 671 | * Get a group category |
|
| @@ 6471-6499 (lines=29) @@ | ||
| 6468 | * @param int $sessionId The session id |
|
| 6469 | * @return array |
|
| 6470 | */ |
|
| 6471 | public static function getTotalUserCoursesInSession($sessionId) |
|
| 6472 | { |
|
| 6473 | $tableUser = Database::get_main_table(TABLE_MAIN_USER); |
|
| 6474 | $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
| 6475 | ||
| 6476 | if (empty($sessionId)) { |
|
| 6477 | return []; |
|
| 6478 | } |
|
| 6479 | ||
| 6480 | $sql = "SELECT |
|
| 6481 | COUNT(u.id) as count, |
|
| 6482 | u.id, |
|
| 6483 | scu.status status_in_session, |
|
| 6484 | u.status user_status |
|
| 6485 | FROM $table scu |
|
| 6486 | INNER JOIN $tableUser u |
|
| 6487 | ON scu.user_id = u.id |
|
| 6488 | WHERE scu.session_id = " . intval($sessionId) ." |
|
| 6489 | GROUP BY u.id"; |
|
| 6490 | ||
| 6491 | $result = Database::query($sql); |
|
| 6492 | ||
| 6493 | $list = array(); |
|
| 6494 | while ($data = Database::fetch_assoc($result)) { |
|
| 6495 | $list[] = $data; |
|
| 6496 | } |
|
| 6497 | ||
| 6498 | return $list; |
|
| 6499 | } |
|
| 6500 | ||
| 6501 | ||
| 6502 | /** |
|
| @@ 8034-8057 (lines=24) @@ | ||
| 8031 | * |
|
| 8032 | * @return array |
|
| 8033 | */ |
|
| 8034 | public static function getCoursesInSession($sessionId) |
|
| 8035 | { |
|
| 8036 | if (empty($sessionId)) { |
|
| 8037 | return []; |
|
| 8038 | } |
|
| 8039 | ||
| 8040 | $tblSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
| 8041 | $tblCourse = Database::get_main_table(TABLE_MAIN_COURSE); |
|
| 8042 | ||
| 8043 | // list of course in this session |
|
| 8044 | $sql = "SELECT session_id, c.id |
|
| 8045 | FROM $tblSessionRelCourse src |
|
| 8046 | LEFT JOIN $tblCourse c |
|
| 8047 | ON c.id = src.c_id |
|
| 8048 | WHERE session_id = ".intval($sessionId); |
|
| 8049 | $res = Database::query($sql); |
|
| 8050 | ||
| 8051 | $listResultsCourseId = array(); |
|
| 8052 | while ($data = Database::fetch_assoc($res)) { |
|
| 8053 | $listResultsCourseId[] = $data['id']; |
|
| 8054 | } |
|
| 8055 | ||
| 8056 | return $listResultsCourseId; |
|
| 8057 | } |
|
| 8058 | ||
| 8059 | /** |
|
| 8060 | * Return an array of courses in session for user |
|
| @@ 2444-2460 (lines=17) @@ | ||
| 2441 | * @author Patrick Cool <[email protected]>, Ghent University |
|
| 2442 | * @version September 2007 |
|
| 2443 | */ |
|
| 2444 | public static function get_invitations($survey_code) |
|
| 2445 | { |
|
| 2446 | $course_id = api_get_course_int_id(); |
|
| 2447 | // Database table definition |
|
| 2448 | $table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
| 2449 | ||
| 2450 | $sql = "SELECT * FROM $table_survey_invitation |
|
| 2451 | WHERE |
|
| 2452 | c_id = $course_id AND |
|
| 2453 | survey_code = '".Database::escape_string($survey_code)."'"; |
|
| 2454 | $result = Database::query($sql); |
|
| 2455 | $return = array(); |
|
| 2456 | while ($row = Database::fetch_array($result)) { |
|
| 2457 | $return[$row['user']] = $row; |
|
| 2458 | } |
|
| 2459 | return $return; |
|
| 2460 | } |
|
| 2461 | ||
| 2462 | /** |
|
| 2463 | * This function displays the form for searching a survey |
|