Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
lesson_add_page_form_base Class Reference

Abstract class that page type's MUST inherit from. More...

Inheritance diagram for lesson_add_page_form_base:

Public Member Functions

 _process_submission ($method)
 Internal method.
 
 _validate_files (&$files)
 Internal method.
 
 add_action_buttons ($cancel=true, $submitlabel=null)
 Use this method to a cancel and submit button to the end of your form.
 
 add_checkbox_controller ($groupid, $text=null, $attributes=null, $originalValue=0)
 Adds a link/button that controls the checked state of a group of checkboxes.
 
 add_sticky_action_buttons (bool $cancel=true, ?string $submitlabel=null)
 Use this method to make a sticky submit/cancel button at the end of your form.
 
 construction_override ($pageid, lesson $lesson)
 A function that gets called upon init of this object by the calling script.
 
 custom_definition ()
 Each page type can and should override this to add any custom elements to the basic form that they want.
 
 definition ()
 Add the required basic elements to the form.
 
 definition_after_data ()
 Dummy stub method - override if you need to setup the form depending on current values.
 
 display ()
 Print html form.
 
 filter_shown_headers (array $shownonly)
 Use this method to indicate that the fieldsets should be shown as expanded and all other fieldsets should be hidden.
 
 focus ($name=NULL)
 To autofocus on first form element or first element with error.
 
 get_answer_format ()
 Returns answer format used by question type.
 
 get_data ()
 Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data.
 
 get_file_content ($elname)
 Get content of uploaded file.
 
 get_new_filename ($elname=null)
 Returns name of uploaded file.
 
 get_response_format ()
 Returns response format used by question type.
 
 get_submitted_data ()
 Return submitted data without validation or NULL if there is no submitted data.
 
 init_javascript_enhancement ($element, $enhancement, array $options=array(), array $strings=null)
 Adds an initialisation call for a standard JavaScript enhancement.
 
 is_cancelled ()
 Return true if a cancel button has been pressed resulting in the form being submitted.
 
 is_standard ()
 Used to determine if this is a standard page or a special page.
 
 is_submitted ()
 Check that form was submitted.
 
 is_validated ()
 Check that form data is valid.
 
 moodleform ($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true)
 Old syntax of class constructor.
 
 no_submit_button_pressed ()
 Checks if button pressed is not for submitting the form.
 
 optional_param ($name, $default, $type)
 Checks if a parameter was passed in the previous form submission.
 
 render ()
 Renders the html form (same as display, but returns the result).
 
 repeat_elements ($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=null, $addbuttoninside=false, $deletebuttonname='')
 Method to add a repeating group of elements to a form.
 
 repeat_elements_fix_clone ($i, $elementclone, &$namecloned)
 Helper used by repeat_elements().
 
 save_file ($elname, $pathname, $override=false)
 Save file to standard filesystem.
 
 save_files ($destination)
 Save verified uploaded files into directory.
 
 save_stored_file ($elname, $newcontextid, $newcomponent, $newfilearea, $newitemid, $newfilepath='/', $newfilename=null, $overwrite=false, $newuserid=null)
 Save file to local filesystem pool.
 
 save_temp_file ($elname)
 Returns a temporary file, do not forget to delete after not needed any more.
 
 set_data ($default_values)
 Load in existing data as form defaults.
 
 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.
 
 set_initial_dirty_state ($state=false)
 Set the initial 'dirty' state of the form.
 
 validate_defined_fields ($validateonnosubmit=false)
 Validate the form.
 
 validation ($data, $files)
 Dummy stub method - override if you needed to perform some extra validation.
 

Static Public Member Functions

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

Public Attributes

int $qtype
 This is the classic define that is used to identify this pagetype.
 
string $qtypestring
 The simple string that describes the page type e.g.
 

