Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
qtype_gapselect_edit_form_base Class Reference

Elements embedded in question text editing form definition. More...

Inheritance diagram for qtype_gapselect_edit_form_base:
question_edit_form question_wizard_form moodleform qtype_ddwtos_edit_form qtype_gapselect_edit_form

Public Member Functions

 _process_submission ($method)
 Internal method. More...
 
 _validate_files (&$files)
 Internal method. More...
 
 add_action_buttons ($cancel=true, $submitlabel=null)
 Use this method to a cancel and submit button to the end of your form. More...
 
 add_checkbox_controller ($groupid, $text=null, $attributes=null, $originalValue=0)
 Adds a link/button that controls the checked state of a group of checkboxes. More...
 
 data_preprocessing ($question)
 Perform an preprocessing needed on the data passed to set_data() before it is used to initialise the form. More...
 
 definition_after_data ()
 Dummy stub method - override if you need to setup the form depending on current values. More...
 
 display ()
 Print html form.
 
 focus ($name=NULL)
 To autofocus on first form element or first element with error. More...
 
 get_data ()
 Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data. More...
 
 get_file_content ($elname)
 Get content of uploaded file. More...
 
 get_maximum_choice_group_number ()
 Return how many different groups of choices there should be. More...
 
 get_new_filename ($elname=null)
 Returns name of uploaded file. More...
 
 get_submitted_data ()
 Return submitted data without validation or NULL if there is no submitted data. More...
 
 init_javascript_enhancement ($element, $enhancement, array $options=array(), array $strings=null)
 Adds an initialisation call for a standard JavaScript enhancement. More...
 
 is_cancelled ()
 Return true if a cancel button has been pressed resulting in the form being submitted. More...
 
 is_submitted ()
 Check that form was submitted. More...
 
 is_validated ()
 Check that form data is valid. More...
 
 moodleform ($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true)
 Old syntax of class constructor. More...
 
 no_submit_button_pressed ()
 Checks if button pressed is not for submitting the form. More...
 
 optional_param ($name, $default, $type)
 Checks if a parameter was passed in the previous form submission. More...
 
 qtype ()
 Override this in the subclass to question type name. More...
 
 render ()
 Renders the html form (same as display, but returns the result). More...
 
 repeat_elements ($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=null, $addbuttoninside=false)
 Method to add a repeating group of elements to a form. More...
 
 repeat_elements_fix_clone ($i, $elementclone, &$namecloned)
 Helper used by repeat_elements(). More...
 
 save_file ($elname, $pathname, $override=false)
 Save file to standard filesystem. More...
 
 save_files ($destination)
 Save verified uploaded files into directory. More...
 
 save_stored_file ($elname, $newcontextid, $newcomponent, $newfilearea, $newitemid, $newfilepath='/', $newfilename=null, $overwrite=false, $newuserid=null)
 Save file to local filesystem pool. More...
 
 save_temp_file ($elname)
 Returns a temporary file, do not forget to delete after not needed any more. More...
 
 set_data ($question)
 Load in existing data as form defaults. More...
 
 set_display_vertical ()
 Set display mode for the form when labels take full width of the form and above the elements even on big screens. More...
 
 set_initial_dirty_state ($state=false)
 Set the initial 'dirty' state of the form. More...
 
 validate_defined_fields ($validateonnosubmit=false)
 Validate the form. More...
 
 validation ($data, $files)
 Dummy stub method - override if you needed to perform some extra validation. More...
 

Static Public Member Functions

static get_js_module ()
 Returns a JS module definition for the mforms JS. More...
 
static mock_generate_submit_keys ($data=[])
 Used by tests to generate valid submit keys for moodle forms that are submitted with ajax data. More...
 
static mock_submit ($simulatedsubmitteddata, $simulatedsubmittedfiles=array(), $method='post', $formidentifier=null)
 Used by tests to simulate submitted form data submission from the user. More...
 

Public Attributes

object $context
 current context
 
array $editoroptions
 html editor options
 
array $fileoptions
 options to preapre draft area
 
object $instance
 instance of question type
 
