feat: Include activity name in rendered script tag
Updated the `render_activity` method to accept an additional parameter for activity name and include it in the script tag data attributes. This allows for more descriptive data handling on the client side. Adjusted calls to this method to provide the necessary activity name. Improved readability of the code by adhering to standard formatting practices.
This commit is contained in:
parent
4ac9f46986
commit
a40ffdf41f
2 changed files with 19 additions and 16 deletions
|
@ -6,16 +6,19 @@ defined('MOODLE_INTERNAL') || die();
|
|||
|
||||
use plugin_renderer_base;
|
||||
|
||||
class renderer extends plugin_renderer_base {
|
||||
class renderer extends plugin_renderer_base
|
||||
{
|
||||
|
||||
private static $modals_rendered = false;
|
||||
|
||||
public function render_activity($activity_id) {
|
||||
$script = "<script data-activity-id='$activity_id' src='/mod/exp360/script.js'></>";
|
||||
public function render_activity($activity_id, $activity_name)
|
||||
{
|
||||
$script = "<script data-activity-id='$activity_id' data-activity-name='$activity_name' src='/mod/exp360/script.js'></script>";
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function render_modals() {
|
||||
public function render_modals()
|
||||
{
|
||||
if (self::$modals_rendered) {
|
||||
return '';
|
||||
}
|
||||
|
|
2
lib.php
2
lib.php
|
@ -53,7 +53,7 @@ function mod_exp360_cm_info_dynamic(cm_info $cm)
|
|||
|
||||
$renderer = $PAGE->get_renderer('mod_exp360');
|
||||
$modals = $renderer->render_modals();
|
||||
$script = $renderer->render_activity($cm->id);
|
||||
$script = $renderer->render_activity($cm->id, $cm->name);
|
||||
|
||||
$cm->set_no_view_link();
|
||||
$cm->set_content($modals . $script);
|
||||
|
|
Loading…
Reference in a new issue