Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

Library functions used by question/preview.php.

Copyright: 2010 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 328 lines (12 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 0 files

Defines 2 classes

preview_options_form:: (1 method):
  definition()

question_preview_options:: (11 methods):
  __construct()
  get_user_pref_fields()
  get_field_types()
  load_user_defaults()
  save_user_preview_options()
  set_from_request()
  get_url_params()
  question_preview_question_pluginfile()
  question_preview_action_url()
  question_preview_form_url()
  restart_preview()


Class: preview_options_form  - X-Ref

Settings form for the preview options.

definition()   X-Ref
No description

Class: question_preview_options  - X-Ref

Displays question preview options as default and set the options
Setting default, getting and setting user preferences in question preview options.

__construct($question)   X-Ref
Constructor.


get_user_pref_fields()   X-Ref

return: array names of the options we store in the user preferences table.

get_field_types()   X-Ref

return: array names and param types of the options we read from the request.

load_user_defaults()   X-Ref
Load the value of the options from the user_preferences table.


save_user_preview_options($newoptions)   X-Ref
Save a change to the user's preview options to the database.

param: object $newoptions

set_from_request()   X-Ref
Set the value of any fields included in the request.


get_url_params()   X-Ref

return: string URL fragment. Parameters needed in the URL when continuing

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 $options additional options affecting the file serving
return: bool false if file not found, does not return if found - justsend the file

question_preview_action_url($questionid, $qubaid,question_preview_options $options, $context)   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.

question_preview_form_url($questionid, $context, $previewid = 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.

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

param: int $previewid
param: int $questionid
param: object $displayoptions
param: object $context