Commit 7d8cc2c6 authored by jun's avatar jun
Browse files

MDL-70821 course: Remove unused completion info from cm_format

With the activity information output component dealing with the
completion information of the activity, there's no need to pass
completion info to the cm_format renderable.
parent abc5d761
......@@ -54,24 +54,17 @@ class cm_format implements renderable, templatable {
/** @var array optional display options */
protected $displayoptions;
/** @var completion_info the course completion */
protected $completioninfo;
/**
* Constructor.
*
* @param course_format $format the course format
* @param section_info $section the section info
* @param completion_info $completioninfo the course completion info
* @param cm_info $mod the course module ionfo
* @param array $displayoptions optional extra display options
*/
public function __construct(course_format $format, section_info $section, completion_info $completioninfo,
cm_info $mod, array $displayoptions = []) {
public function __construct(course_format $format, section_info $section, cm_info $mod, array $displayoptions = []) {
$this->format = $format;
$this->section = $section;
$this->completioninfo = $completioninfo;
$this->mod = $mod;
$this->displayoptions = $displayoptions;
}
......@@ -79,7 +72,7 @@ class cm_format implements renderable, templatable {
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output typically, the renderer that's calling this function
* @param \renderer_base $output typically, the renderer that's calling this function
* @return stdClass data context for a mustache template
*/
public function export_for_template(\renderer_base $output): stdClass {
......
......@@ -25,8 +25,9 @@
namespace core_course\output\section_format;
use core_course\course_format;
use core_course\output\section_format;
use renderer_base;
use section_info;
use completion_info;
use renderable;
use templatable;
use cm_info;
......@@ -78,12 +79,11 @@ class cmitem implements renderable, templatable {
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output typically, the renderer that's calling this function
* @return array data context for a mustache template
* @return stdClass data context for a mustache template
*/
public function export_for_template(\renderer_base $output): stdClass {
$format = $this->format;
$course = $format->get_course();
$completioninfo = new completion_info($course);
$mod = $this->mod;
$data = new stdClass();
......@@ -95,7 +95,7 @@ class cmitem implements renderable, templatable {
// This will apply styles to the course homepage when the activity information output component is displayed.
$hasinfo = $showactivityconditions || $showactivitydates;
$item = new $this->cmclass($format, $this->section, $completioninfo, $mod, $this->displayoptions);
$item = new $this->cmclass($format, $this->section, $mod, $this->displayoptions);
return (object)[
'id' => $mod->id,
'module' => $mod->modname,
......@@ -105,4 +105,3 @@ class cmitem implements renderable, templatable {
];
}
}
......@@ -872,7 +872,7 @@ class core_course_renderer extends plugin_renderer_base {
$section = $modinfo->get_section_info($format->get_section_number());
$cmclass = $format->get_output_classname('cm_format');
$cm = new $cmclass($format, $section, $completioninfo, $mod, $displayoptions);
$cm = new $cmclass($format, $section, $mod, $displayoptions);
// The course outputs works with format renderers, not with course renderers.
$renderer = $format->get_renderer($this->page);
return $renderer->render($cm);
......
Supports Markdown
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