const DEFAULT_NUM_HINTS = 2
 

Protected Member Functions

 _get_post_params ()
 Internal method - should not be used anywhere. More...
 
 add_combined_feedback_fields ($withshownumpartscorrect=false)
 
 add_hidden_fields ()
 Add all the hidden form fields used by question/question.php.
 
 add_interactive_settings ($withclearwrong=false, $withshownumpartscorrect=false)
 
 add_per_answer_fields (&$mform, $label, $gradeoptions, $minoptions=QUESTION_NUMANS_START, $addoptions=QUESTION_NUMANS_ADD)
 Add a set of form fields, obtained from get_per_answer_fields, to the form, one for each existing answer, with some blanks for some new ones. More...
 
 add_tag_fields ($mform)
 Add the tag and course tag fields to the mform. More...
 
 after_definition ()
 After definition hook. More...
 
 can_preview ()
 Is the question being edited in a state where it can be previewed? More...
 
 choice_group ($mform)
 Creates an array with elements for a choice group. More...
 
 data_preprocessing_answers ($question, $withanswerfiles=false)
 Perform the necessary preprocessing for the fields added by add_per_answer_fields(). More...
 
 data_preprocessing_choice ($question, $answer, $key)
 
 data_preprocessing_combined_feedback ($question, $withshownumcorrect=false)
 Perform the necessary preprocessing for the fields added by add_combined_feedback_fields(). More...
 
 data_preprocessing_extra_answer_field ($answer, $field)
 Perfmorm preprocessing for particular extra answer field. More...
 
 data_preprocessing_extra_answer_fields ($question, $extraanswerfields)
 Perform the necessary preprocessing for the extra answer fields. More...
 
 data_preprocessing_hints ($question, $withclearwrong=false, $withshownumpartscorrect=false)
 Perform the necessary preprocessing for the hint fields. More...
 
 definition ()
 Build the form definition. More...
 
 definition_answer_choice (&$mform)
 Defines form elements for answer choices. More...
 
 definition_inner ($mform)
 definition_inner adds all specific fields to the form. More...
 
 get_draft_files ($elname)
 Get draft files of a form element This is a protected method which will be used only inside moodleforms. More...
 
 get_form_identifier ()
 It should returns unique identifier for the form. More...
 
 get_hint_fields ($withclearwrong=false, $withshownumpartscorrect=false)
 Create the form elements required by one hint. More...
 
 get_illegal_tag_error ($text)
 Vaidate some input to make sure it does not contain any tags other than $this->allowedhtmltags. More...
 
 get_more_choices_string ()
 Language string to use for 'Add {no} more {whatever we call answers}'.
 
 get_non_collabsible_editor_options ()
 Returns an array of editor options with collapsed options turned off. More...
 
 get_per_answer_fields ($mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption)
 Get the list of form elements to repeat, one for each answer. More...
 
 repeated_options ()
 Returns an array for form repeat options. More...
 
 validate_draft_files ()
 Internal method. More...
 

Protected Attributes

array $_ajaxformdata
 submitted form data when using mforms with ajax
 
array $_customdata
 globals workaround
 
object $_definition_finalized = false
 definition_after_data executed flag
 
MoodleQuickForm $_form
 quickform object definition
 
string $_formname
 name of the form
 
bool null $_validated = null
 stores the validation result of this form or null if not yet validated
 
array $allowedhtmltags
 of HTML tags allowed in choices / drag boxes. More...
 
 $category
 
 $categorycontext
 
 $contexts
 
object $question
 Question object with options and answers already loaded by get_question_options Be careful how you use this it is needed sometimes to set up the structure of the form in definition_inner but data is always loaded into the form with set_data.
 

Detailed Description

Elements embedded in question text editing form definition.

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

Member Function Documentation

◆ _get_post_params()

moodleform::_get_post_params ( )
protectedinherited

Internal method - should not be used anywhere.

Deprecated:
since 2.6
Return values
array::$_POST,.

◆ _process_submission()

moodleform::_process_submission (   $method)
inherited

Internal method.

Alters submitted data to be suitable for quickforms processing. Must be called when the form is fully set up.

