Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/inc/ajax/course_category.ajax.php

43 lines
1.2 KiB

<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls.
*/
require_once __DIR__.'/../global.inc.php';
api_protect_admin_script();
$action = $_REQUEST['a'];
switch ($action) {
case 'show_courses':
$categoryId = (int) $_REQUEST['id'];
$categoryInfo = CourseCategory::getCategoryById($categoryId);
if (!empty($categoryInfo)) {
$courses = CourseCategory::getCoursesInCategory($categoryInfo['code'], '', false, false);
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
$headers = [
get_lang('Name'),
];
$row = 0;
$column = 0;
foreach ($headers as $header) {
$table->setHeaderContents($row, $column, $header);
$column++;
}
$result = '';
foreach ($courses as $course) {
$row++;
$courseLink = '<a href="'.api_get_path(WEB_PATH).'courses/'.$course['directory'].'/index.php">'.$course['title'].'</a>';
$table->setCellContents($row, 0, $courseLink);
}
echo $table->toHtml();
exit;
}
break;
}
exit;