Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
mod_lesson_mod_form Class Reference
Inheritance diagram for mod_lesson_mod_form:
moodleform_mod moodleform

Public Member Functions

 __construct ($current, $section, $cm, $course)
 
 _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_action_buttons ($cancel=true, $submitlabel=null, $submit2label=null)
 Overriding formslib's add_action_buttons() method, to add an extra submit "save changes and return" button.
 
 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_completion_rules ()
 Display module-specific activity completion rules.
 
 add_completiongrade_rules ()
 Add completion grading elements to the form and return the list of element ids.
 
 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.
 
 apply_admin_defaults ($datetimeoffsets=array())
 Get the list of admin settings for this module and apply any defaults/advanced/locked/required settings.
 
 completion_rule_enabled ($data)
 Called during validation.
 
 data_postprocessing ($data)
 Allows module to modify the data returned by form get_data().
 
 data_preprocessing (&$defaultvalues)
 Enforce defaults here.
 
 definition ()
 Form definition.
 
 definition_after_data ()
 Each module which defines definition_after_data() must call this method using parent\definition_after_data();.
 
 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_context ()
 Return the course context for new modules, or the module context for existing modules.
 
 get_course ()
 Get the course id.
 
 get_coursemodule ()
 Get the course module object.
 
 get_current ()
 Get the current data for the form.
 
 get_data ()
 Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data.
 
 get_features ()
 Return the features this module supports.
 
 get_file_content ($elname)
 Get content of uploaded file.
 
 get_instance ()
 Get the DB record for the current instance.
 
 get_new_filename ($elname=null)
 Returns name of uploaded file.
 
 get_section ()
 Get the course section number (relative).
 
 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_submitted ()
 Check that form was submitted.
 
 is_validated ()
 Check that form data is valid.
 
 mod_lesson_mod_form ($current, $section, $cm, $course)
 Old syntax of class constructor.
 
 moodleform ($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true)
 Old syntax of class constructor.
 
 moodleform_mod ($current, $section, $cm, $course)
 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.
 
 standard_grading_coursemodule_elements ()
 
 standard_hidden_coursemodule_elements ()
 
 validate_defined_fields ($validateonnosubmit=false)
 Validate the form.
 
 validation ($data, $files)
 Enforce validation rules here.
 

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.
 

Protected Member Functions

 _get_post_params ()
 Internal method - should not be used anywhere.
 
 add_intro_editor ($required=null, $customlabel=null)
 Add an editor for an activity's introduction field.
 
 add_rating_settings ($mform, int $itemnumber)
 Add rating settings.
 
 after_definition ()
 After definition hook.
 
 apply_admin_locked_flags ()
 Get the list of admin settings for this module and apply any locked settings.
 
 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.
 
 init_features ()
 
 plugin_extend_coursemodule_definition_after_data ()
 Plugins can extend the coursemodule settings form after the data is set.
 
 plugin_extend_coursemodule_standard_elements ()
 Plugins can extend the coursemodule settings form.
 
 plugin_extend_coursemodule_validation ($data)
 Extend the validation function from any other plugin.
 
 standard_coursemodule_elements ()
 Adds all the standard elements to a form to edit the settings for an activity module.
 
 standard_intro_elements ($customlabel=null)
 Add an editor for an activity's introduction field.
 
 validate_draft_files ()
 Internal method.
 

Protected Attributes

array $_ajaxformdata
 submitted form data when using mforms with ajax
 
mixed $_cm
 Course module record of the module that is being updated.
 
mixed $_course
 Current course.
 
array $_customcompletionelements
 Custom completion-rule elements, if enabled.
 
mixed $_customdata
 globals workaround
 
object $_definition_finalized = false
 definition_after_data executed flag
 
 $_features
 List of modform features.
 
MoodleQuickForm $_form
 quickform object definition
 
string $_formname
 name of the form
 
mixed $_instance
 Instance of the module that is being updated.
 
string $_modname
 name of module.
 
 $_outcomesused
 a flag indicating whether outcomes are being used
 
int $_section
 Section of course that module instance will be put in or is in.
 
bool null $_validated = null
 stores the validation result of this form or null if not yet validated
 
bool $applyadminlockedflags = false
 A flag used to indicate that this module should lock settings based on admin settings flags in definition_after_data.
 
 $context
 current context, course or module depends if already exists
 
 $course = null
 
object $courseformat
 The course format of the current course.
 
 $current
 Current data.
 

Static Protected Attributes

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

Constructor & Destructor Documentation

◆ __construct()

mod_lesson_mod_form::__construct ( $current,
$section,
$cm,
$course )

Reimplemented from moodleform_mod.

Member Function Documentation

◆ add_action_buttons()

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

Overriding formslib's add_action_buttons() method, to add an extra submit "save changes and return" button.

Parameters
bool$cancelshow cancel button
string$submitlabelnull means default, false means none, string is label text
string$submit2labelnull means default, false means none, string is label text
Return values
void

◆ add_completion_rules()

mod_lesson_mod_form::add_completion_rules ( )

Display module-specific activity completion rules.

Part of the API defined by moodleform_mod

Return values
arrayArray of string IDs of added items, empty array if none

Reimplemented from moodleform_mod.

◆ add_completiongrade_rules()

moodleform_mod::add_completiongrade_rules ( )
inherited

Add completion grading elements to the form and return the list of element ids.

Return values
arrayArray of string IDs of added items, empty array if none

Reimplemented in mod_quiz_mod_form.

◆ add_intro_editor()