Parameters
string$methodname of the method which alters submitted data

◆ _validate_files()

moodleform::_validate_files ( $files)
inherited

Internal method.

Validates all old-style deprecated uploaded files. The new way is to upload files via repository api.

Parameters
array$fileslist of files to be validated
Return values
bool|arraySuccess or an array of errors

◆ add_action_buttons()

moodleform::add_action_buttons (   $cancel = true,
  $submitlabel = null 
)
inherited

Use this method to a cancel and submit button to the end of your form.

Pass a param of false if you don't want a cancel button in your form. If you have a cancel button make sure you check for it being pressed using is_cancelled() and redirecting if it is true before trying to get data with get_data().

Parameters
bool$cancelwhether to show cancel button, default true
string$submitlabellabel for submit button, defaults to get_string('savechanges')

Reimplemented in tool_uploadcourse_step2_form.

◆ add_checkbox_controller()

moodleform::add_checkbox_controller (   $groupid,
  $text = null,
  $attributes = null,
  $originalValue = 0 
)
inherited

Adds a link/button that controls the checked state of a group of checkboxes.

Parameters
int$groupidThe id of the group of advcheckboxes this element controls
string$textThe text of the link. Defaults to selectallornone ("select all/none")
array$attributesassociative array of HTML attributes
int$originalValueThe original general state of the checkboxes before the user first clicks this element

◆ add_per_answer_fields()

question_edit_form::add_per_answer_fields ( $mform,
  $label,
  $gradeoptions,
  $minoptions = QUESTION_NUMANS_START,
  $addoptions = QUESTION_NUMANS_ADD 
)
protectedinherited

Add a set of form fields, obtained from get_per_answer_fields, to the form, one for each existing answer, with some blanks for some new ones.

Parameters
object$mformthe form being built.
$labelthe label to use for each option.
$gradeoptionsthe possible grades for each answer.
$minoptionsthe minimum number of answer blanks to display. Default QUESTION_NUMANS_START.
$addoptionsthe number of answer blanks to add. Default QUESTION_NUMANS_ADD.

◆ add_tag_fields()

question_edit_form::add_tag_fields (   $mform)
protectedinherited

Add the tag and course tag fields to the mform.

If the form is being built in a course context then add the field for course tags.

If the question category doesn't belong to a course context or we aren't editing in a course context then add the tags element to allow tags to be added to the question category context.

Parameters
object$mformThe form being built

◆ after_definition()

moodleform::after_definition ( )
protectedinherited

After definition hook.

This is useful for intermediate classes to inject logic after the definition was provided without requiring developers to call the parent self::definition() as it's not obvious by design. The 'intermediate' class is 'MyClass extends IntermediateClass extends moodleform'.

Classes overriding this method should always call the parent. We may not add anything specifically in this instance of the method, but intermediate classes are likely to do so, and so it is a good practice to always call the parent.

Return values
void

Reimplemented in core\form\persistent.

◆ can_preview()

question_edit_form::can_preview ( )
protectedinherited

Is the question being edited in a state where it can be previewed?

Return values
boolwhether to show the preview link.

Reimplemented in qtype_calculatedsimple_edit_form, qtype_calculatedmulti_edit_form, and qtype_calculated_edit_form.

◆ choice_group()

qtype_gapselect_edit_form_base::choice_group (   $mform)
protected

Creates an array with elements for a choice group.

Parameters
object$mformThe Moodle form we are working with
int$maxgroupThe number of max group generate element select.
Return values
arrayArray for form elements

Reimplemented in qtype_ddwtos_edit_form.

◆ data_preprocessing()

qtype_gapselect_edit_form_base::data_preprocessing (   $question)

Perform an preprocessing needed on the data passed to set_data() before it is used to initialise the form.

Parameters
object$questionthe data being passed to the form.
Return values
object::$questionthe modified data.

Reimplemented from question_edit_form.

◆ data_preprocessing_answers()

question_edit_form::data_preprocessing_answers (   $question,
  $withanswerfiles = false 
)
protectedinherited

Perform the necessary preprocessing for the fields added by add_per_answer_fields().