Protected Member Functions

 _get_post_params ()
 Internal method - should not be used anywhere.
 
 add_answer ($count, $label=null, $required=false, $format='', array $help=[])
 Convenience function: Adds an answer editor.
 
 add_jumpto ($name, $label=null, $selected=LESSON_NEXTPAGE)
 Convenience function: Adds a jumpto select element.
 
 add_response ($count, $label=null, $required=false)
 Convenience function: Adds an response editor.
 
 add_score ($name, $label=null, $value=null)
 Convenience function: Adds a score input element.
 
 after_definition ()
 After definition hook.
 
 get_array_value_by_keys (array $array, array $keys)
 Returns an element of multi-dimensional array given the list of keys.
 
 get_draft_files ($elname)
 Get draft files of a form element This is a protected method which will be used only inside moodleforms.
 
 get_form_identifier ()
 It should returns unique identifier for the form.
 
 validate_draft_files ()
 Internal method.
 

Protected Attributes

array $_ajaxformdata
 submitted form data when using mforms with ajax
 
mixed $_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
 
 $answerformat = ''
 Answer format supported by question type.
 
array $editoroptions = array()
 An array of options used in the htmleditor.
 
 $responseformat = ''
 Response format supported by question type.
 
bool $standard = true
 True if this is a standard page of false if it does something special.
 

Static Protected Attributes

static int $uniqueid = 0
 Unique identifier to be used for action buttons.
 

Detailed Description

Abstract class that page type's MUST inherit from.

This is the abstract class that ALL add page type forms must extend. You will notice that all but two of the methods this class contains are final. Essentially the only thing that extending classes can do is extend custom_definition. OR if it has a special requirement on creation it can extend construction_override

@abstract

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

Member Function Documentation

◆ add_answer()

lesson_add_page_form_base::add_answer ( $count,
$label = null,
$required = false,
$format = '',
array $help = [] )
finalprotected

Convenience function: Adds an answer editor.

Parameters
int$countThe count of the element to add
string$label,nullmeans default
bool$required
string$format
array$helpAdd help text via the addHelpButton. Must be an array which contains the string identifier and component as it's elements
Return values
void

◆ add_jumpto()

lesson_add_page_form_base::add_jumpto ( $name,
$label = null,
$selected = LESSON_NEXTPAGE )
finalprotected

Convenience function: Adds a jumpto select element.

Parameters
string$name
string | null$label
int$selectedThe page to select by default

◆ add_response()

lesson_add_page_form_base::add_response ( $count,
$label = null,
$required = false )
finalprotected

Convenience function: Adds an response editor.

Parameters
int$countThe count of the element to add
string$label,nullmeans default
bool$required
Return values
void

◆ add_score()

lesson_add_page_form_base::add_score ( $name,
$label = null,
$value = null )
finalprotected

Convenience function: Adds a score input element.

Parameters
string$name
string | null$label
mixed$valueThe default value

◆ construction_override()

lesson_add_page_form_base::construction_override ( $pageid,
lesson $lesson )

A function that gets called upon init of this object by the calling script.

This can be used to process an immediate action if required. Currently it is only used in special cases by non-standard page types.

Return values
bool

Reimplemented in lesson_add_page_form_cluster, lesson_add_page_form_endofbranch, and lesson_add_page_form_endofcluster.

◆ custom_definition()

◆ definition()

lesson_add_page_form_base::definition ( )
final

Add the required basic elements to the form.

This method adds the basic elements to the form including title and contents and then calls custom_definition();

Reimplemented from moodleform.

◆ is_standard()

lesson_add_page_form_base::is_standard ( )
final

Used to determine if this is a standard page or a special page.

Return values
bool

Member Data Documentation

◆ $qtype

int lesson_add_page_form_base::$qtype

This is the classic define that is used to identify this pagetype.

Will be one of LESSON_*

◆ $qtypestring

string lesson_add_page_form_base::$qtypestring

The simple string that describes the page type e.g.

truefalse, multichoice

◆ $standard

bool lesson_add_page_form_base::$standard = true
protected

True if this is a standard page of false if it does something special.

Questions are standard pages, branch tables are not


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