Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

(no description)

File Size: 339 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: helper  - X-Ref

Class helper contains all the helper functions.

question_preview_question_pluginfile($course, $context, $component,$filearea, $qubaid, $slot, $args, $forcedownload, $fileoptions)   X-Ref
Called via pluginfile.php -> question_pluginfile to serve files belonging to
a question in a question_attempt when that attempt is a preview.

param: stdClass $course course settings object
param: stdClass $context context object
param: string $component the name of the component we are serving files for.
param: string $filearea the name of the file area.
param: int $qubaid the question_usage this image belongs to.
param: int $slot the relevant slot within the usage.
param: array $args the remaining bits of the file path.
param: bool $forcedownload whether the user must be forced to download the file.
param: array $fileoptions options for the stored files
return: void false if file not found, does not return if found - justsend the file

question_preview_action_url($questionid, $qubaid,question_preview_options $options, $context, $returnurl = null, $restartversion = null)   X-Ref
The the URL to use for actions relating to this preview.

param: int $questionid the question being previewed
param: int $qubaid the id of the question usage for this preview
param: question_preview_options $options the options in use
param: context $context context for the question preview
param: moodle_url $returnurl url of the page to return to
param: int|null $restartversion version of the question to use when next restarting the preview.
return: moodle_url

question_preview_form_url($questionid, $context, $previewid = null, $returnurl = null)   X-Ref
The the URL to use for actions relating to this preview.

param: int $questionid the question being previewed
param: context $context the current moodle context
param: int $previewid optional previewid to sign post saved previewed answers
param: moodle_url $returnurl url of the page to return to
return: moodle_url

restart_preview($previewid, $questionid, $displayoptions, $context,$returnurl = null, $restartversion = null)   X-Ref
Delete the current preview, if any, and redirect to start a new preview.

param: int $previewid id of the preview while restarting it
param: int $questionid id of the question in preview
param: object $displayoptions display options for the question in preview
param: object $context context of the question for preview
param: moodle_url $returnurl url of the page to return to
param: int|null $restartversion version of the question to use when next restarting the preview.
return: void

question_preview_url($questionid, $preferredbehaviour = null,$maxmark = null, $displayoptions = null, $variant = null, $context = null, $returnurl = null,$restartversion = null)   X-Ref
Generate the URL for starting a new preview of a given question with the given options.

param: integer $questionid the question to preview
param: string $preferredbehaviour the behaviour to use for the preview
param: float $maxmark the maximum to mark the question out of
param: question_display_options $displayoptions the display options to use
param: int $variant the variant of the question to preview. If null, one will
param: object $context context to run the preview in (affects things like
param: moodle_url $returnurl url of the page to return to
param: int $restartversion The version of the question to use when restarting the preview.
return: moodle_url the URL

question_preview_popup_params()   X-Ref
Popup params for the question preview.

return: array that can be passed as $params to the {@see popup_action} constructor.

get_preview_extra_elements(question_definition $question, int $courseid)   X-Ref
Get the extra elements for preview from qbank plugins.

param: question_definition $question question definition object
param: int $courseid id of the course
return: array

is_latest(string $version, string $questionbankentryid)   X-Ref
Checks if question is the latest version.

param: string $version Question version to check
param: string $questionbankentryid Entry to check against
return: bool

load_versions(string $questionbankentryid)   X-Ref
Loads question version ids for current question.

param: string $questionbankentryid Question bank entry id
return: array  $questionids Array containing question id as key and version as value.

get_restart_id(array $versions, int $restartversion)   X-Ref
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.

param: array $versions
param: int $restartversion
return: ?int