Parameters
object$questionthe data being passed to the form.
Return values
object::$questionthe modified data.

Reimplemented in qtype_numerical_edit_form, qtype_calculatedmulti_edit_form, and qtype_calculated_edit_form.

◆ data_preprocessing_combined_feedback()

question_edit_form::data_preprocessing_combined_feedback (   $question,
  $withshownumcorrect = false 
)
protectedinherited

Perform the necessary preprocessing for the fields added by add_combined_feedback_fields().

Parameters
object$questionthe data being passed to the form.
Return values
object::$questionthe modified data.

◆ data_preprocessing_extra_answer_field()

question_edit_form::data_preprocessing_extra_answer_field (   $answer,
  $field 
)
protectedinherited

Perfmorm preprocessing for particular extra answer field.

Questions with non-trivial DB - form element relationship will want to override this.

Parameters
object$answeran answer object to get extra field from.
string$fieldextra answer field name.
Return values
fieldvalue to be set to the form.

◆ data_preprocessing_extra_answer_fields()

question_edit_form::data_preprocessing_extra_answer_fields (   $question,
  $extraanswerfields 
)
protectedinherited

Perform the necessary preprocessing for the extra answer fields.

Questions that do something not trivial when editing extra answer fields will want to override this.

Parameters
object$questionthe data being passed to the form.
array$extraanswerfieldsextra answer fields (without table name).
Return values
object::$questionthe modified data.

◆ data_preprocessing_hints()

question_edit_form::data_preprocessing_hints (   $question,
  $withclearwrong = false,
  $withshownumpartscorrect = false 
)
protectedinherited

Perform the necessary preprocessing for the hint fields.

Parameters
object$questionthe data being passed to the form.
Return values
object::$questionthe modified data.

Reimplemented in qtype_ddmarker_edit_form.

◆ definition()

question_edit_form::definition ( )
protectedinherited

Build the form definition.

This adds all the form fields that the default question type supports. If your question type does not support all these fields, then you can override this method and remove the ones you don't want with $mform->removeElement().

Reimplemented from moodleform.

Reimplemented in qtype_random_edit_form.

◆ definition_after_data()

moodleform::definition_after_data ( )
inherited

◆ definition_answer_choice()

qtype_gapselect_edit_form_base::definition_answer_choice ( $mform)
protected

Defines form elements for answer choices.

Parameters
object$mformThe Moodle form object being built

◆ definition_inner()

qtype_gapselect_edit_form_base::definition_inner (   $mform)
protected

definition_inner adds all specific fields to the form.

Parameters
object$mform(the form being built).

Reimplemented from question_edit_form.

◆ focus()

moodleform::focus (   $name = NULL)
inherited

To autofocus on first form element or first element with error.

Parameters
string$nameif this is set then the focus is forced to a field with this name
Return values
stringjavascript to select form element with first error or first element if no errors. Use this as a parameter when calling print_header

◆ get_data()

moodleform::get_data ( )
inherited

◆ get_draft_files()

moodleform::get_draft_files (   $elname)
protectedinherited

Get draft files of a form element This is a protected method which will be used only inside moodleforms.

Parameters
string$elnamename of element
Return values
array|bool|null

◆ get_file_content()

moodleform::get_file_content (   $elname)
inherited

Get content of uploaded file.

Parameters
string$elnamename of file upload element
Return values
string|boolfalse in case of failure, string if ok

◆ get_form_identifier()

moodleform::get_form_identifier ( )
protectedinherited

It should returns unique identifier for the form.

Currently it will return class name, but in case two same forms have to be rendered on same page then override function to get unique form identifier. e.g This is used on multiple self enrollments page.

Return values
stringform identifier.

Reimplemented in mod_assign_grade_form, and enrol_self_enrol_form.

◆ get_hint_fields()

question_edit_form::get_hint_fields (   $withclearwrong = false,
  $withshownumpartscorrect = false 
)
protectedinherited

Create the form elements required by one hint.

