Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_h5pactivity\local\manager Class Reference

Class manager for H5P activity. More...

Public Member Functions

 __construct (cm_info $coursemodule, stdClass $instance)
 Class contructor.
 
 can_submit (stdClass $user=null)
 Check if the user has permission to submit a particular h5pactivity for a specific user.
 
 can_view_all_attempts (stdClass $user=null)
 Check if a user can see the activity attempts list.
 
 can_view_own_attempts (stdClass $user=null)
 Check if a user can see own attempts.
 
 count_attempts (int $userid=null)
 Count the activity completed attempts.
 
 count_users_attempts ()
 Return an array of all users and it's total attempts.
 
 get_active_users_join (bool $allpotentialusers=false, $currentgroup=false)
 Return the join to collect all activity active users.
 
 get_attempt (int $attemptid)
 Return a single attempt.
 
 get_context ()
 Return the current context.
 
 get_coursemodule ()
 Return the current cm_info.
 
 get_grader ()
 Return the specific grader object for this activity.
 
 get_instance ()
 Return the current instance.
 
 get_report (int $userid=null, int $attemptid=null, $currentgroup=false)
 Return the suitable report to show the attempts.
 
 get_selected_attempt ()
 Return the selected attempt criteria.
 
 get_user_attempts (int $userid)
 Return an array of all user attempts (including incompleted)
 
 get_users_scaled_score (int $userid=0)
 Return a relation of userid and the valid attempt's scaled score.
 
 is_tracking_enabled ()
 Check if tracking is enabled in a particular h5pactivity for a specific user.
 
 set_module_viewed (stdClass $course)
 Trigger module viewed event and set the module viewed for completion.
 

Static Public Member Functions

static create_from_coursemodule ($coursemodule)
 Create a manager instance from an course_modules record.
 
static create_from_instance (stdClass $instance)
 Create a manager instance from an instance record.
 
static get_grading_methods ()
 Return the available grading methods.
 
static get_review_modes ()
 Return the available review modes.
 

Public Attributes

const GRADEAVERAGEATTEMPT = 2
 Use average attempt results for grading.
 
const GRADEFIRSTATTEMPT = 4
 Use first attempt results for grading.
 
const GRADEHIGHESTATTEMPT = 1
 Use highest attempt results for grading.
 
const GRADELASTATTEMPT = 3
 Use last attempt results for grading.
 
const GRADEMANUAL = 0
 No automathic grading using attempt results.
 
const REVIEWCOMPLETION = 1
 Participants can review their own attempts when have one attempt completed.
 
const REVIEWNONE = 0
 Participants cannot review their own attempts.
 

Detailed Description

Class manager for H5P activity.

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

Constructor & Destructor Documentation

◆ __construct()

mod_h5pactivity\local\manager::__construct ( cm_info $coursemodule,
stdClass $instance )

Class contructor.

Parameters
cm_info$coursemodulecourse module info object
stdClass$instanceH5Pactivity instance object.

Member Function Documentation

◆ can_submit()

mod_h5pactivity\local\manager::can_submit ( stdClass $user = null)

Check if the user has permission to submit a particular h5pactivity for a specific user.

Parameters
stdClass | null$useruser record (default $USER)
Return values
boolif the user has permission to submit in this activity

◆ can_view_all_attempts()

mod_h5pactivity\local\manager::can_view_all_attempts ( stdClass $user = null)

Check if a user can see the activity attempts list.

Parameters
stdClass | null$useruser record (default $USER)
Return values
boolif the user can see the attempts link

◆ can_view_own_attempts()

mod_h5pactivity\local\manager::can_view_own_attempts ( stdClass $user = null)

Check if a user can see own attempts.

Parameters
stdClass | null$useruser record (default $USER)
Return values
boolif the user can see the own attempts link

◆ count_attempts()

mod_h5pactivity\local\manager::count_attempts ( int $userid = null)

Count the activity completed attempts.

If no user is provided the method will count all active users attempts. Check get_active_users_join PHPdoc to a more detailed description of "active users".

Parameters
int | null$useridoptional user id (default null)
Return values
intthe total amount of attempts

◆ count_users_attempts()

mod_h5pactivity\local\manager::count_users_attempts ( )

Return an array of all users and it's total attempts.

Note: this funciton only returns the list of users with attempts, it does not check all participants.

