Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_courseformat\output\activitybadge Class Reference
Inheritance diagram for core_courseformat\output\activitybadge:
core\output\named_templatable renderable templatable mod_forum\output\courseformat\activitybadge mod_resource\output\courseformat\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.
 

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, mod_quiz\output\list_of_attempts, 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' => 'bg-dark text-white',
'danger' => 'bg-danger text-white',
'warning' => 'bg-warning text-dark',
'info' => 'bg-info text-white',
]

Badge defined styles.


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