Parameters
string$withclearwrongwhether this quesiton type uses the 'Clear wrong' option on hints.
string$withshownumpartscorrectwhether this quesiton type uses the 'Show num parts correct' option on hints.
Return values
arrayform field elements for one hint.

Reimplemented in qtype_multichoice_edit_form, and qtype_ddmarker_edit_form.

◆ get_illegal_tag_error()

qtype_gapselect_edit_form_base::get_illegal_tag_error (   $text)
protected

Vaidate some input to make sure it does not contain any tags other than $this->allowedhtmltags.

Parameters
string$textthe input to validate.
Return values
stringany validation errors.

◆ get_js_module()

static moodleform::get_js_module ( )
staticinherited

Returns a JS module definition for the mforms JS.

Return values
array

◆ get_maximum_choice_group_number()

qtype_gapselect_edit_form_base::get_maximum_choice_group_number ( )

Return how many different groups of choices there should be.

Return values
intthe maximum group number.

Reimplemented in qtype_gapselect_edit_form.

◆ get_new_filename()

moodleform::get_new_filename (   $elname = null)
inherited

Returns name of uploaded file.

Parameters
string$elnamefirst element if null
Return values
string|boolfalse in case of failure, string if ok

◆ get_non_collabsible_editor_options()

question_edit_form::get_non_collabsible_editor_options ( )
protectedinherited

Returns an array of editor options with collapsed options turned off.

Deprecated:
since 2.6
Return values
array

◆ get_per_answer_fields()

question_edit_form::get_per_answer_fields (   $mform,
  $label,
  $gradeoptions,
$repeatedoptions,
$answersoption 
)
protectedinherited

Get the list of form elements to repeat, one for each answer.

Parameters
object$mformthe form being built.
$labelthe label to use for each option.
$gradeoptionsthe possible grades for each answer.
$repeatedoptionsreference to array of repeated options to fill
$answersoptionreference to return the name of $question->options field holding an array of answers
Return values
arrayof form fields.

Reimplemented in qtype_numerical_edit_form, qtype_multichoice_edit_form, qtype_match_edit_form, qtype_calculatedmulti_edit_form, and qtype_calculated_edit_form.

◆ get_submitted_data()

moodleform::get_submitted_data ( )
inherited

Return submitted data without validation or NULL if there is no submitted data.

note: $slashed param removed

Return values
objectsubmitted data; NULL if not submitted

Reimplemented in lesson_add_page_form_numerical, and core\form\persistent.

◆ init_javascript_enhancement()

moodleform::init_javascript_enhancement (   $element,
  $enhancement,
array  $options = array(),
array  $strings = null 
)
inherited

Adds an initialisation call for a standard JavaScript enhancement.

This function is designed to add an initialisation call for a JavaScript enhancement that should exist within javascript-static M.form.init_{enhancementname}.

Current options:

  • Selectboxes
    • smartselect: Turns a nbsp indented select box into a custom drop down control that supports multilevel and category selection. $enhancement = 'smartselect'; $options = array('selectablecategories' => true|false)
Parameters
string | element$elementform element for which Javascript needs to be initalized
string$enhancementwhich init function should be called
array$optionsoptions passed to javascript
array$stringsstrings for javascript
Deprecated:
since Moodle 3.3 MDL-57471

◆ is_cancelled()

moodleform::is_cancelled ( )
inherited

Return true if a cancel button has been pressed resulting in the form being submitted.

Return values
booltrue if a cancel button has been pressed

Reimplemented in base_moodleform.

◆ is_submitted()

moodleform::is_submitted ( )
inherited

Check that form was submitted.

Does not check validity of submitted data.

Return values
booltrue if form properly submitted

◆ is_validated()

moodleform::is_validated ( )
inherited

Check that form data is valid.

You should almost always use this, rather than validate_defined_fields

Return values
booltrue if form data valid

◆ mock_generate_submit_keys()

static moodleform::mock_generate_submit_keys (   $data = [])
staticinherited

Used by tests to generate valid submit keys for moodle forms that are submitted with ajax data.

Exceptions
moodle_exceptionIf called outside unit test environment
Parameters
array$dataExisting form data you wish to add the keys to.
Return values
array

◆ mock_submit()

static moodleform::mock_submit (   $simulatedsubmitteddata,
  $simulatedsubmittedfiles = array(),
  $method = 'post',
  $formidentifier = null 
)
staticinherited

Used by tests to simulate submitted form data submission from the user.

For form fields where no data is submitted the default for that field as set by set_data or setDefault will be passed to get_data.

This method sets $_POST or $_GET and $_FILES with the data supplied. Our unit test code empties all these global arrays after each test.

Parameters
array$simulatedsubmitteddataAn associative array of form values (same format as $_POST).
array$simulatedsubmittedfilesAn associative array of files uploaded (same format as $_FILES). Can be omitted.
string$method'post' or 'get', defaults to 'post'.
null$formidentifierthe default is to use the class name for this class but you may need to provide a different value here for some forms that are used more than once on the same page.

◆ moodleform()

moodleform::moodleform (   $action = null,
  $customdata = null,
  $method = 'post',
  $target = '',
  $attributes = null,
  $editable = true 
)
inherited

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated:
since Moodle 3.1

◆ no_submit_button_pressed()

moodleform::no_submit_button_pressed ( )
inherited

Checks if button pressed is not for submitting the form.

@staticvar bool $nosubmit keeps track of no submit button

Return values
bool

◆ optional_param()

moodleform::optional_param (   $name,
  $default,
  $type 
)
inherited

Checks if a parameter was passed in the previous form submission.

Parameters
string$namethe name of the page parameter we want
mixed$defaultthe default value to return if nothing is found
string$typeexpected type of parameter
Return values
mixed

◆ qtype()

qtype_gapselect_edit_form_base::qtype ( )

Override this in the subclass to question type name.

Return values
thequestion type name, should be the same as the name() method in the question type class.

Reimplemented from question_edit_form.

Reimplemented in qtype_gapselect_edit_form, and qtype_ddwtos_edit_form.

◆ render()

moodleform::render ( )
inherited

Renders the html form (same as display, but returns the result).

Note that you can only output this rendered result once per page, as it contains IDs which must be unique.

Return values
stringHTML code for the form

◆ repeat_elements()

moodleform::repeat_elements (   $elementobjs,
  $repeats,
  $options,
  $repeathiddenname,
  $addfieldsname,
  $addfieldsno = 5,
  $addstring = null,
  $addbuttoninside = false 
)
inherited

Method to add a repeating group of elements to a form.

Parameters
array$elementobjsArray of elements or groups of elements that are to be repeated
int$repeatsno of times to repeat elements initially
array$optionsa nested array. The first array key is the element name. the second array key is the type of option to set, and depend on that option, the value takes different forms. 'default' - default value to set. Can include '{no}' which is replaced by the repeat number. 'type' - PARAM_* type. 'helpbutton' - array containing the helpbutton params. 'disabledif' - array containing the disabledIf() arguments after the element name. 'rule' - array containing the addRule arguments after the element name. 'expanded' - whether this section of the form should be expanded by default. (Name be a header element.) 'advanced' - whether this element is hidden by 'Show more ...'.
string$repeathiddennamename for hidden element storing no of repeats in this form
string$addfieldsnamename for button to add more fields
int$addfieldsnohow many fields to add at a time
string$addstringname of button, {no} is replaced by no of blanks that will be added.
bool$addbuttoninsideif true, don't call closeHeaderBefore($addfieldsname). Default false.
Return values
intno of repeats of element in this page

◆ repeat_elements_fix_clone()

moodleform::repeat_elements_fix_clone (   $i,
  $elementclone,
$namecloned 
)
inherited

Helper used by repeat_elements().

Parameters
int$ithe index of this element.
HTML_QuickForm_element$elementclone
array$nameclonedarray of names

◆ repeated_options()

qtype_gapselect_edit_form_base::repeated_options ( )
protected

Returns an array for form repeat options.

Return values
arrayArray of repeate options

◆ save_file()

moodleform::save_file (   $elname,
  $pathname,
  $override = false 
)
inherited

Save file to standard filesystem.