Return values
arrayindexed count userid => total number of attempts

◆ create_from_coursemodule()

static mod_h5pactivity\local\manager::create_from_coursemodule ( $coursemodule)
static

Create a manager instance from an course_modules record.

Parameters
stdClass | cm_info$coursemodulea h5pactivity record
Return values
manager

◆ create_from_instance()

static mod_h5pactivity\local\manager::create_from_instance ( stdClass $instance)
static

Create a manager instance from an instance record.

Parameters
stdClass$instancea h5pactivity record
Return values
manager

◆ get_active_users_join()

mod_h5pactivity\local\manager::get_active_users_join ( bool $allpotentialusers = false,
$currentgroup = false )

Return the join to collect all activity active users.

The concept of active user is relative to the activity permissions. All users with "mod/h5pactivity:view" are potential users but those with "mod/h5pactivity:reviewattempts" are evaluators and they don't count as valid submitters.

Note that, in general, the active list has the same effect as checking for "mod/h5pactivity:submit" but submit capability cannot be used because is a write capability and does not apply to frozen contexts.

Since
Moodle 3.11
Parameters
bool$allpotentialusersif true, the join will return all active users, not only the ones with attempts.
int | bool$currentgroupFalse if groups not used, 0 for all groups, group id (int) to filter by specific group
Return values
sql_jointhe active users attempts join

◆ get_attempt()

mod_h5pactivity\local\manager::get_attempt ( int $attemptid)

Return a single attempt.

Parameters
int$attemptidthe attempt id
Return values
attempt

◆ get_context()

mod_h5pactivity\local\manager::get_context ( )

Return the current context.

Return values
context_module

◆ get_coursemodule()

mod_h5pactivity\local\manager::get_coursemodule ( )

Return the current cm_info.

Return values
cm_infothe course module

◆ get_grader()

mod_h5pactivity\local\manager::get_grader ( )

Return the specific grader object for this activity.

Return values
grader

◆ get_grading_methods()

static mod_h5pactivity\local\manager::get_grading_methods ( )
static

Return the available grading methods.

Return values
string[]an array "option value" => "option description"

◆ get_instance()

mod_h5pactivity\local\manager::get_instance ( )

Return the current instance.

Return values
stdClassthe instance record

◆ get_report()

mod_h5pactivity\local\manager::get_report ( int $userid = null,
int $attemptid = null,
$currentgroup = false )

Return the suitable report to show the attempts.

This method controls the access to the different reports the activity have.

Parameters
int$useridan opional userid to show
int$attemptidan optional $attemptid to show
int | bool$currentgroupFalse if groups not used, 0 for all groups, group id (int) to filter by specific group
Return values
report|nullavailable report (or null if no report available)

◆ get_review_modes()

static mod_h5pactivity\local\manager::get_review_modes ( )
static

Return the available review modes.

Return values
string[]an array "option value" => "option description"

◆ get_selected_attempt()

mod_h5pactivity\local\manager::get_selected_attempt ( )

Return the selected attempt criteria.

Return values
string[]an array "grademethod value", "attempt description"

◆ get_user_attempts()

mod_h5pactivity\local\manager::get_user_attempts ( int $userid)

Return an array of all user attempts (including incompleted)

Parameters
int$useridthe user id
Return values
attempt[]

◆ get_users_scaled_score()

mod_h5pactivity\local\manager::get_users_scaled_score ( int $userid = 0)

Return a relation of userid and the valid attempt's scaled score.

The returned elements contain a record of userid, scaled value, attemptid and timemodified. In case the grading method is "GRADEAVERAGEATTEMPT" the attemptid will be zero. In case that tracking is disabled or grading method is "GRADEMANUAL" the method will return null.

Parameters
int$userida specific userid or 0 for all user attempts.
Return values
array|nullof userid, scaled value and, if exists, the attempt id

◆ is_tracking_enabled()

mod_h5pactivity\local\manager::is_tracking_enabled ( )

Check if tracking is enabled in a particular h5pactivity for a specific user.

Return values
boolif tracking is enabled in this activity

◆ set_module_viewed()

mod_h5pactivity\local\manager::set_module_viewed ( stdClass $course)

Trigger module viewed event and set the module viewed for completion.

Parameters
stdClass$coursecourse object
Return values
void

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