コード例 #1
0
             //if session is defined, lets find only courses of this session
             $courseList = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']);
         } else {
             //if session is not defined lets search all courses STARTING with $_GET['q']
             //TODO change this function to search not only courses STARTING with $_GET['q']
             $courseList = CourseManager::get_courses_list(0, 0, 1, 'ASC', -1, $_GET['q'], null, true);
         }
         $results = array();
         if (empty($courseList)) {
             echo json_encode([]);
             break;
         }
         foreach ($courseList as $course) {
             $title = $course['title'];
             if (!empty($course['category_code'])) {
                 $parents = CourseCategoryManager::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) {
コード例 #2
0
    if ($result) {
        Display::addFlash(Display::return_message(get_lang('ItemCopied')));
    } else {
        Display::addFlash(Display::return_message(get_lang('ThereWasAnError'), 'error'));
    }
    header('Location: session_list.php');
    exit;
}
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
$courseId = isset($_GET['course_id']) ? $_GET['course_id'] : null;
$sessionFilter = new FormValidator('course_filter', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
$courseSelect = $sessionFilter->addElement('select_ajax', 'course_name', get_lang('SearchCourse'), null, array('url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_course'));
if (!empty($courseId)) {
    $courseInfo = api_get_course_info_by_id($courseId);
    $parents = CourseCategoryManager::getParentsToString($courseInfo['categoryCode']);
    $courseSelect->addOption($parents . $courseInfo['title'], $courseInfo['code'], ['selected' => 'selected']);
}
$url = api_get_self();
$actions = '
<script>
$(function() {
    $("#course_name").on("change", function() {
       var courseId = $(this).val();

       if (!courseId) {
        return;
       }

       window.location = "' . $url . '?course_id="+courseId;
    });