Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_courseformat\output\activitybadge Class Reference

Base class to render an activity badge. More...

Inheritance diagram for core_courseformat\output\activitybadge:

Public Member Functions

 __construct (cm_info $cminfo)
 Constructor.
 
 export_for_template (renderer_base $output)
 Export this data so it can be used as the context for a mustache template.
 
 get_template_name (\renderer_base $renderer)
 Get the name of the template to use for this templatable.
 

Static Public Member Functions

static create_instance (cm_info $cminfo)
 Creates an instance of activityclass for the given course module, in case it implements it.
 

Public Attributes

array const STYLES
 Badge defined styles.
 

Protected Member Functions

 update_content ()
 This method will be called before exporting the template.
 

Protected Attributes

cm_info $cminfo = null
 The course module information.
 
string $content = null
 The content to be displayed in the activity badge.
 
string $elementid = null
 An optional element id in case the module wants to add some code for the activity badge (events, CSS...).
 
array $extraattributes = []
 An optional array of extra HTML attributes to add to the badge element (for example, data attributes).
 
string $style = self::STYLES['none']
 The style for the activity badge.
 
moodle_url $url = null
 An optional URL to redirect the user when the activity badge is clicked.
 

Detailed Description

Base class to render an activity badge.

Plugins can extend this class and override some methods to customize the content to be displayed in the activity badge.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_courseformat\output\activitybadge::__construct ( cm_info $cminfo)

Constructor.

Parameters
cm_info$cminfoThe course module information.

Member Function Documentation

◆ create_instance()

static core_courseformat\output\activitybadge::create_instance ( cm_info $cminfo)
staticfinal

Creates an instance of activityclass for the given course module, in case it implements it.

Parameters
cm_info$cminfo
Return values
self|nullAn instance of activityclass for the given module or null if the module doesn't implement it.

◆ export_for_template()

core_courseformat\output\activitybadge::export_for_template ( renderer_base $output)
final

Export this data so it can be used as the context for a mustache template.

Parameters
renderer_base$outputtypically, the renderer that's calling this function
Return values
stdClassdata context for a mustache template

Implements templatable.

◆ get_template_name()

core\output\named_templatable::get_template_name ( \renderer_base $renderer)
inherited

Get the name of the template to use for this templatable.

Parameters
renderer_base$rendererThe renderer requesting the template name
Return values
string

Implemented in core\output\local\dropdown\dialog, core\output\local\dropdown\status, core\output\sticky_footer, core_courseformat\output\local\content\cm\title, and qbank_viewquestionname\output\questionname.

◆ update_content()

core_courseformat\output\activitybadge::update_content ( )
abstractprotected

This method will be called before exporting the template.

It should be implemented by any module extending this class and will be in charge of updating any of the class attributes with the proper information that will be displayed in the activity badge (like the content or the badge style).

Reimplemented in mod_forum\output\courseformat\activitybadge, and mod_resource\output\courseformat\activitybadge.

Member Data Documentation

◆ $content

string core_courseformat\output\activitybadge::$content = null
protected

The content to be displayed in the activity badge.


◆ $extraattributes

array core_courseformat\output\activitybadge::$extraattributes = []
protected

An optional array of extra HTML attributes to add to the badge element (for example, data attributes).

The format for this array is [['name' => 'attr1', 'value' => 'attrval1'], ['name' => 'attr2', 'value' => 'attrval2']].

◆ $style

string core_courseformat\output\activitybadge::$style = self::STYLES['none']
protected

The style for the activity badge.


◆ $url

moodle_url core_courseformat\output\activitybadge::$url = null
protected

An optional URL to redirect the user when the activity badge is clicked.


◆ STYLES

array const core_courseformat\output\activitybadge::STYLES
Initial value:
= [
'none' => 'badge-none',
'dark' => 'badge-dark',
'danger' => 'badge-danger',
'warning' => 'badge-warning',
'info' => 'badge-info',
]

Badge defined styles.


The documentation for this class was generated from the following file: