MDL-40955 Course: Add a new renderer to give a complete course module

This commit is contained in:
Andrew Nicols 2013-07-31 00:50:48 +01:00
parent 1a3f52a102
commit 9ce4fa2fd4
2 changed files with 29 additions and 5 deletions

View File

@ -2,6 +2,12 @@ This files describes API changes for course formats
Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
=== 2.6 ===
* An additional course renderer function has been created which allows you to
specify the wrapper for a course module within a section (e.g. the <li>). This can be
found in core_course_renderer::course_section_cm_list_item().
=== 2.5 ===
* Functions responsible for output in course/lib.php are deprecated, the code is moved to

View File

@ -820,6 +820,28 @@ class core_course_renderer extends plugin_renderer_base {
return '';
}
/**
* Renders HTML to display one course module for display within a section.
*
* This function calls:
* {@link core_course_renderer::course_section_cm()}
*
* @param stdClass $course
* @param completion_info $completioninfo
* @param cm_info $mod
* @param int|null $sectionreturn
* @param array $displayoptions
* @return String
*/
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->get_extra_classes();
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
}
return $output;
}
/**
* Renders HTML to display one course module in a course section
*
@ -956,7 +978,7 @@ class core_course_renderer extends plugin_renderer_base {
continue;
}
if ($modulehtml = $this->course_section_cm($course,
if ($modulehtml = $this->course_section_cm_list_item($course,
$completioninfo, $mod, $sectionreturn, $displayoptions)) {
$moduleshtml[$modnumber] = $modulehtml;
}
@ -972,11 +994,7 @@ class core_course_renderer extends plugin_renderer_base {
array('class' => 'movehere', 'title' => $strmovefull));
}
$mod = $modinfo->cms[$modnumber];
$modclasses = 'activity '. $mod->modname. ' modtype_'.$mod->modname. ' '. $mod->get_extra_classes();
$sectionoutput .= html_writer::start_tag('li', array('class' => $modclasses, 'id' => 'module-' . $mod->id));
$sectionoutput .= $modulehtml;
$sectionoutput .= html_writer::end_tag('li');
}
if ($ismoving) {