Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | List of all members
mod_h5pactivity\local\attempt Class Reference

Class attempt for H5P activity. More...

Public Member Functions

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

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. More...
 
static delete_attempt (attempt $attempt)
 Delete a specific attempt. More...
 
static last_attempt (stdClass $user, stdClass $cm)
 Get the last user attempt in a specific H5P activity. More...
 
static new_attempt (stdClass $user, stdClass $cm)
 Create a new user attempt in a specific H5P activity. More...
 

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: