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; }
/** * Returns HTML to display a course category as a part of a tree * * This is an internal function, to display a particular category and all its contents * use {@link core_course_renderer::course_category()} * * @param coursecat_helper $chelper various display options * @param coursecat $coursecat * @param int $depth depth of this category in the current tree * @return string */ protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth) { // open category tag $classes = array('category'); if (empty($coursecat->visible)) { $classes[] = 'dimmed_category'; } if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) { // do not load content $categorycontent = ''; $classes[] = 'notloaded'; if ($coursecat->get_children_count() || $chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count()) { $classes[] = 'with_children'; $classes[] = 'collapsed'; } } else { // load category content $categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth); $classes[] = 'loaded'; if (!empty($categorycontent)) { $classes[] = 'with_children'; } } // Make sure JS file to expand category content is included. $this->coursecat_include_js(); $content = html_writer::start_tag('div', array('class' => join(' ', $classes), 'data-categoryid' => $coursecat->id, 'data-depth' => $depth, 'data-showcourses' => $chelper->get_show_courses(), 'data-type' => self::COURSECAT_TYPE_CATEGORY)); // category name $categoryname = $coursecat->get_formatted_name(); $categoryname = html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $coursecat->id)), $categoryname); if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT && ($coursescount = $coursecat->get_courses_count())) { $categoryname .= html_writer::tag('span', ' (' . $coursescount . ')', array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse')); } $content .= html_writer::start_tag('div', array('class' => 'info')); $content .= html_writer::tag($depth > 1 ? 'h4' : 'h3', $categoryname, array('class' => 'categoryname')); $content .= html_writer::end_tag('div'); // .info // add category content to the output $content .= html_writer::tag('div', $categorycontent, array('class' => 'content')); $content .= html_writer::end_tag('div'); // .category // Return the course category tree HTML return $content; }
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course, $type = 3) { 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); } if ($type == 3 || $OUTPUT->body_id() != 'page-site-index') { return parent::coursecat_coursebox_content($chelper, $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)); } $coursecontacts = theme_bcu_get_setting('tilesshowcontacts'); if ($coursecontacts) { $coursecontacttitle = theme_bcu_get_setting('tilescontactstitle'); // 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 = ($coursecontacttitle ? $coursecontact['rolename'] . ': ' : html_writer::tag('i', ' ', array('class' => 'fa fa-graduation-cap'))) . 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; }
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; }
/** * 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) { 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 = ''; $coursehascontacts = $course->has_course_contacts(); // Display course summary. if ($course->has_summary()) { $summaryclass = 'summary'; if ($coursehascontacts == false) { $summaryclass .= ' noteachers'; } $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'); // .summary } // 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')); } 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) { $content .= html_writer::start_tag('ul', array('class' => 'teachers')); foreach ($course->get_course_contacts() as $userid => $coursecontact) { $faiconsetting = $this->output->get_setting('courselistteachericon'); $faiconsettinghtml = empty($faiconsetting) ? '' : '<i class="fa fa-' . $faiconsetting . '"></i> '; $name = $faiconsettinghtml . $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 } } return $content; }
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; }
LEFT JOIN {course_completions} cc ON cc.course=e.courseid and ue.userid=cc.userid WHERE c.id=$course->id group by e.courseid"); $chelper = new coursecat_helper; // .coursebox $coursecount ++; $classes = ($coursecount%2) ? 'odd' : 'even'; if ($coursecount == 1) { $classes .= ' first'; } if ($coursecount >= count($courses)) { $classes .= ' last'; } $classes = trim('coursebox clearfix '); if ($chelper->get_show_courses() >= 30) { $nametag = 'h3'; } else { $classes .= ' collapsed'; $nametag = 'div'; } if($i%2==0) $classes .= ' even'; else $classes .=' odd'; $content = html_writer::start_tag('div', array( 'class' => $classes, 'data-courseid' => $course->id, 'data-type' => 1, ));