Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Contains class mod_feedback_complete_form

Copyright: 2016 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 580 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: mod_feedback_complete_form  - X-Ref

Class mod_feedback_complete_form

__construct($mode, mod_feedback_structure $structure, $formid, $customdata = null)   X-Ref
Constructor

param: int $mode
param: mod_feedback_structure $structure
param: string $formid CSS id attribute of the form
param: array $customdata

definition()   X-Ref
Form definition


definition_complete()   X-Ref
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()   X-Ref
Called from definition_after_data() in all modes except for completion

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

remove_button($buttonname)   X-Ref
Removes the button that is not applicable for the current page

param: string $buttonname

get_item_value($item)   X-Ref
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.

param: stdClass $item
return: string

get_course_id()   X-Ref
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: int

get_feedback()   X-Ref
Record from 'feedback' table corresponding to the current feedback

return: stdClass

get_mode()   X-Ref
Current feedback mode, see constants on the top of this class

return: int

is_frozen()   X-Ref
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: bool

get_cm()   X-Ref
Returns the current course module

return: cm_info

get_current_course_id()   X-Ref
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: int

get_suggested_class($item)   X-Ref
CSS class for the item

param: stdClass $item
return: string

add_form_element($item, $element, $addrequiredrule = true, $setdefaultvalue = true)   X-Ref
Adds an element to this form - to be used by items in their complete_form_element() method

param: stdClass $item
param: HTML_QuickForm_element|array $element either completed form element or an array that
param: bool $addrequiredrule automatically add 'required' rule
param: bool $setdefaultvalue automatically set default value for element
return: HTML_QuickForm_element

add_form_group_element($item, $groupinputname, $name, $elements, $separator,$class = '')   X-Ref
Adds a group element to this form - to be used by items in their complete_form_element() method

param: stdClass $item
param: string $groupinputname name for the form element
param: string $name question text
param: array $elements array of arrays that can be passed to $this->_form->createElement()
param: string $separator separator between group elements
param: string $class additional CSS classes for the form element
return: HTML_QuickForm_element

add_item_number($item, $element)   X-Ref
Adds an item number to the question name (if feedback autonumbering is on)

param: stdClass $item
param: HTML_QuickForm_element $element

add_item_label($item, $element)   X-Ref
Adds an item label to the question name

param: stdClass $item
param: HTML_QuickForm_element $element

add_item_dependencies($item, $element)   X-Ref
Adds a dependency description to the question name

param: stdClass $item
param: HTML_QuickForm_element $element

guess_element_id($item, $element)   X-Ref
Returns the CSS id attribute that will be assigned by moodleform later to this element

param: stdClass $item
param: HTML_QuickForm_element $element

enhance_name_for_edit($item, $element)   X-Ref
Adds editing actions to the question name in the edit mode

param: stdClass $item
param: HTML_QuickForm_element $element

set_element_default($element, $defaultvalue)   X-Ref
Sets the default value for form element - alias to $this->_form->setDefault()

param: HTML_QuickForm_element|string $element
param: mixed $defaultvalue

set_element_type($element, $type)   X-Ref
Sets the default value for form element - wrapper to $this->_form->setType()

param: HTML_QuickForm_element|string $element
param: int $type

add_element_rule($element, $message, $type, $format = null, $validation = 'server',$reset = false, $force = false)   X-Ref
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 {@link self::add_validation_rule()}

param: string $element Form element name
param: string $message Message to display for invalid data
param: string $type Rule type, use getRegisteredRules() to get types
param: string $format (optional)Required for extra rule data
param: string $validation (optional)Where to perform validation: "server", "client"
param: bool $reset Client-side validation: reset the form element to its original value if there is an error?
param: bool $force Force the rule to be applied, even if the target form element does not exist

add_validation_rule(callable $callback)   X-Ref
Adds a validation rule to the form

param: callable $callback with arguments ($values, $files)

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

param: string $elementname Element name
return: HTML_QuickForm_element reference to element

display()   X-Ref
Displays the form