Commit b60f70ab authored by Camille Tardy's avatar Camille Tardy
Browse files

Add cousrte code beneath course name in course listing

parent a4714209
......@@ -373,4 +373,88 @@ class course_renderer extends \core_course_renderer {
return $color_fac;
}
/**
* 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';
} 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'));
// 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'));
$content .= html_writer::tag($nametag, $coursenamelink, array('class' => 'coursename'));
// 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 = $this->output->pix_icon('i/info', $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 .= html_writer::tag('div', $course->shortname, array('class' => 'courseshortname'));
$content .= $this->coursecat_coursebox_content($chelper, $course);
$content .= html_writer::end_tag('div'); // .content
$content .= html_writer::end_tag('div'); // .coursebox
return $content;
}
}
......@@ -806,6 +806,10 @@ select + .btn-group, .btn-group + .btn {
}
}
.courseshortname{
margin: 5px;
}
.enrolmenticons {
padding-top: 0.35em;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment