Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_feedback_complete_form Class Reference

Class mod_feedback_complete_form. More...

Inheritance diagram for mod_feedback_complete_form:
moodleform

Public Member Functions

 __construct ($mode, mod_feedback_structure $structure, $formid, $customdata=null)
 Constructor.
 
 _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_element_rule ($element, $message, $type, $format=null, $validation='server', $reset=false, $force=false)
 Adds a validation rule for the given field - wrapper for $this->_form->addRule()
 
 add_form_element ($item, $element, $addrequiredrule=true, $setdefaultvalue=true)
 Adds an element to this form - to be used by items in their complete_form_element() method.
 
 add_form_group_element ($item, $groupinputname, $name, $elements, $separator, $class='')
 Adds a group element to this form - to be used by items in their complete_form_element() method.
 
 add_validation_rule (callable $callback)
 Adds a validation rule to the form.
 
 definition ()
 Form definition.
 
 definition_after_data ()
 Dummy stub method - override if you need to setup the form depending on current values.
 
 display ()
 Displays the form.
 
 focus ($name=NULL)
 To autofocus on first form element or first element with error.
 
 get_cm ()
 Returns the current course module.
 
 get_course_id ()
 Can be used by the items to get the course id for which feedback is taken.
 
 get_current_course_id ()
 Returns the course where user was before taking the feedback.
 
 get_data ()
 Return submitted data if properly submitted or returns NULL if validation fails or if there is no submitted data.
 
 get_feedback ()
 Record from 'feedback' table corresponding to the current feedback.
 
 get_file_content ($elname)
 Get content of uploaded file.
 
 get_form_element ($elementname)
 Returns a reference to the element - wrapper for function $this->_form->getElement()
 
 get_item_value ($item)
 Returns value for this element that is already stored in temporary or permanent table, usually only available when user clicked "Previous page".
 
 get_mode ()
 Current feedback mode, see constants on the top of this class.
 
 get_new_filename ($elname=null)
 Returns name of uploaded file.
 
 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_frozen ()
 Returns whether the form is frozen, some items may prefer to change the element type in case of frozen form.
 
 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_element_default ($element, $defaultvalue)
 Sets the default value for form element - alias to $this->_form->setDefault()
 
 set_element_type ($element, $type)
 Sets the default value for form element - wrapper to $this->_form->setType()
 
 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 const MODE_COMPLETE = 1
 
int const MODE_EDIT = 3
 
int const MODE_PRINT = 2
 
int const MODE_VIEW_RESPONSE = 4
 
int const MODE_VIEW_TEMPLATE = 5
 

Protected Member Functions

 _get_post_params ()
 Internal method - should not be used anywhere.
 
 add_item_dependencies ($item, $element)
 Adds a dependency description to the question name.
 
 add_item_label ($item, $element)
 Adds an item label to the question name.
 
 add_item_number ($item, $element)
 Adds an item number to the question name (if feedback autonumbering is on)
 
 after_definition ()
 After definition hook.
 
 definition_complete ()
 Called from definition_after_data() in the completion mode.
 
 definition_preview ()
 Called from definition_after_data() in all modes except for completion.
 
 enhance_name_for_edit ($item, $element)
 Adds editing actions to the question name in the edit mode.
 
 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.
 
 get_suggested_class ($item)
 CSS class for the item.
 
 guess_element_id ($item, $element)
 Returns the CSS id attribute that will be assigned by moodleform later to this element.
 
 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
 
mod_feedback_completion $completion
 
int $gopage
 
bool $hasrequired = false
 
int $mode
 
mod_feedback_structure mod_feedback_completion $structure
 

Detailed Description

Class mod_feedback_complete_form.

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

Constructor & Destructor Documentation

◆ __construct()

mod_feedback_complete_form::__construct ( $mode,
mod_feedback_structure $structure,
$formid,
$customdata = null )

Constructor.

Parameters
int$mode
mod_feedback_structure$structure
string$formidCSS id attribute of the form
array$customdata

Member Function Documentation

◆ add_element_rule()

mod_feedback_complete_form::add_element_rule ( $element,
$message,
$type,
$format = null,
$validation = 'server',
$reset = false,
$force = false )

Adds a validation rule for the given field - wrapper for $this->_form->addRule()

Do not use for 'required' rule! Required * will be added automatically, if additional validation is needed use method self::add_validation_rule()

Parameters
string$elementForm element name
string$messageMessage to display for invalid data
string$typeRule type, use getRegisteredRules() to get types
string$format(optional)Required for extra rule data
string$validation(optional)Where to perform validation: "server", "client"
bool$resetClient-side validation: reset the form element to its original value if there is an error?
bool$forceForce the rule to be applied, even if the target form element does not exist

◆ add_form_element()

mod_feedback_complete_form::add_form_element ( $item,
$element,
$addrequiredrule = true,
$setdefaultvalue = true )

Adds an element to this form - to be used by items in their complete_form_element() method.

