/** * Returns the url of the first image contained in the course summary file area * @param int $id the course id * @return string the url to the image */ function block_my_course_progress_get_course_image_url($id) { global $CFG; require_once $CFG->libdir . "/filelib.php"; $course = get_course($id); if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); if ($isimage) { return file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); } } return false; }
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) { global $CFG; if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) { return ''; } if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $content = ''; // Display course overview files. $contentimages = $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if ($isimage) { $contentimages .= html_writer::start_tag('div', array('class' => 'imagebox')); $images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage')); $contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images); $contentimages .= html_writer::end_tag('div'); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } $content .= $contentimages . $contentfiles; // Display course summary. if ($course->has_summary()) { $content .= $chelper->get_course_formatted_summary($course); } // Display course contacts. See course_in_list::get_course_contacts(). if ($course->has_course_contacts()) { $content .= html_writer::start_tag('ul', array('class' => 'teachers')); foreach ($course->get_course_contacts() as $userid => $coursecontact) { $name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']); $content .= html_writer::tag('li', $name); } $content .= html_writer::end_tag('ul'); // ...Teachers!. } return $content; }
protected function mycourses($CFG, $sidebar) { $mycourses = enrol_get_users_courses($_SESSION['USER']->id); $courselist = array(); foreach ($mycourses as $key => $val) { $courselist[] = $val->id; } $content = ''; for ($x = 1; $x <= sizeof($courselist); $x++) { $course = get_course($courselist[$x - 1]); $title = $course->fullname; if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg"; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if (!$isimage) { $url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg"; } } $content .= '<div class="view view-second view-mycourse ' . ($x % 3 == 0 ? 'view-nomargin' : '') . '"> <img src="' . $url . '" /> <div class="mask"> <h2>' . $title . '</h2> <a href="' . $CFG->wwwroot . '/course/view.php?id=' . $courselist[$x - 1] . '" class="info">Enter</a> </div> </div>'; } return $content; }
<div class="seal"> <?php /** * Display fullname and shortname of course * @author André Rodrigues <Math> * @date 2015/12/19 */ $actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; if (strpos($actual_link, $CFG->wwwroot . '/course') !== false) { // if ($PAGE->course->category != 0) { if (isset($_GET['id'])) { $courseid = $_GET['id']; $c = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $course = new course_in_list($c); $url = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); } echo '<div>'; echo '<img src="' . $url . '" />'; echo '</div>'; echo '<div>'; echo '<p>' . $PAGE->course->fullname . '</p>'; echo '<p>' . $PAGE->course->shortname . '</p>'; echo '</div>'; } } ?> <script> $(function() {
public function top_promoted_courses() { global $CFG, $OUTPUT, $DB, $PAGE; $featuredcontent = ''; /* Get Featured courses id from DB */ $featuredids = theme_pioneer_get_setting('toppromotedcourses'); $rcourseids = !empty($featuredids) ? explode(",", $featuredids, 10) : array(); if (empty($rcourseids)) { return false; } $hcourseids = theme_pioneer_hidden_courses_ids(); if (!empty($hcourseids)) { foreach ($rcourseids as $key => $val) { if (in_array($val, $hcourseids)) { unset($rcourseids[$key]); } } } foreach ($rcourseids as $key => $val) { $ccourse = $DB->get_record('course', array('id' => $val)); if (empty($ccourse)) { unset($rcourseids[$key]); continue; } } if (empty($rcourseids)) { return false; } $fcourseids = array_chunk($rcourseids, 10); $totalfcourse = count($fcourseids); $promotedtitle = theme_pioneer_get_setting('toppromotedtitle', 'format_text'); $promotedtitle = theme_pioneer_lang($promotedtitle); $closelisting = theme_pioneer_get_setting('topclosefeatured', 'format_text'); $topshowfeatured = theme_pioneer_get_setting('topshowfeatured', 'format_text'); $featuredheader = '<div class="custom-courses-list" id="topPromoted-Courses"> <div class="container-fluid"> <div class="promoted_courses" data-crow="' . $totalfcourse . '">'; $featuredfooter = ' </div> </div> </div>'; if (!empty($fcourseids)) { echo '<div id="featured-listing" class="collapse out">'; echo '<div data-toggle="collapse" data-target="#featured-listing" class="btn-link"style="text-align:center;">' . $closelisting . '</div>'; foreach ($fcourseids as $courseids) { $rowcontent = '<div><div class="row-fluid topcarousel">'; foreach ($courseids as $courseid) { $course = get_course($courseid); $no = get_config('theme_pioneer', 'toppatternselect'); $nimgp = empty($no) || $no == "default" ? 'no-image' : 'cs0' . $no . '/no-image'; $noimgurl = $OUTPUT->pix_url($nimgp, 'theme'); $courseurl = new moodle_url('/course/view.php', array('id' => $courseid)); if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $imgurl = ''; $summary = theme_pioneer_strip_html_tags($course->summary); $summary = theme_pioneer_course_trim_char($summary, 125); $trimtitle = theme_pioneer_course_trim_char($course->fullname, 90); $context = context_course::instance($course->id); $nostudents = count_role_users(5, $context); foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $imgurl = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if (!$isimage) { $imgurl = $noimgurl; } } if (empty($imgurl)) { $imgurl = $PAGE->theme->setting_file_url('headerbackgroundimage', 'headerbackgroundimage', true); if (!$imgurl) { $imgurl = $noimgurl; } } $listitems = ' <div class="row-fluid"> <div class="span3"> <img src="' . $imgurl . '" width="100%" height="75px" alt="' . $course->fullname . '"> </div> <div class="span5"> <h5><a href="' . $courseurl . '" >' . $trimtitle . '</a></h5> </div> <div class="span4"> <p>' . $summary . '</p> </div> </div>'; $coursehtml = ' <div style="background-image: url(' . $imgurl . ');background-repeat: no-repeat;background-size:cover; background-position:center;" class="promowrap"> <div class="fp-coursebox"> <div class="fp-courseinfo"> <p style="font-size:24px;font-weight:bold;"><a href="' . $courseurl . '" id="button" data-toggle="tooltip" data-placement="bottom"title="' . $summary . '" >' . $trimtitle . '</a></p> <div class="titlebar"> <h5>' . $promotedtitle . '</h5> </div> <div data-toggle="collapse" data-target="#featured-listing" class="btn-link">' . $topshowfeatured . '</div> </div> </div> </div>'; $rowcontent .= $coursehtml; echo $listitems; } $rowcontent .= '</div></div> '; $featuredcontent .= $rowcontent; } echo "</div>"; } $featuredcourses = $featuredheader . $featuredcontent . $featuredfooter; return $featuredcourses; }
/** * Return the course information that is public (visible by every one) * * @param course_in_list $course course in list object * @param stdClass $coursecontext course context object * @return array the course information * @since Moodle 3.2 */ protected static function get_course_public_information(course_in_list $course, $coursecontext) { static $categoriescache = array(); // Category information. if (!array_key_exists($course->category, $categoriescache)) { $categoriescache[$course->category] = coursecat::get($course->category, IGNORE_MISSING); } $category = $categoriescache[$course->category]; // Retrieve course overview used files. $files = array(); foreach ($course->get_course_overviewfiles() as $file) { $fileurl = moodle_url::make_webservice_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename())->out(false); $files[] = array('filename' => $file->get_filename(), 'fileurl' => $fileurl, 'filesize' => $file->get_filesize(), 'filepath' => $file->get_filepath(), 'mimetype' => $file->get_mimetype(), 'timemodified' => $file->get_timemodified()); } // Retrieve the course contacts, // we need here the users fullname since if we are not enrolled can be difficult to obtain them via other Web Services. $coursecontacts = array(); foreach ($course->get_course_contacts() as $contact) { $coursecontacts[] = array('id' => $contact['user']->id, 'fullname' => $contact['username']); } // Allowed enrolment methods (maybe we can self-enrol). $enroltypes = array(); $instances = enrol_get_instances($course->id, true); foreach ($instances as $instance) { $enroltypes[] = $instance->enrol; } // Format summary. list($summary, $summaryformat) = external_format_text($course->summary, $course->summaryformat, $coursecontext->id, 'course', 'summary', null); $displayname = get_course_display_name_for_list($course); $coursereturns = array(); $coursereturns['id'] = $course->id; $coursereturns['fullname'] = external_format_string($course->fullname, $coursecontext->id); $coursereturns['displayname'] = external_format_string($displayname, $coursecontext->id); $coursereturns['shortname'] = external_format_string($course->shortname, $coursecontext->id); $coursereturns['categoryid'] = $course->category; $coursereturns['categoryname'] = $category == null ? '' : $category->name; $coursereturns['summary'] = $summary; $coursereturns['summaryformat'] = $summaryformat; $coursereturns['summaryfiles'] = external_util::get_area_files($coursecontext->id, 'course', 'summary', false, false); $coursereturns['overviewfiles'] = $files; $coursereturns['contacts'] = $coursecontacts; $coursereturns['enrollmentmethods'] = $enroltypes; return $coursereturns; }
/** * Returns detailed info aboout a course * * @param int $id Course identifier */ function get_course_info($id, $username = '') { global $CFG, $DB; $username = utf8_decode($username); $username = strtolower($username); $query = "SELECT\n\t\t\tco.id AS remoteid,\n\t\t\tca.id AS cat_id,\n\t\t\tca.name AS cat_name,\n\t\t\tca.description AS cat_description,\n\t\t\tco.sortorder,\n\t\t\tco.fullname,\n\t\t\tco.shortname,\n\t\t\tco.idnumber,\n\t\t\tco.summary,\n\t\t\tco.startdate,\n\t\t\tco.lang\n\t\t\tFROM\n\t\t\t{$CFG->prefix}course_categories ca\n\t\t\tJOIN\n\t\t\t{$CFG->prefix}course co ON\n\t\t\tca.id = co.category\n\t\t\tWHERE\n\t\t\tco.id = ?\n\t\t\tORDER BY\n\t\t\tsortorder ASC"; $params = array($id); $record = $DB->get_record_sql($query, $params); $options['noclean'] = true; $course_info = get_object_vars($record); $course_info['fullname'] = format_string($course_info['fullname']); $course_info['cat_name'] = format_string($course_info['cat_name']); $context = context_coursecat::instance($course_info['cat_id']); $course_info['cat_description'] = file_rewrite_pluginfile_urls($course_info['cat_description'], 'pluginfile.php', $context->id, 'coursecat', 'description', NULL); $course_info['cat_description'] = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $course_info['cat_description']); $course_info['cat_description'] = format_text($course_info['cat_description'], FORMAT_MOODLE, $options); $context = context_course::instance($record->remoteid); $course_info['summary'] = file_rewrite_pluginfile_urls($course_info['summary'], 'pluginfile.php', $context->id, 'course', 'summary', NULL); $course_info['summary'] = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $course_info['summary']); $course_info['summary'] = format_text($course_info['summary'], FORMAT_MOODLE, $options); /* Get course cost if any */ $instances = enrol_get_instances($id, true); $params = array($id); $query = "SELECT count(*)\n FROM\n {$CFG->prefix}course_sections\n WHERE\n course = ? and section != 0 and visible=1\n "; $course_info['numsections'] = $DB->count_records_sql($query, $params); $course_info['self_enrolment'] = 0; $course_info['guest'] = 0; $in = true; $now = time(); foreach ($instances as $instance) { if ($instance->enrol == 'paypal' || $instance->enrol == 'joomdle') { $enrol = $instance->enrol; $query = "SELECT cost, currency\n\t\t\t\t\t\t\tFROM {$CFG->prefix}enrol\n\t\t\t\t\t\t\twhere courseid = ? and enrol = ?"; $params = array($id, $enrol); $record = $DB->get_record_sql($query, $params); $course_info['cost'] = (double) $record->cost; $course_info['currency'] = $record->currency; } /* Get enrolment dates. We get the last one, as good/bad as any other XXX */ if ($instance->enrolstartdate) { $course_info['enrolstartdate'] = $instance->enrolstartdate; } if ($instance->enrolenddate) { $course_info['enrolenddate'] = $instance->enrolenddate; } if ($instance->enrolperiod) { $course_info['enrolperiod'] = $instance->enrolperiod; } // Self-enrolment if ($instance->enrol == 'self') { $course_info['self_enrolment'] = 1; } // Guest access if ($instance->enrol == 'guest') { $course_info['guest'] = 1; } if ($instance->enrolstartdate && $instance->enrolenddate) { $in = false; if ($instance->enrolstartdate <= $now && $instance->enrolenddate >= $now) { $in = true; } } else { if ($instance->enrolstartdate) { $in = false; if ($instance->enrolstartdate <= $now) { $in = true; } } else { if ($instance->enrolenddate) { $in = false; if ($instance->enrolenddate >= $now) { $in = true; } } } } } $course_info['in_enrol_date'] = $in; $course_info['enroled'] = 0; if ($username) { $user = get_complete_user_data('username', $username); $courses = enrol_get_users_courses($user->id, true); $my_courses = array(); foreach ($courses as $course) { $my_courses[] = $course->id; } if (in_array($id, $my_courses)) { $course_info['enroled'] = 1; } } $course_info['summary_files'] = array(); $course = new course_in_list(get_course($id)); foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/auth/joomdle/pluginfile_joomdle.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); $url_item = array(); $url_item['url'] = $url; $course_info['summary_files'][] = $url_item; } return $course_info; }
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) { /* * We had to override this renderer to output the full category list for * a course : cat 1 / cat 2 / subcat / etc */ global $CFG; if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) { return ''; } if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $content = ''; // Display course overview files. $contentimages = $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if ($isimage) { $contentimages .= html_writer::start_tag('div', array('class' => 'imagebox')); $images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage')); $contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images); $contentimages .= html_writer::end_tag('div'); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } $content .= $contentimages . $contentfiles; // Display course summary. if ($course->has_summary()) { $content .= $chelper->get_course_formatted_summary($course); } // Display course contacts. See course_in_list::get_course_contacts(). if ($course->has_course_contacts()) { $content .= html_writer::start_tag('ul', array('class' => 'teachers')); foreach ($course->get_course_contacts() as $userid => $coursecontact) { $name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']); $content .= html_writer::tag('li', $name); } $content .= html_writer::end_tag('ul'); // .teachers } // Display course category if necessary (for example in search results). if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) { require_once $CFG->libdir . '/coursecatlib.php'; if ($cat = coursecat::get($course->category, IGNORE_MISSING)) { $content .= html_writer::start_tag('div', array('class' => 'coursecat')); // $content .= get_string('category').': '. // html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), // $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed')); $parents = coursecat::get_many($cat->get_parents()); $linkydink = []; foreach ($parents as $parent) { $linkydink[] = $parent->get_formatted_name(); } $linkydink[] = $cat->get_formatted_name(); $content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), implode(" / ", $linkydink), array('class' => $cat->visible ? '' : 'dimmed')); $content .= html_writer::end_tag('div'); // .coursecat } } return $content; }
/** * Construct contents of course_overview block * * @param array $courses list of courses in sorted order * @param array $overviews list of course overviews * @return string html to be displayed in course_overview block */ public function course_overview($courses, $overviews) { global $CFG; $html = ''; $config = get_config('block_course_overview'); $ismovingcourse = false; $courseordernumber = 0; $maxcourses = count($courses); $userediting = false; // Intialise string/icon etc if user is editing and courses > 1 if ($this->page->user_is_editing() && count($courses) > 1) { $userediting = true; $this->page->requires->js_init_call('M.block_course_overview.add_handles'); // Check if course is moving $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL); $movingcourseid = optional_param('courseid', 0, PARAM_INT); } // Render first movehere icon. if ($ismovingcourse) { // Remove movecourse param from url. $this->page->ensure_param_not_in_url('movecourse'); // Show moving course notice, so user knows what is being moved. $html .= $this->output->box_start('notice'); $a = new stdClass(); $a->fullname = $courses[$movingcourseid]->fullname; $a->cancellink = html_writer::link($this->page->url, get_string('cancel')); $html .= get_string('movingcourse', 'block_course_overview', $a); $html .= $this->output->box_end(); $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid)); // Create move icon, so it can be used. $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere'))); $moveurl = html_writer::link($moveurl, $movetofirsticon); $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere')); } foreach ($courses as $key => $course) { // If moving course, then don't show course which needs to be moved. if ($ismovingcourse && $course->id == $movingcourseid) { continue; } $html .= $this->output->box_start('span6', "course-{$course->id}"); $html .= html_writer::start_tag('div', array('class' => 'coursebox')); $html .= html_writer::start_tag('div', array('class' => 'course_title')); // If user is editing, then add move icons. if ($userediting && !$ismovingcourse) { $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move'))); $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id)); $moveurl = html_writer::link($moveurl, $moveicon); $html .= html_writer::tag('div', $moveurl, array('class' => 'move')); } // No need to pass title through s() here as it will be done automatically by html_writer. $attributes = array('title' => $course->fullname); if ($course->id > 0) { if (empty($course->visible)) { $attributes['class'] = 'dimmed'; } $courseurl = new moodle_url('/course/view.php', array('id' => $course->id)); $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id); $link = html_writer::link($courseurl, $coursefullname, $attributes); $html .= $this->output->heading($link, 2, 'title'); } else { $html .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title'); } $html .= $this->output->box('', 'flush'); $html .= html_writer::end_tag('div'); if (!empty($config->showchildren) && $course->id > 0) { // List children here. if ($children = block_course_overview_get_child_shortnames($course->id)) { $html .= html_writer::tag('span', $children, array('class' => 'coursechildren')); } } // show summary and image require_once $CFG->libdir . '/coursecatlib.php'; global $DB; $coursesummary = $DB->get_field("course", "summary", array("id" => $course->id)); $html .= html_writer::tag('p', $coursesummary, array('class' => 'summary')); // If user is moving courses, then down't show overview. if (isset($overviews[$course->id]) && !$ismovingcourse) { $html .= $this->activity_display($course->id, $overviews[$course->id]); } $html .= $this->output->box('', 'flush'); $courseordernumber++; if ($ismovingcourse) { $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid)); $a = new stdClass(); $a->movingcoursename = $courses[$movingcourseid]->fullname; $a->currentcoursename = $course->fullname; $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere'))); $moveurl = html_writer::link($moveurl, $movehereicon); $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere')); } //show image $contentimages = ''; $thiscourse = new course_in_list($course); foreach ($thiscourse->get_course_overviewfiles() as $courseimage) { $isimage = $courseimage->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $courseimage->get_contextid() . '/' . $courseimage->get_component() . '/' . $courseimage->get_filearea() . $courseimage->get_filepath() . $courseimage->get_filename()); if ($isimage) { $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url)), array('class' => 'courseimage')); } } $html .= $contentimages; $html .= html_writer::end_tag('div'); $html .= $this->output->box_end(); } // Wrap course list in a div and return. return html_writer::tag('div', $html, array('class' => 'course_list')); }
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) { global $CFG; // if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) { // return ''; // } if ($course instanceof stdClass) { require_once($CFG->libdir. '/coursecatlib.php'); $course = new course_in_list($course); } $content = ''; // display course overview files $contentimages = $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("$CFG->wwwroot/pluginfile.php", '/'. $file->get_contextid(). '/'. $file->get_component(). '/'. $file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage); if ($isimage) { $contentimages .= html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image '. $course->fullname, 'class' => 'courseimage')); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } /** * @updateDate 25/09/2014 * @author eFaktor (fbv) * * Description * Check if there is any image connected with the course. * Not Image --> Add an empty place */ if (!$contentimages) { $contentimages .= html_writer::start_tag('div', array('class' => 'not_courseimage')); $contentimages .= html_writer::end_div();//courseimage } $content .= $contentimages. $contentfiles; // display course summary if ($course->has_summary()) { $content .= html_writer::start_tag('div', array('class' => 'course-summary')); $content .= $course->summary; $content .= html_writer::end_div();//courseimage } // display course contacts. See course_in_list::get_course_contacts() if ($course->has_course_contacts()) { $content .= html_writer::start_tag('ul', array('class' => 'teachers')); foreach ($course->get_course_contacts() as $userid => $coursecontact) { $name = $coursecontact['rolename'].': '. html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']); $content .= html_writer::tag('li', $name); } $content .= html_writer::end_tag('ul'); // .teachers } // display course category if necessary (for example in search results) if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) { require_once($CFG->libdir. '/coursecatlib.php'); if ($cat = coursecat::get($course->category, IGNORE_MISSING)) { $content .= html_writer::start_tag('div', array('class' => 'coursecat')); $content .= get_string('category').': '. html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed')); $content .= html_writer::end_tag('div'); // .coursecat } } $content .= html_writer::tag('div', '', array('class' => 'boxfooter')); // .coursecat return $content; }
public function promoted_courses() { global $CFG, $OUTPUT, $DB; $pcourseenable = theme_eguru_get_setting('pcourseenable'); if (!$pcourseenable) { return false; } $featuredcontent = ''; /* Get Featured courses id from DB */ $featuredids = theme_eguru_get_setting('promotedcourses'); $rcourseids = !empty($featuredids) ? explode(",", $featuredids) : array(); if (empty($rcourseids)) { return false; } $hcourseids = theme_eguru_hidden_courses_ids(); if (!empty($hcourseids)) { foreach ($rcourseids as $key => $val) { if (in_array($val, $hcourseids)) { unset($rcourseids[$key]); } } } foreach ($rcourseids as $key => $val) { $ccourse = $DB->get_record('course', array('id' => $val)); if (empty($ccourse)) { unset($rcourseids[$key]); continue; } } if (empty($rcourseids)) { return false; } $fcourseids = array_chunk($rcourseids, 6); $totalfcourse = count($fcourseids); $promotedtitle = theme_eguru_get_setting('promotedtitle', 'format_text'); $promotedtitle = theme_eguru_lang($promotedtitle); $featuredheader = '<div class="custom-courses-list" id="Promoted-Courses"> <div class="container-fluid"> <div class="titlebar with-felements"> <h2>' . $promotedtitle . '</h2> <div class="slidenav pagenav"> <button class="nav-item nav-prev slick-prev"> <i class="fa fa-chevron-right"></i><i class="fa fa-chevron-left"></i> </button> <button class="nav-item nav-next slick-next"> <i class="fa fa-chevron-right"></i><i class="fa fa-chevron-left"></i> </button> <div class="clearfix"></div> </div> <div class="clearfix"></div> </div> <div class="promoted_courses" data-crow="' . $totalfcourse . '">'; $featuredfooter = ' </div> </div> </div>'; if (!empty($fcourseids)) { foreach ($fcourseids as $courseids) { $rowcontent = '<div><div class="row-fluid">'; foreach ($courseids as $courseid) { $course = get_course($courseid); $no = get_config('theme_eguru', 'patternselect'); $nimgp = empty($no) || $no == "default" ? 'cs00/no-image' : 'cs0' . $no . '/no-image'; $noimgurl = $OUTPUT->pix_url($nimgp, 'theme'); $courseurl = new moodle_url('/course/view.php', array('id' => $courseid)); if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $imgurl = ''; $summary = theme_eguru_strip_html_tags($course->summary); $summary = theme_eguru_course_trim_char($summary, 75); $context = context_course::instance($course->id); $nostudents = count_role_users(5, $context); foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $imgurl = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if (!$isimage) { $imgurl = $noimgurl; } } if (empty($imgurl)) { $imgurl = $noimgurl; } $coursehtml = '<div class="span2"> <div class="course-box"> <div class="thumb"><a href="' . $courseurl . '"> <img src="' . $imgurl . '" width="135" height="135" alt="' . $course->fullname . '"></a></div> <div class="info"> <h5><a href="' . $courseurl . '">' . $course->fullname . '</a></h5> </div> </div> </div>'; $rowcontent .= $coursehtml; } $rowcontent .= '</div></div>'; $featuredcontent .= $rowcontent; } } $featuredcourses = $featuredheader . $featuredcontent . $featuredfooter; return $featuredcourses; }
/** * Displays one course in the list of courses. * * This is an internal function, to display an information about just one course * please use {@link core_course_renderer::course_info_box()} * * @param coursecat_helper $chelper various display options * @param course_in_list|stdClass $course * @param string $additionalclasses additional classes to add to the main <div> tag (usually * depend on the course position in list - first/last/even/odd) * @return string */ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '') { global $CFG; if (!isset($this->strings->summary)) { $this->strings->summary = get_string('summary'); } if ($chelper->get_show_courses() <= self::COURSECAT_SHOW_COURSES_COUNT) { return ''; } if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $content = ''; $classes = trim('coursebox clearfix ' . $additionalclasses); if ($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_EXPANDED) { $nametag = 'h3'; $nametag1 = 'div'; /* GWL*/ } else { $classes .= ' collapsed'; $nametag = 'div'; } // .coursebox $content .= html_writer::start_tag('div', array('class' => $classes, 'data-courseid' => $course->id, 'data-type' => self::COURSECAT_TYPE_COURSE)); $content .= html_writer::start_tag('div', array('class' => 'info')); // display course overview files $contentimages = $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if ($isimage) { $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url)), array('class' => 'courseimage')) . html_writer::link(new moodle_url('#', array('' => '')), 'Plus', array('class' => 'icon-plus')) . html_writer::link(new moodle_url('#', array('' => '')), 'Minus', array('class' => 'icon-minus')); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } $content .= $contentimages . $contentfiles; // course name $coursename = $chelper->get_course_formatted_name($course); $coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed')); $coursenamelink1 = html_writer::tag('span', '', array('class' => 'duration-time')) . html_writer::tag('span', '', array('class' => 'time-text')) . html_writer::link(new moodle_url('#page-footer'), 'CONTACT US', array('class' => 'anchor-1 join-now')); /* GWL : Add extra, Remove Duration, Remove Time & Change Contact Us url to Footer */ /*GWL - Remove Contact Us Link */ /* $coursenamelink1 = html_writer::tag('span','', array('class'=>'duration-time')).html_writer::tag('span','', array('class'=>'time-text')).html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), 'CONTACT US', array('class' => 'anchor-1 join-now')); */ /* GWL : Add extra, Remove Duration & Remove Time */ /* GWL - Duration & Time */ /* $coursenamelink1 = html_writer::tag('span','Duration', array('class'=>'duration-time')).html_writer::tag('span','10hrs', array('class'=>'time-text')).html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), 'Join Now', array('class' => 'anchor-1 join-now')); */ /* gwl */ $content .= html_writer::tag($nametag, $coursenamelink, array('class' => 'coursename')); $content .= html_writer::tag($nametag1, $coursenamelink1, array('class' => 'course-bottom')); /* GWL*/ // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page. $content .= html_writer::start_tag('div', array('class' => 'moreinfo')); if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) { if ($course->has_summary() || $course->has_course_contacts() || $course->has_course_overviewfiles()) { $url = new moodle_url('/course/info.php', array('id' => $course->id)); $image = html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/info'), 'alt' => $this->strings->summary)); $content .= html_writer::link($url, $image, array('title' => $this->strings->summary)); // Make sure JS file to expand course content is included. $this->coursecat_include_js(); } } $content .= html_writer::end_tag('div'); // .moreinfo // print enrolmenticons if ($icons = enrol_get_course_info_icons($course)) { $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons')); foreach ($icons as $pix_icon) { $content .= $this->render($pix_icon); } $content .= html_writer::end_tag('div'); // .enrolmenticons } $content .= html_writer::end_tag('div'); // .info $content .= html_writer::start_tag('div', array('class' => 'content')); $content .= $this->coursecat_coursebox_content($chelper, $course); $content .= html_writer::end_tag('div'); // .content $content .= html_writer::end_tag('div'); // .coursebox return $content; }
/** * Returns HTML to display course content (summary, course contacts and optionally category name) * * This method is called from coursecat_coursebox() and may be re-used in AJAX * * @param coursecat_helper $chelper various display options * @param stdClass|course_in_list $course * @return string */ protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) { if (!$this->enablecategoryicon) { return parent::coursecat_coursebox_content($chelper, $course); } global $CFG; if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) { return ''; } if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $content = ''; $coursehassummary = $course->has_summary(); $coursehascontacts = $course->has_course_contacts(); $courseoverviewfiles = $course->get_course_overviewfiles(); // Display course summary. if ($coursehassummary) { $summaryclass = 'summary'; if ($coursehascontacts == false && empty($courseoverviewfiles)) { $summaryclass .= ' fullsummarywidth'; } if (!$course->visible) { $summaryclass .= ' dimmed'; } $content .= html_writer::start_tag('div', array('class' => $summaryclass)); $content .= $chelper->get_course_formatted_summary($course, array('overflowdiv' => true, 'noclean' => true, 'para' => false)); $content .= html_writer::end_tag('div'); // Class .summary. } // Display course overview files. $contentimages = $contentfiles = ''; foreach ($courseoverviewfiles as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if ($isimage) { $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url)), array('class' => 'courseimage')); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } $content .= $contentimages . $contentfiles; // Display course contacts. See course_in_list::get_course_contacts(). if ($coursehascontacts) { $teacherclass = 'teachers'; if (!$course->visible) { $teacherclass .= ' dimmed'; } if (!empty($courseoverviewfiles) && !$coursehassummary) { $teacherclass .= ' courseboxright'; } else { if (empty($courseoverviewfiles) && !$coursehassummary) { $teacherclass .= ' fullsummarywidth'; } else { if (!empty($courseoverviewfiles) && $coursehassummary) { $teacherclass .= ' fullsummarywidth'; } } } $content .= html_writer::start_tag('ul', array('class' => $teacherclass)); $teacherlinkattributes = array(); if (!$course->visible) { $teacherlinkattributes['class'] = 'dimmed'; } foreach ($course->get_course_contacts() as $userid => $coursecontact) { $faiconsetting = \theme_essential\toolbox::get_setting('courselistteachericon'); $faiconsettinghtml = empty($faiconsetting) ? '' : '<span aria-hidden="true" class="fa fa-' . $faiconsetting . '"></span> '; $name = $faiconsettinghtml . $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username'], $teacherlinkattributes); $content .= html_writer::tag('li', $name); } $content .= html_writer::end_tag('ul'); // Class .teachers. } // Display course category if necessary (for example in search results). if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) { require_once $CFG->libdir . '/coursecatlib.php'; if ($cat = coursecat::get($course->category, IGNORE_MISSING)) { $content .= html_writer::start_tag('div', array('class' => 'coursecat')); $content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed')); $content .= html_writer::end_tag('div'); // Class .coursecat. } } return $content; }
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course, $type = 1) { global $CFG, $OUTPUT, $PAGE; if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) { return ''; } if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $content = ''; // Display course overview files. $contentimages = ''; $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if ($isimage) { if ($type == 1) { $contentimages .= html_writer::start_tag('div', array('class' => 'courseimage')); $link = new moodle_url('/course/view.php', array('id' => $course->id)); $contentimages .= html_writer::link($link, html_writer::empty_tag('img', array('src' => $url))); $contentimages .= html_writer::end_tag('div'); } else { $contentimages .= "<div class='cimbox' style='background: #FFF url({$url}) no-repeat center center; background-size: contain;'></div>"; } } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } if (strlen($contentimages) == 0 && $type == 2) { // Default image $url = $PAGE->theme->setting_file_url('frontpagerendererdefaultimage', 'frontpagerendererdefaultimage'); $contentimages .= "<div class='cimbox' style='background: #FFF url({$url}) no-repeat center center; background-size: contain;'></div>"; } $content .= $contentimages . $contentfiles; if ($type == 2) { $content .= $this->coursecat_coursebox_enrolmenticons($course); } if ($type == 2) { $content .= html_writer::start_tag('div', array('class' => 'coursebox-content')); $coursename = $chelper->get_course_formatted_name($course); $content .= html_writer::tag('h3', html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed', 'title' => $coursename))); } $content .= html_writer::start_tag('div', array('class' => 'summary')); if (isset($coursename)) { $content .= html_writer::tag('p', html_writer::tag('b', $coursename)); } // Display course summary. if ($course->has_summary()) { $summs = $chelper->get_course_formatted_summary($course, array('overflowdiv' => false, 'noclean' => true, 'para' => false)); $summs = strip_tags($summs); $truncsum = strlen($summs) > 70 ? substr($summs, 0, 70) . "..." : $summs; $content .= html_writer::tag('span', $truncsum, array('title' => $summs)); } // Display course contacts. See course_in_list::get_course_contacts(). if ($course->has_course_contacts()) { $content .= html_writer::start_tag('ul', array('class' => 'teachers')); foreach ($course->get_course_contacts() as $userid => $coursecontact) { $name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']); $content .= html_writer::tag('li', $name); } $content .= html_writer::end_tag('ul'); // Teachers. } $content .= html_writer::end_tag('div'); // Summary. // Display course category if necessary (for example in search results). if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) { require_once $CFG->libdir . '/coursecatlib.php'; if ($cat = coursecat::get($course->category, IGNORE_MISSING)) { $content .= html_writer::start_tag('div', array('class' => 'coursecat')); $content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed')); $content .= html_writer::end_tag('div'); // Coursecat. } } if ($type == 2) { $content .= html_writer::end_tag('div'); } $content .= html_writer::tag('div', '', array('class' => 'boxfooter')); // Coursecat. return $content; }
public function frontpage_available_courses() { /* available courses */ global $CFG, $OUTPUT; require_once $CFG->libdir . '/coursecatlib.php'; $chelper = new coursecat_helper(); $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses'))); $chelper->set_attributes(array('class' => 'frontpage-course-list-all')); $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options()); $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options()); $course_ids = array_keys($courses); $new_course = get_string('availablecourses'); $header = '<div id="frontpage-course-list"> <h2>' . $new_course . '</h2> <div class="courses frontpage-course-list-all"> <div class="row-fluid">'; $footer = '</div> </div> </div>'; $co_cnt = 1; $content = ''; if ($ccc = get_courses('all', 'c.sortorder ASC', 'c.id,c.shortname,c.visible')) { foreach ($course_ids as $course_id) { $course = get_course($course_id); $noimg_url = $OUTPUT->pix_url('no-image', 'theme'); $course_url = new moodle_url('/course/view.php', array('id' => $course_id)); if ($course instanceof stdClass) { require_once $CFG->libdir . '/coursecatlib.php'; $course = new course_in_list($course); } $img_url = ''; $context = context_course::instance($course->id); foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $img_url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if (!$isimage) { $img_url = $noimg_url; } } if (empty($img_url)) { $img_url = $noimg_url; } $content .= '<div class="span3"> <div class="fp-coursebox"> <div class="fp-coursethumb"> <a href="' . $course_url . '"> <img src="' . $img_url . '" width="243" height="165" alt="' . $course->fullname . '"> </a> </div> <div class="fp-courseinfo"> <h5><a href="' . $course_url . '">' . $course->fullname . '</a></h5> <div class="readmore"><a href="' . $course_url . '">Readmore<i class="fa fa-angle-double-right"></i></a></div> </div> </div> </div>'; if ($co_cnt % 4 == "0") { $content .= '<div class="clearfix hidexs"></div>'; } $co_cnt++; } } $course_html = $header . $content . $footer; echo $course_html; if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) { // Print link to create a new course, for the 1st available category. echo $this->add_new_course_button(); } }