Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
question_flags Class Reference

Contains the logic for handling question flags. More...

Static Public Member Functions

static get_postdata (question_attempt $qa)
 Get the postdata that needs to be sent to question/toggleflag.php to change the flag state.
 
static initialise_js ()
 
static update_flag ($qubaid, $questionid, $qaid, $slot, $checksum, $newstate)
 If the request seems valid, update the flag state of a question attempt.
 

Static Protected Member Functions

static get_toggle_checksum ($qubaid, $questionid, $qaid, $slot, $user=null)
 Get the checksum that validates that a toggle request is valid.
 

Detailed Description

Contains the logic for handling question flags.

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

Member Function Documentation

◆ get_postdata()

static question_flags::get_postdata ( question_attempt $qa)
static

Get the postdata that needs to be sent to question/toggleflag.php to change the flag state.

You need to append &newstate=0/1 to this.

Return values
thepost data to send.

◆ get_toggle_checksum()

static question_flags::get_toggle_checksum ( $qubaid,
$questionid,
$qaid,
$slot,
$user = null )
staticprotected

Get the checksum that validates that a toggle request is valid.

Parameters
int$qubaidthe question usage id.
int$questionidthe question id.
int$sessionidthe question_attempt id.
object$userthe user. If null, defaults to $USER.
Return values
stringthat needs to be sent to question/toggleflag.php for it to work.

◆ update_flag()

static question_flags::update_flag ( $qubaid,
$questionid,
$qaid,
$slot,
$checksum,
$newstate )
static

If the request seems valid, update the flag state of a question attempt.

Throws exceptions if this is not a valid update request.

Parameters
int$qubaidthe question usage id.
int$questionidthe question id.
int$sessionidthe question_attempt id.
string$checksumchecksum, as computed by get_toggle_checksum() corresponding to the last three arguments.
bool$newstatethe new state of the flag. true = flagged.

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