moodleform_mod::add_intro_editor ( $required = null,
$customlabel = null )
protectedinherited

Add an editor for an activity's introduction field.

Deprecated
since MDL-49101 - use moodleform_mod\standard_intro_elements() instead.
Parameters
null$requiredOverride system default for requiremodintro
null$customlabelOverride default label for editor
Exceptions
coding_exception

◆ add_rating_settings()

moodleform_mod::add_rating_settings ( $mform,
int $itemnumber )
protectedinherited

Add rating settings.

Parameters
moodleform_mod$mform
int$itemnumber

◆ apply_admin_defaults()

moodleform_mod::apply_admin_defaults ( $datetimeoffsets = array())
inherited

Get the list of admin settings for this module and apply any defaults/advanced/locked/required settings.

Parameters
$datetimeoffsetsarray - If passed, this is an array of fieldnames => times that the default date/time value should be relative to. If not passed, all date/time fields are set relative to the users current midnight.
Return values
void

◆ apply_admin_locked_flags()

moodleform_mod::apply_admin_locked_flags ( )
protectedinherited

Get the list of admin settings for this module and apply any locked settings.

This cannot happen in apply_admin_defaults because we do not the current values of the settings in that function because set_data has not been called yet.

Return values
void

◆ completion_rule_enabled()

mod_lesson_mod_form::completion_rule_enabled ( $data)

Called during validation.

Indicates whether a module-specific completion rule is selected.

Parameters
array$dataInput data (not yet validated)
Return values
boolTrue if one or more rules is enabled, false if none are.

Reimplemented from moodleform_mod.

◆ data_postprocessing()

mod_lesson_mod_form::data_postprocessing ( $data)

Allows module to modify the data returned by form get_data().

This method is also called in the bulk activity completion form.

Only available on moodleform_mod.

Parameters
stdClass$datathe form data to be modified.

Reimplemented from moodleform_mod.

◆ data_preprocessing()

mod_lesson_mod_form::data_preprocessing ( & $defaultvalues)

Enforce defaults here.

Parameters
array$defaultvaluesForm defaults
Return values
void

Reimplemented from moodleform_mod.

◆ definition()

mod_lesson_mod_form::definition ( )

Form definition.

Abstract method - always override!

Reimplemented from moodleform.

◆ definition_after_data()

moodleform_mod::definition_after_data ( )
inherited

Each module which defines definition_after_data() must call this method using parent\definition_after_data();.

Reimplemented from moodleform.

Reimplemented in mod_bigbluebuttonbn_mod_form, mod_forum_mod_form, mod_glossary_mod_form, mod_resource_mod_form, and mod_workshop_mod_form.

◆ get_context()

moodleform_mod::get_context ( )
inherited

Return the course context for new modules, or the module context for existing modules.

Return values
context

◆ get_course()

moodleform_mod::get_course ( )
inherited

Get the course id.

Return values
int

◆ get_coursemodule()

moodleform_mod::get_coursemodule ( )
inherited

Get the course module object.

Return values
stdClass|null

◆ get_current()

moodleform_mod::get_current ( )
inherited

Get the current data for the form.

Return values
stdClass|null

◆ get_data()

moodleform_mod::get_data ( )
inherited

Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data.

Do not override this method, override data_postprocessing() instead.

Return values
objectsubmitted data; NULL if not valid or not submitted or cancelled

Reimplemented from moodleform.

Reimplemented in mod_forum_mod_form.

◆ get_features()

moodleform_mod::get_features ( )
inherited

Return the features this module supports.

Return values
stdClass

◆ get_instance()

moodleform_mod::get_instance ( )
inherited

Get the DB record for the current instance.

Return values
stdClass|null

◆ get_section()

moodleform_mod::get_section ( )
inherited

Get the course section number (relative).

Return values
int

◆ mod_lesson_mod_form()

mod_lesson_mod_form::mod_lesson_mod_form ( $current,
$section,
$cm,
$course )

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ moodleform_mod()

moodleform_mod::moodleform_mod ( $current,
$section,
$cm,
$course )
inherited

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ plugin_extend_coursemodule_validation()

moodleform_mod::plugin_extend_coursemodule_validation ( $data)
protectedinherited

Extend the validation function from any other plugin.

Parameters
stdClass$dataThe form data.
Return values
array\$errorsThe list of errors keyed by element name.

◆ set_data()

moodleform_mod::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).

Parameters
mixed$default_valuesobject or array of default values

Reimplemented from moodleform.

Reimplemented in mod_lti_mod_form, and mod_scorm_mod_form.

◆ standard_intro_elements()

moodleform_mod::standard_intro_elements ( $customlabel = null)
protectedinherited

Add an editor for an activity's introduction field.

Parameters
null$customlabelOverride default label for editor
Exceptions
coding_exception

◆ validation()

mod_lesson_mod_form::validation ( $data,
$files )

Enforce validation rules here.

Parameters
object$dataPost data to validate
Return values
array

Reimplemented from moodleform_mod.

Member Data Documentation

◆ $_cm

mixed moodleform_mod::$_cm
protectedinherited

Course module record of the module that is being updated.

Will be null if this is an 'add' form and not an update one.

◆ $_instance

mixed moodleform_mod::$_instance
protectedinherited

Instance of the module that is being updated.

This is the id of the {prefix}{modulename} record. Can be used in form definition. Will be "" if this is an 'add' form and not an update one.

◆ $_section

int moodleform_mod::$_section
protectedinherited

Section of course that module instance will be put in or is in.

This is always the section number itself (column 'section' from 'course_sections' table).


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