Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
qbank_previewquestion\helper Class Reference

Static Public Member Functions

static get_preview_extra_elements (question_definition $question, int $courseid)
 Get the extra elements for preview from qbank plugins.
 
static get_restart_id (array $versions, int $restartversion)
 Return the question ID from the array of id => version that corresponds to the requested version.
 
static is_latest (string $version, string $questionbankentryid)
 Checks if question is the latest version.
 
static load_versions (string $questionbankentryid)
 Loads question version ids for current question.
 
static question_preview_action_url ($questionid, $qubaid, question_preview_options $options, $context, $returnurl=null, $restartversion=null)
 The the URL to use for actions relating to this preview.
 
static question_preview_form_url ($questionid, $context, $previewid=null, $returnurl=null)
 The the URL to use for actions relating to this preview.
 
static question_preview_popup_params ()
 Popup params for the question preview.
 
static question_preview_question_pluginfile ($course, $context, $component, $filearea, $qubaid, $slot, $args, $forcedownload, $fileoptions)
 Called via pluginfile.php -> question_pluginfile to serve files belonging to a question in a question_attempt when that attempt is a preview.
 
static question_preview_url ($questionid, $preferredbehaviour=null, $maxmark=null, $displayoptions=null, $variant=null, $context=null, $returnurl=null, $restartversion=null)
 Generate the URL for starting a new preview of a given question with the given options.
 
static restart_preview ($previewid, $questionid, $displayoptions, $context, $returnurl=null, $restartversion=null)
 Delete the current preview, if any, and redirect to start a new preview.
 

Member Function Documentation

◆ get_preview_extra_elements()

static qbank_previewquestion\helper::get_preview_extra_elements ( question_definition $question,
int $courseid )
static

Get the extra elements for preview from qbank plugins.

Parameters
question_definition$questionquestion definition object
int$courseidid of the course
Return values
array

◆ get_restart_id()

static qbank_previewquestion\helper::get_restart_id ( array $versions,
int $restartversion )
static

Return the question ID from the array of id => version that corresponds to the requested version.

If the requested version is question_preview_options\ALWAYS_LATEST, this will return the latest version.

Parameters
array$versions
int$restartversion
Return values
?int

◆ is_latest()

static qbank_previewquestion\helper::is_latest ( string $version,
string $questionbankentryid )
static

Checks if question is the latest version.

Parameters
string$versionQuestion version to check
string$questionbankentryidEntry to check against
Return values
bool

◆ load_versions()

static qbank_previewquestion\helper::load_versions ( string $questionbankentryid)
static

Loads question version ids for current question.

Parameters
string$questionbankentryidQuestion bank entry id
Return values
array\$questionidsArray containing question id as key and version as value.

◆ question_preview_action_url()

static qbank_previewquestion\helper::question_preview_action_url ( $questionid,
$qubaid,
question_preview_options $options,
$context,
$returnurl = null,
$restartversion = null )
static

The the URL to use for actions relating to this preview.

Parameters
int$questionidthe question being previewed
int$qubaidthe id of the question usage for this preview
question_preview_options$optionsthe options in use
context$contextcontext for the question preview
moodle_url$returnurlurl of the page to return to
int | null$restartversionversion of the question to use when next restarting the preview.
Return values
moodle_url

◆ question_preview_form_url()

static qbank_previewquestion\helper::question_preview_form_url ( $questionid,
$context,
$previewid = null,
$returnurl = null )
static

The the URL to use for actions relating to this preview.

Parameters
int$questionidthe question being previewed
context$contextthe current moodle context
int$previewidoptional previewid to sign post saved previewed answers
moodle_url$returnurlurl of the page to return to
Return values
moodle_url

◆ question_preview_popup_params()

static qbank_previewquestion\helper::question_preview_popup_params ( )
static

Popup params for the question preview.

Return values
arraythat can be passed as $params to the {
See also
popup_action} constructor.

◆ question_preview_question_pluginfile()

static qbank_previewquestion\helper::question_preview_question_pluginfile ( $course,
$context,
$component,
$filearea,
$qubaid,
$slot,
$args,
$forcedownload,
$fileoptions )
static

Called via pluginfile.php -> question_pluginfile to serve files belonging to a question in a question_attempt when that attempt is a preview.

Parameters
stdClass$coursecourse settings object
stdClass$contextcontext object
string$componentthe name of the component we are serving files for.
string$fileareathe name of the file area.
int$qubaidthe question_usage this image belongs to.
int$slotthe relevant slot within the usage.
array$argsthe remaining bits of the file path.
bool$forcedownloadwhether the user must be forced to download the file.
array$fileoptionsoptions for the stored files
Return values
voidfalse if file not found, does not return if found - justsend the file

◆ question_preview_url()

static qbank_previewquestion\helper::question_preview_url ( $questionid,
$preferredbehaviour = null,
$maxmark = null,
$displayoptions = null,
$variant = null,
$context = null,
$returnurl = null,
$restartversion = null )
static

Generate the URL for starting a new preview of a given question with the given options.

Parameters
integer$questionidthe question to preview
string$preferredbehaviourthe behaviour to use for the preview
float$maxmarkthe maximum to mark the question out of
question_display_options$displayoptionsthe display options to use
int$variantthe variant of the question to preview. If null, one will be picked randomly
object$contextcontext to run the preview in (affects things like filter settings, theme, lang, etc.) Defaults to $PAGE->context
moodle_url$returnurlurl of the page to return to
int$restartversionThe version of the question to use when restarting the preview.
Return values
moodle_urlthe URL

◆ restart_preview()

static qbank_previewquestion\helper::restart_preview ( $previewid,
$questionid,
$displayoptions,
$context,
$returnurl = null,
$restartversion = null )
static

Delete the current preview, if any, and redirect to start a new preview.

Parameters
int$previewidid of the preview while restarting it
int$questionidid of the question in preview
object$displayoptionsdisplay options for the question in preview
object$contextcontext of the question for preview
moodle_url$returnurlurl of the page to return to
int | null$restartversionversion of the question to use when next restarting the preview.
Return values
void

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