MDL-75234 mod_data: load default templates when empty
The mod_data is forcing teachers to understand how to write templates even if they want to use basic forms. With this patch the default templates will be auto updated unless the user manually define the templates.
This commit is contained in:
@@ -20,9 +20,11 @@ use cm_info;
|
||||
use context_module;
|
||||
use completion_info;
|
||||
use data_field_base;
|
||||
use mod_data_renderer;
|
||||
use mod_data\event\course_module_viewed;
|
||||
use mod_data\event\template_viewed;
|
||||
use mod_data\event\template_updated;
|
||||
use moodle_page;
|
||||
use core_component;
|
||||
use stdClass;
|
||||
|
||||
@@ -155,6 +157,18 @@ class manager {
|
||||
return $this->cm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current module renderer.
|
||||
*
|
||||
* @param moodle_page|null $page the current page
|
||||
* @return mod_data_renderer the module renderer
|
||||
*/
|
||||
public function get_renderer(?moodle_page $page = null): mod_data_renderer {
|
||||
global $PAGE;
|
||||
$page = $page ?? $PAGE;
|
||||
return $page->get_renderer(self::PLUGINNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger module viewed event and set the module viewed for completion.
|
||||
*
|
||||
@@ -262,6 +276,11 @@ class manager {
|
||||
* NOTE: this method returns a default template if the module template is empty.
|
||||
* However, it won't update the template database field.
|
||||
*
|
||||
* Some possible options:
|
||||
* - search: string with the current searching text.
|
||||
* - page: integer repesenting the current pagination page numbre (if any)
|
||||
* - baseurl: a moodle_url object to the current page.
|
||||
*
|
||||
* @param string $templatename
|
||||
* @param array $options extra display options array
|
||||
* @return template the template instance
|
||||
|
||||
Reference in New Issue
Block a user