Esempio n. 1
0
/**
 * Prints the available (enrollable) courses as simple link entries
 */
function local_my_print_available_courses(&$excludedcourses, &$courseareacourses)
{
    $str = '';
    $config = get_config('local_my');
    $courses = local_get_enrollable_courses();
    if (empty($courses)) {
        return;
    }
    $overcount = 0;
    if (!empty($config->maxavailablelistsize)) {
        $overcount = count($courses) > $config->maxavailablelistsize;
        if ($overcount) {
            $courses = array_slice($courses, 0, 11);
        }
    }
    if (!empty($excludedcourses)) {
        $excludedids = array_keys($excludedcourses);
    } else {
        $excludedids = array();
    }
    foreach ($courses as $cid => $foo) {
        if (in_array($cid, $excludedids)) {
            unset($courses[$cid]);
        }
    }
    if (!count($courses)) {
        // No more courses to show once filtered.
        return '';
    }
    $options['printifempty'] = 0;
    $options['withcats'] = 2;
    $options['nocompletion'] = 1;
    $str .= '<div class="block block_my_available_courses">';
    $str .= local_my_print_courses('availablecourses', $courses, $options);
    if ($overcount) {
        $allcoursesurl = new moodle_url('/local/my/enrollable_courses.php');
        $link = '<a href="' . $allcoursesurl . '">' . get_string('seealllist', 'local_my') . '</a>';
        $str .= '<div class="local-my-overcount">' . $link . '</div>';
    }
    $str .= '</div>';
    return $str;
}
 */
require '../../config.php';
require_once $CFG->dirroot . '/my/lib.php';
require_once $CFG->dirroot . '/lib/coursecatlib.php';
// Security.
$context = context_system::instance();
require_login();
$titlestr = get_string('enrollablecourses', 'local_my');
// Start setting up the page.
$params = array();
$PAGE->set_context($context);
$PAGE->set_url('/local/my/enrollable_course.php', $params);
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_pagetype('my-index');
$PAGE->set_title($titlestr);
$PAGE->set_heading($titlestr);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('choosecoursetoenrollin', 'local_my'));
$courses = local_get_enrollable_courses();
if (empty($courses)) {
    return;
}
$options['printifempty'] = 0;
$options['withcats'] = 2;
echo '<center>';
echo '<div class="block" style="width:80%">';
echo local_my_print_courses('availablecourses', $courses, $options, true);
echo '</div>';
echo $OUTPUT->single_button(new moodle_url('/my/index.php'), get_string('backtohome', 'local_my'));
echo '</center>';
echo $OUTPUT->footer();