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

Class attempt for H5P activity. More...

Public Member Functions

 __construct (stdClass $record)
 Create a new attempt object.
 
 count_results ()
 Return de number of results stored in this attempt.
 
 delete_results ()
 Delete the current attempt results from the DB.
 
 get_attempt ()
 Return the attempt number.
 
 get_completion ()
 Return the attempt completion.
 
 get_duration ()
 Return the attempt duration.
 
 get_h5pactivityid ()
 Return the attempt H5P activity ID.
 
 get_id ()
 Return the attempt ID.
 
 get_maxscore ()
 Return the attempt maxscore.
 
 get_rawscore ()
 Return the attempt rawscore.
 
 get_results ()
 Return all results stored in this attempt.
 
 get_scaled ()
 Return the attempt scaled.
 
 get_scoreupdated ()
 Return if the attempt has been modified.
 
 get_success ()
 Return the attempt success.
 
 get_timecreated ()
 Return the attempt H5P timecreated.
 
 get_timemodified ()
 Return the attempt H5P timemodified.
 
 get_userid ()
 Return the attempt user ID.
 
 save ()
 Update the current attempt record into DB.
 
 save_statement (statement $statement, string $subcontent='')
 Save a new result statement into the attempt.
 
 set_completion (?int $completion)
 Set the attempt completion.
 
 set_duration (?int $duration)
 Set the attempt duration.
 
 set_score (?int $rawscore, ?int $maxscore)
 Set the attempt score.
 
 set_success (?int $success)
 Set the attempt success.
 

Static Public Member Functions

static delete_all_attempts (stdClass $cm, stdClass $user=null)
 Wipe all attempt data for specific course_module and an optional user.
 
static delete_attempt (attempt $attempt)
 Delete a specific attempt.
 
static last_attempt (stdClass $user, stdClass $cm)
 Get the last user attempt in a specific H5P activity.
 
static new_attempt (stdClass $user, stdClass $cm)
 Create a new user attempt in a specific H5P activity.
 

Detailed Description

Class attempt 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\attempt::__construct ( stdClass $record)

Create a new attempt object.

Parameters
stdClass$recordthe h5pactivity_attempts record

Member Function Documentation

◆ count_results()

mod_h5pactivity\local\attempt::count_results ( )

Return de number of results stored in this attempt.

Return values
intthe number of results stored in this attempt.

◆ delete_all_attempts()

static mod_h5pactivity\local\attempt::delete_all_attempts ( stdClass $cm,
stdClass $user = null )
static

Wipe all attempt data for specific course_module and an optional user.

Parameters
stdClass$cma course_module record
stdClass$usera user record

◆ delete_attempt()

static mod_h5pactivity\local\attempt::delete_attempt ( attempt $attempt)
static

Delete a specific attempt.

Parameters
attempt$attemptthe attempt object to delete

◆ get_attempt()

mod_h5pactivity\local\attempt::get_attempt ( )

Return the attempt number.

Return values
intthe attempt number

◆ get_completion()

mod_h5pactivity\local\attempt::get_completion ( )

Return the attempt completion.

Return values
int|nullthe completion value

◆ get_duration()

mod_h5pactivity\local\attempt::get_duration ( )

Return the attempt duration.

Return values
int|nullthe duration value

◆ get_h5pactivityid()

mod_h5pactivity\local\attempt::get_h5pactivityid ( )

Return the attempt H5P activity ID.

Return values
intthe attempt userid

◆ get_id()

mod_h5pactivity\local\attempt::get_id ( )

Return the attempt ID.

Return values
intthe attempt id

◆ get_maxscore()

mod_h5pactivity\local\attempt::get_maxscore ( )

Return the attempt maxscore.

Return values
intthe maxscore value

◆ get_rawscore()

mod_h5pactivity\local\attempt::get_rawscore ( )

Return the attempt rawscore.

Return values
intthe rawscore value

◆ get_results()

mod_h5pactivity\local\attempt::get_results ( )

Return all results stored in this attempt.

Return values
stdClass[]results records.

◆ get_scaled()

mod_h5pactivity\local\attempt::get_scaled ( )

Return the attempt scaled.

Return values
int|nullthe scaled value

◆ get_scoreupdated()

mod_h5pactivity\local\attempt::get_scoreupdated ( )

Return if the attempt has been modified.

Note: adding a result only add track information unless the statement does not specify subcontent. In this case this will update also the statement.

Return values
boolif the attempt score have been modified

◆ get_success()

mod_h5pactivity\local\attempt::get_success ( )

Return the attempt success.

Return values
int|nullthe success value

◆ get_timecreated()

mod_h5pactivity\local\attempt::get_timecreated ( )

Return the attempt H5P timecreated.

Return values
intthe attempt timecreated

◆ get_timemodified()

mod_h5pactivity\local\attempt::get_timemodified ( )

Return the attempt H5P timemodified.

Return values
intthe attempt timemodified

◆ get_userid()

mod_h5pactivity\local\attempt::get_userid ( )

Return the attempt user ID.

Return values
intthe attempt userid

◆ last_attempt()

static mod_h5pactivity\local\attempt::last_attempt ( stdClass $user,
stdClass $cm )
static

Get the last user attempt in a specific H5P activity.

If no previous attempt exists, it generates a new one.

Parameters
stdClass$usera user record
stdClass$cma course_module record
Return values
attempt|nulla new attempt object or null if some problem accured

◆ new_attempt()

static mod_h5pactivity\local\attempt::new_attempt ( stdClass $user,
stdClass $cm )
static

Create a new user attempt in a specific H5P activity.

Parameters
stdClass$usera user record
stdClass$cma course_module record
Return values
attempt|nulla new attempt object or null if fail

◆ save()

mod_h5pactivity\local\attempt::save ( )

Update the current attempt record into DB.

Return values
booltrue if update is succesful

◆ save_statement()

mod_h5pactivity\local\attempt::save_statement ( statement $statement,
string $subcontent = '' )

Save a new result statement into the attempt.

It also updates the rawscore and maxscore if necessary.

Parameters
statement$statementthe xAPI statement object
string$subcontent= '' optional subcontent identifier
Return values
boolif it can save the statement into db

◆ set_completion()

mod_h5pactivity\local\attempt::set_completion ( ?int $completion)

Set the attempt completion.

Parameters
int | null$completionthe attempt completion

◆ set_duration()

mod_h5pactivity\local\attempt::set_duration ( ?int $duration)

Set the attempt duration.

Parameters
int | null$durationthe attempt duration

◆ set_score()

mod_h5pactivity\local\attempt::set_score ( ?int $rawscore,
?int $maxscore )

Set the attempt score.

Parameters
int | null$rawscorethe attempt rawscore
int | null$maxscorethe attempt maxscore

◆ set_success()

mod_h5pactivity\local\attempt::set_success ( ?int $success)

Set the attempt success.

Parameters
int | null$successthe attempt success

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