/** * Renderers a course list item. * * This function will be called for every course being displayed by course_listing. * * @param coursecat $category The currently selected category and the category the course belongs to. * @param course_in_list $course The course to produce HTML for. * @param int $selectedcourse The id of the currently selected course. * @return string */ public function course_listitem(coursecat $category, course_in_list $course, $selectedcourse) { $text = $course->get_formatted_name(); $attributes = array('class' => 'listitem listitem-course', 'data-id' => $course->id, 'data-selected' => $selectedcourse == $course->id ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0'); $bulkcourseinput = array('type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox'); if (!$category->has_manage_capability()) { // Very very hardcoded here. $bulkcourseinput['style'] = 'visibility:hidden'; } $viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id)); $html = html_writer::start_tag('li', $attributes); $html .= html_writer::start_div('clearfix'); if ($category->can_resort_courses()) { // In order for dnd to be available the user must be able to resort the category children.. $html .= html_writer::div($this->output->pix_icon('i/dragdrop', get_string('dndcourse')), 'float-left drag-handle'); } $html .= html_writer::start_div('ba-checkbox float-left'); $html .= html_writer::empty_tag('input', $bulkcourseinput) . ' '; $html .= html_writer::end_div(); $html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename')); $html .= html_writer::start_div('float-right'); if ($course->idnumber) { $html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber')); } $html .= $this->course_listitem_actions($category, $course); $html .= html_writer::end_div(); $html .= html_writer::end_div(); $html .= html_writer::end_tag('li'); return $html; }