//TODO change this function to search not only courses STARTING with $_GET['q'] if (api_is_platform_admin()) { $courseList = CourseManager::get_courses_list(0, 0, 1, 'ASC', -1, $_GET['q'], null, true); } elseif (api_is_teacher()) { $courseList = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id(), $_GET['q']); } } $results = array(); if (empty($courseList)) { echo json_encode([]); break; } foreach ($courseList as $course) { $title = $course['title']; if (!empty($course['category_code'])) { $parents = CourseCategory::getParentsToString($course['category_code']); $title = $parents . $course['title']; } $results['items'][] = array('id' => $course['id'], 'text' => $title); } echo json_encode($results); } break; case 'search_course_by_session': if (api_is_platform_admin()) { $results = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']); $results2 = array(); if (!empty($results)) { foreach ($results as $item) { $item2 = array(); foreach ($item as $id => $internal) {