Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
qbank_previewquestion\question_preview_options Class Reference
Inheritance diagram for qbank_previewquestion\question_preview_options:
question_display_options

Public Member Functions

 __construct ($question)
 Constructor.
 
 add_question_identifier_to_label (string $label, bool $sridentifier=false, bool $addbefore=false)
 Helper to add the question identify (if there is one) to the label of an input field in a question.
 
 get_url_params ()
 Parameters needed in the URL when continuing this preview.
 
 has_question_identifier ()
 Whether a question number has been provided for the question that is being displayed.
 
 hide_all_feedback ()
 Set all the feedback-related fields, feedback, numpartscorrect, generalfeedback, rightanswer, manualcomment} and correctness to {.
 
 load_user_defaults ()
 Load the value of the options from the user_preferences table.
 
 save_user_preview_options ($newoptions)
 Save a change to the user's preview options to the database.
 
 set_from_request ()
 Set the value of any fields included in the request.
 

Static Public Member Functions

static get_dp_options ()
 Returns the valid choices for the number of decimal places for showing question marks.
 

Public Attributes

string $behaviour
 the behaviour to use for this preview.
 
boolean $clearwrong = false
 whether the question type should output hidden form fields to reset any incorrect parts of the resonse to blank.
 
context $context
 the context the attempt being output belongs to.
 
int $correctness = self::VISIBLE
 Should the student have what they got right and wrong clearly indicated.
 
array $editquestionparams = array()
 If not empty, then a link to edit the question will be included in the info box for the question.
 
string $extrahistorycontent = ''
 
string $extrainfocontent = ''
 
int $feedback = self::VISIBLE
 Should the specific feedback be visible.
 
int $flags = self::VISIBLE
 Should the flag this question UI element be visible, and if so, should the flag state be changeable?
 
int $generalfeedback = self::VISIBLE
 Should the general feedback be visible?
 
int $history = self::HIDDEN
 Should the history of previous question states table be visible? {.
 
int $manualcomment = self::VISIBLE
 Should the manually added marker's comment be visible.
 
string $manualcommentlink = null
 Should we show a 'Make comment or override grade' link? base URL for the edit comment script, which will be shown if $manualcomment = self\VISIBLE.
 
int $markdp = 2
 of decimal places to use when formatting marks for output.
 
int $marks = self::MARK_AND_MAX
 The the mark and/or the maximum available mark for this question be visible? {.
 
number $maxmark
 the maximum mark to use for this preview.
 
int $numpartscorrect = self::VISIBLE
 For questions with a number of sub-parts (like matching, or multiple-choice, multiple-reponse) display the number of sub-parts that were correct.
 
string $questionidentifier = null
 This identifier should be added to the labels of all input fields in the question.
 
moodle_url $questionreviewlink = null
 Used in places like the question history table, to show a link to review this question in a certain state.
 
boolean $readonly = false
 whether the question should be displayed as a read-only review, or in an active state where you can change the answer.
 
int $rightanswer = self::VISIBLE
 Should the automatically generated display of what the correct answer be visible?
 
int $userinfoinhistory = self::HIDDEN
 The option to show the action author in the response history.
 
int $variant
 the variant of the question to preview.
 
int const ALWAYS_LATEST = 0
 Special value for question version ID to indicate that we should always use the latest version.
 
const EDITABLE = 2
 
const HIDDEN = 0
 
const MARK_AND_MAX = 2
 
int const MAX_DP = 7
 #-
 
int const MAX_ONLY = 1
 #-
 
string const OPTIONPREFIX = 'question_preview_options_'
 prefix to append to field names to get user_preference names.
 
int const SHOW_ALL = -1
 #+ named constants for the values that most of the options take.
 
const VISIBLE = 1
 

Protected Member Functions

 get_field_types ()
 Names and param types of the options we read from the request.
 
 get_user_pref_fields ()
 Names of the options we store in the user preferences table.
 

Constructor & Destructor Documentation

◆ __construct()

qbank_previewquestion\question_preview_options::__construct ( $question)

Constructor.

Parameters
stdClass$question

Member Function Documentation

◆ add_question_identifier_to_label()

question_display_options::add_question_identifier_to_label ( string $label,
bool $sridentifier = false,
bool $addbefore = false )
inherited

Helper to add the question identify (if there is one) to the label of an input field in a question.

Parameters
string$labelThe plain field label. E.g. 'Answer 1'
bool$sridentifierIf true, the question identifier, if added, will be wrapped in a sr-only span. Default false.
bool$addbeforeIf true, the question identifier will be added before the label.
Return values
stringThe amended label. For example 'Answer 1, Question 1'.

◆ get_dp_options()

static question_display_options::get_dp_options ( )
staticinherited

Returns the valid choices for the number of decimal places for showing question marks.

For use in the user interface.

Calling code should probably use {

See also
question_engine\get_dp_options()} rather than calling this method directly.
Return values
arraysuitable for passing to {
See also
html_writer\select()} or similar.

◆ get_field_types()

qbank_previewquestion\question_preview_options::get_field_types ( )
protected

Names and param types of the options we read from the request.

Return values
array

◆ get_url_params()

qbank_previewquestion\question_preview_options::get_url_params ( )

Parameters needed in the URL when continuing this preview.

Return values
arrayURL fragment.

◆ get_user_pref_fields()

qbank_previewquestion\question_preview_options::get_user_pref_fields ( )
protected

Names of the options we store in the user preferences table.

Return values
array

◆ has_question_identifier()

question_display_options::has_question_identifier ( )
inherited

Whether a question number has been provided for the question that is being displayed.

Return values
bool

◆ hide_all_feedback()

question_display_options::hide_all_feedback ( )
inherited

Set all the feedback-related fields, feedback, numpartscorrect, generalfeedback, rightanswer, manualcomment} and correctness to {.

See also
question_display_options\HIDDEN}.

◆ save_user_preview_options()

qbank_previewquestion\question_preview_options::save_user_preview_options ( $newoptions)

Save a change to the user's preview options to the database.

Parameters
object$newoptions

Member Data Documentation

◆ $correctness

int question_display_options::$correctness = self::VISIBLE
inherited

Should the student have what they got right and wrong clearly indicated.

This includes the green/red hilighting of the bits of their response, whether the one-line summary of the current state of the question says correct/incorrect or just answered. {

See also
question_display_options\HIDDEN} or {
question_display_options\VISIBLE}

◆ $editquestionparams

array question_display_options::$editquestionparams = array()
inherited

If not empty, then a link to edit the question will be included in the info box for the question.

If used, this array must contain an element courseid or cmid.

It shoudl also contain a parameter returnurl => moodle_url giving a sensible URL to go back to when the editing form is submitted or cancelled.

url parameter for the edit link. id => questiosnid will be added automatically.

◆ $extrahistorycontent

string question_display_options::$extrahistorycontent = ''
inherited
Since
2.9 extra HTML to include in the history box of the question display, if it is shown.

◆ $extrainfocontent

string question_display_options::$extrainfocontent = ''
inherited
Since
2.9 extra HTML to include at the end of the outcome (feedback) box of the question display.

This field is now badly named. The place it included is was changed (for the better) but the name was left unchanged for backwards compatibility.

◆ $feedback

int question_display_options::$feedback = self::VISIBLE
inherited

Should the specific feedback be visible.

Specific feedback is typically the part of the feedback that changes based on the answer that the student gave. For example the feedback shown if a particular choice has been chosen in a multi-choice question. It also includes the combined feedback that a lost of question types have (e.g. feedback for any correct/incorrect response.)

{

See also
question_display_options\HIDDEN} or {
question_display_options\VISIBLE}

◆ $flags

int question_display_options::$flags = self::VISIBLE
inherited

Should the flag this question UI element be visible, and if so, should the flag state be changeable?

{

See also
question_display_options\HIDDEN}, {
question_display_options\VISIBLE} or {
question_display_options\EDITABLE}

◆ $generalfeedback

int question_display_options::$generalfeedback = self::VISIBLE
inherited

Should the general feedback be visible?

This is typically feedback shown to all students after the question is finished, irrespective of which answer they gave.

{

See also
question_display_options\HIDDEN} or {
question_display_options\VISIBLE}

◆ $history

int question_display_options::$history = self::HIDDEN
inherited

Should the history of previous question states table be visible? {.

See also
question_display_options\HIDDEN} or {
question_display_options\VISIBLE}

◆ $manualcomment

int question_display_options::$manualcomment = self::VISIBLE
inherited

Should the manually added marker's comment be visible.

Should the link for adding/editing the comment be there. {

See also
question_display_options\HIDDEN}, {
question_display_options\VISIBLE}, or {
question_display_options\EDITABLE}. Editable means that form fields are displayed inline.

◆ $marks

int question_display_options::$marks = self::MARK_AND_MAX
inherited

The the mark and/or the maximum available mark for this question be visible? {.

See also
question_display_options\HIDDEN}, {
question_display_options\MAX_ONLY} or {
question_display_options\MARK_AND_MAX}

◆ $numpartscorrect

int question_display_options::$numpartscorrect = self::VISIBLE
inherited

For questions with a number of sub-parts (like matching, or multiple-choice, multiple-reponse) display the number of sub-parts that were correct.

{

See also
question_display_options\HIDDEN} or {
question_display_options\VISIBLE}

◆ $questionidentifier

string question_display_options::$questionidentifier = null
inherited

This identifier should be added to the labels of all input fields in the question.

This is so people using assistive technology can easily tell which input belong to which question. The helper {

See also
self\add_question_identifier_to_label() makes this easier.

If not set before the question is rendered, then it defaults to 'Question N'. (lang string)

The identifier that the question being rendered is associated with. E.g. The question number when it is rendered on a quiz.

◆ $questionreviewlink

moodle_url question_display_options::$questionreviewlink = null
inherited

Used in places like the question history table, to show a link to review this question in a certain state.

If blank, a link is not shown. base URL for a review question script.

◆ $rightanswer

int question_display_options::$rightanswer = self::VISIBLE
inherited

Should the automatically generated display of what the correct answer be visible?

{

See also
question_display_options\HIDDEN} or {
question_display_options\VISIBLE}

◆ MAX_DP

int const question_display_options::MAX_DP = 7
inherited

#-

maximum value for the {

See also
$markpd} option. This is effectively set by the database structure, which uses NUMBER(12,7) columns for question marks/fractions.

◆ MAX_ONLY

int const question_display_options::MAX_ONLY = 1
inherited

#-

#+ named constants for the {

See also
$marks} option.

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