Parameters
stdClass$item
HTML_QuickForm_element | array$elementeither completed form element or an array that can be passed as arguments to $this->_form->createElement() function
bool$addrequiredruleautomatically add 'required' rule
bool$setdefaultvalueautomatically set default value for element
Return values
HTML_QuickForm_element

◆ add_form_group_element()

mod_feedback_complete_form::add_form_group_element ( $item,
$groupinputname,
$name,
$elements,
$separator,
$class = '' )

Adds a group element to this form - to be used by items in their complete_form_element() method.

Parameters
stdClass$item
string$groupinputnamename for the form element
string$namequestion text
array$elementsarray of arrays that can be passed to $this->_form->createElement()
string$separatorseparator between group elements
string$classadditional CSS classes for the form element
Return values
HTML_QuickForm_element

◆ add_item_dependencies()

mod_feedback_complete_form::add_item_dependencies ( $item,
$element )
protected

Adds a dependency description to the question name.

Parameters
stdClass$item
HTML_QuickForm_element$element

◆ add_item_label()

mod_feedback_complete_form::add_item_label ( $item,
$element )
protected

Adds an item label to the question name.

Parameters
stdClass$item
HTML_QuickForm_element$element

◆ add_item_number()

mod_feedback_complete_form::add_item_number ( $item,
$element )
protected

Adds an item number to the question name (if feedback autonumbering is on)

Parameters
stdClass$item
HTML_QuickForm_element$element

◆ add_validation_rule()

mod_feedback_complete_form::add_validation_rule ( callable $callback)

Adds a validation rule to the form.

Parameters
callable$callbackwith arguments ($values, $files)

◆ definition()

mod_feedback_complete_form::definition ( )

Form definition.

Reimplemented from moodleform.

◆ definition_complete()

mod_feedback_complete_form::definition_complete ( )
protected

Called from definition_after_data() in the completion mode.

This will add only items from a current page to the feedback and adjust the buttons

◆ definition_preview()

mod_feedback_complete_form::definition_preview ( )
protected

Called from definition_after_data() in all modes except for completion.

This will add all items to the form, including pagebreaks as horizontal rules.

◆ display()

mod_feedback_complete_form::display ( )

Displays the form.

Reimplemented from moodleform.

◆ enhance_name_for_edit()

mod_feedback_complete_form::enhance_name_for_edit ( $item,
$element )
protected

Adds editing actions to the question name in the edit mode.

Parameters
stdClass$item
HTML_QuickForm_element$element

◆ get_cm()

mod_feedback_complete_form::get_cm ( )

Returns the current course module.

Return values
cm_info

◆ get_course_id()

mod_feedback_complete_form::get_course_id ( )

Can be used by the items to get the course id for which feedback is taken.

This function returns 0 for feedbacks that are located inside the courses. $this->get_feedback()->course will return the course where feedback is located. $this->get_current_course_id() will return the course where user was before taking the feedback

Return values
int

◆ get_current_course_id()

mod_feedback_complete_form::get_current_course_id ( )

Returns the course where user was before taking the feedback.

For feedbacks inside the course it will be the same as $this->get_feedback()->course. For feedbacks on the frontpage it will be the same as $this->get_course_id()

Return values
int

◆ get_feedback()

mod_feedback_complete_form::get_feedback ( )

Record from 'feedback' table corresponding to the current feedback.

Return values
stdClass

◆ get_form_element()

mod_feedback_complete_form::get_form_element ( $elementname)

Returns a reference to the element - wrapper for function $this->_form->getElement()

Parameters
string$elementnameElement name
Return values
HTML_QuickForm_elementreference to element

◆ get_item_value()

mod_feedback_complete_form::get_item_value ( $item)

Returns value for this element that is already stored in temporary or permanent table, usually only available when user clicked "Previous page".

Null means no value is stored.

Parameters
stdClass$item
Return values
string

◆ get_mode()

mod_feedback_complete_form::get_mode ( )

Current feedback mode, see constants on the top of this class.

Return values
int

◆ get_suggested_class()

mod_feedback_complete_form::get_suggested_class ( $item)
protected

CSS class for the item.

Parameters
stdClass$item
Return values
string

◆ guess_element_id()

mod_feedback_complete_form::guess_element_id ( $item,
$element )
protected

Returns the CSS id attribute that will be assigned by moodleform later to this element.

Parameters
stdClass$item
HTML_QuickForm_element$element

◆ is_frozen()

mod_feedback_complete_form::is_frozen ( )

Returns whether the form is frozen, some items may prefer to change the element type in case of frozen form.

For example, text or textarea element does not look nice when frozen

Return values
bool

◆ set_element_default()

mod_feedback_complete_form::set_element_default ( $element,
$defaultvalue )

Sets the default value for form element - alias to $this->_form->setDefault()

Parameters
HTML_QuickForm_element | string$element
mixed$defaultvalue

◆ set_element_type()

mod_feedback_complete_form::set_element_type ( $element,
$type )

Sets the default value for form element - wrapper to $this->_form->setType()

Parameters
HTML_QuickForm_element | string$element
int$type

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