Parameters
string$elnamename of element
string$pathnamefull path name of file
bool$overrideoverride file if exists
Return values
boolsuccess

◆ save_files()

moodleform::save_files (   $destination)
inherited

Save verified uploaded files into directory.

Upload process can be customised from definition()

Deprecated:
since Moodle 2.0
Todo:
MDL-31294 remove this api
See also
moodleform::save_stored_file()
moodleform::save_file()
Parameters
string$destinationpath where file should be stored
Return values
boolAlways false

◆ save_stored_file()

moodleform::save_stored_file (   $elname,
  $newcontextid,
  $newcomponent,
  $newfilearea,
  $newitemid,
  $newfilepath = '/',
  $newfilename = null,
  $overwrite = false,
  $newuserid = null 
)
inherited

Save file to local filesystem pool.

Parameters
string$elnamename of element
int$newcontextidid of context
string$newcomponentname of the component
string$newfileareaname of file area
int$newitemiditem id
string$newfilepathpath of file where it get stored
string$newfilenameuse specified filename, if not specified name of uploaded file used
bool$overwriteoverwrite file if exists
int$newuseridnew userid if required
Return values
mixedstored_file object or false if error; may throw exception if duplicate found

◆ save_temp_file()

moodleform::save_temp_file (   $elname)
inherited

Returns a temporary file, do not forget to delete after not needed any more.

Parameters
string$elnamename of the elmenet
Return values
string|booleither string or false

◆ set_data()

question_edit_form::set_data (   $default_values)
inherited

Load in existing data as form defaults.

Usually new entry defaults are stored directly in form definition (new entry form); this function is used to load in data where values already exist and data is being edited (edit entry form).

note: $slashed param removed

Parameters
stdClass | array$default_valuesobject or array of default values

Reimplemented from moodleform.

Reimplemented in qtype_random_edit_form, qtype_multianswer_edit_form, and qtype_missingtype_edit_form.

◆ set_display_vertical()

moodleform::set_display_vertical ( )
inherited

Set display mode for the form when labels take full width of the form and above the elements even on big screens.

Useful for forms displayed inside modals or in narrow containers

◆ set_initial_dirty_state()

moodleform::set_initial_dirty_state (   $state = false)
inherited

Set the initial 'dirty' state of the form.

Parameters
bool$state
Since
Moodle 3.7.1

◆ validate_defined_fields()

moodleform::validate_defined_fields (   $validateonnosubmit = false)
inherited

Validate the form.

You almost always want to call } instead of this * because it calls definition_after_data first, before validating the form, which is what you want in 99% of cases.

This is provided as a separate function for those special cases where you want the form validated before definition_after_data is called for example, to selectively add new elements depending on a no_submit_button press, but only when the form is valid when the no_submit_button is pressed,

Parameters
bool$validateonnosubmitoptional, defaults to false. The default behaviour is NOT to validate the form when a no submit button has been pressed. pass true here to override this behaviour
Return values
booltrue if form data valid

◆ validate_draft_files()

moodleform::validate_draft_files ( )
protectedinherited

Internal method.

Validates filepicker and filemanager files if they are set as required fields. Also, sets the error message if encountered one.

Return values
bool|arraywith errors

◆ validation()

qtype_gapselect_edit_form_base::validation (   $data,
  $files 
)

Dummy stub method - override if you needed to perform some extra validation.

If there are errors return array of errors ("fieldname"=>"error message"), otherwise true if ok.

Server side rules do not work for uploaded files, implement serverside rules here if needed.

Parameters
array$dataarray of ("fieldname"=>value) of submitted data
array$filesarray of uploaded files "element_name"=>tmp_file_path
Return values
arrayof "element_name"=>"error_description" if there are errors, or an empty array if everything is OK (true allowed for backwards compatibility too).

Reimplemented from question_edit_form.

Member Data Documentation

◆ $allowedhtmltags

array qtype_gapselect_edit_form_base::$allowedhtmltags
protected
Initial value:
= array(
'sub',
'sup',
'b',
'i',
'em',
'strong',
'span',
)

of HTML tags allowed in choices / drag boxes.


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