Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
mod_choice\manager Class Reference

Public Member Functions

 __construct (private cm_info cm_info $cm, private stdClass stdClass $instance)
 Class constructor.
 
 count_all_users_answered ()
 Return the current count of users who have answered this choice module, that the current user can see.
 
 get_context ()
 Return the current context.
 
 get_coursemodule ()
 Return the current cm_info.
 
 get_instance ()
 Return the current instance.
 
 has_answered ()
 Check if the current user has answered the choice.
 

Static Public Member Functions

static create_from_coursemodule (stdClass|cm_info $cm)
 Create a manager instance from a course_modules record.
 
static create_from_instance (stdClass $instance)
 Create a manager instance from an instance record.
 

Public Attributes

const MODULE = 'choice'
 Module name.
 

Constructor & Destructor Documentation

◆ __construct()

mod_choice\manager::__construct ( private cm_info cm_info $cm,
private stdClass stdClass $instance )

Class constructor.

Parameters
cm_info$cmcourse module info object
stdClass$instanceactivity instance object.
Parameters
$cm$cm the given course module info
$instance$instance activity instance object

Member Function Documentation

◆ count_all_users_answered()

mod_choice\manager::count_all_users_answered ( )

Return the current count of users who have answered this choice module, that the current user can see.

Return values
intthe number of answers that the user can see

◆ create_from_coursemodule()

static mod_choice\manager::create_from_coursemodule ( stdClass|cm_info $cm)
static

Create a manager instance from a course_modules record.

Parameters
stdClass | cm_info$cman activity record
Return values
manager

◆ create_from_instance()

static mod_choice\manager::create_from_instance ( stdClass $instance)
static

Create a manager instance from an instance record.

Parameters
stdClass$instancean activity record
Return values
manager

◆ get_context()

mod_choice\manager::get_context ( )

Return the current context.

Return values
context_module

◆ get_coursemodule()

mod_choice\manager::get_coursemodule ( )

Return the current cm_info.

Return values
cm_infothe course module

◆ get_instance()

mod_choice\manager::get_instance ( )

Return the current instance.

Return values
stdClassthe instance record

◆ has_answered()

mod_choice\manager::has_answered ( )

Check if the current user has answered the choice.

Note: this will count all answers, regardless of grouping.

Return values
booltrue if the user has answered, false otherwise

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