Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Attributes | List of all members
feedback_item_base Class Reference
Inheritance diagram for feedback_item_base:
feedback_item_captcha feedback_item_info feedback_item_label feedback_item_multichoice feedback_item_multichoicerated feedback_item_numeric feedback_item_pagebreak feedback_item_textarea feedback_item_textfield

Public Member Functions

 __construct ()
 constructor
 
 build_editform ($item, $feedback, $cm)
 Creates and returns an instance of the form for editing the item. More...
 
 can_switch_require ()
 Wether this item can be set as both required and not. More...
 
 compare_value ($item, $dbvalue, $dependvalue)
 Compares the dbvalue with the dependvalue. More...
 
 complete_form_element ($item, $form)
 Adds an input element to the complete form. More...
 
 create_value ($value)
 Converts the value from complete_form data to the string value that is stored in the db. More...
 
 edit_actions ($item, $feedback, $cm)
 Returns the list of actions allowed on this item in the edit mode. More...
 
 excelprint_item (&$worksheet, $row_offset, $xls_formats, $item, $groupid, $courseid=false)
 Adds summary information about an item to the Excel export file. More...
 
 get_analysed_for_external ($item, $groupid=false, $courseid=false)
 Return the analysis data ready for external functions. More...
 
 get_data ()
 Gets submitted data from the edit form and saves it in $this->item. More...
 
 get_data_for_external ($item)
 Return extra data for external functions. More...
 
 get_display_name ($item, $withpostfix=true)
 Returns the formatted name of the item for the complete form or response view. More...
 
 get_display_name_postfix ($item)
 Returns the postfix to be appended to the display name that is based on other settings. More...
 
 get_hasvalue ()
 Wether this item type has a value that is expected from the user and saved in the stored values. More...
 
 get_printval ($item, $value)
 Prepares the value for exporting to Excel. More...
 
 is_cancelled ()
 Checks if the editing form was cancelled. More...
 
 print_analysed ($item, $itemnr='', $groupid=false, $courseid=false)
 Prints analysis for the current item. More...
 
 save_item ()
 Saves the item after it has been edited (or created)
 
 set_data ($itemdata)
 Set the item data (to be used by data generators). More...
 
 show_editform ()
 Displays the form for editing an item. More...
 

Protected Attributes

stdClass $item
 
feedback_item_form $item_form
 
string file Users stronk7 git_moodle ci tests mod feedback item feedback_item_class php $type
 type of the element, should be overridden by each item type
 

Member Function Documentation

◆ build_editform()

feedback_item_base::build_editform (   $item,
  $feedback,
  $cm 
)
abstract

Creates and returns an instance of the form for editing the item.

Parameters
stdClass$item
stdClass$feedback
cm_info | stdClass$cm

Reimplemented in feedback_item_textfield, feedback_item_textarea, feedback_item_numeric, feedback_item_multichoicerated, feedback_item_multichoice, feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ can_switch_require()

feedback_item_base::can_switch_require ( )

Wether this item can be set as both required and not.

Return values
bool

Reimplemented in feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ compare_value()

feedback_item_base::compare_value (   $item,
  $dbvalue,
  $dependvalue 
)

Compares the dbvalue with the dependvalue.

Parameters
stdClass$item
string$dbvalueis the value input by user in the format as it is stored in the db
string$dependvalueis the value that it needs to be compared against

Reimplemented in feedback_item_multichoicerated, feedback_item_multichoice, and feedback_item_label.

◆ complete_form_element()

feedback_item_base::complete_form_element (   $item,
  $form 
)
abstract

Adds an input element to the complete form.

This method is called:

  • to display the form when user completes feedback
  • to display existing elements when teacher edits the feedback items
  • to display the feedback preview (print.php)
  • to display the completed response
  • to preview a feedback template

If it is important which mode the form is in, use $form->get_mode()

Each item type must add a single form element with the name $item->typ.'_'.$item->id This element must always be present in form data even if nothing is selected (i.e. use advcheckbox and not checkbox). To add an element use either: $form->add_form_element() - adds a single element to the form $form->add_form_group_element() - adds a group element to the form

Other useful methods: $form->get_item_value() $form->set_element_default() $form->add_validation_rule() $form->set_element_type()

The element must support freezing so it can be used for viewing the response as well. If the desired form element does not support freezing, check $form->is_frozen() and create a static element instead.

Parameters
stdClass$item
mod_feedback_complete_form$form

Reimplemented in feedback_item_textfield, feedback_item_textarea, feedback_item_numeric, feedback_item_multichoicerated, feedback_item_multichoice, feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ create_value()

feedback_item_base::create_value (   $value)

Converts the value from complete_form data to the string value that is stored in the db.

Parameters
mixed$valueelement from mod_feedback_complete_form::get_data() with the name $item->typ.'_'.$item->id
Return values
string

Reimplemented in feedback_item_textfield, feedback_item_multichoice, feedback_item_info, feedback_item_textarea, feedback_item_numeric, feedback_item_pagebreak, and feedback_item_captcha.

◆ edit_actions()

feedback_item_base::edit_actions (   $item,
  $feedback,
  $cm 
)

Returns the list of actions allowed on this item in the edit mode.

Parameters
stdClass$item
stdClass$feedback
cm_info$cm
Return values
action_menu_link[]

Reimplemented in feedback_item_pagebreak, and feedback_item_captcha.

◆ excelprint_item()

feedback_item_base::excelprint_item ( $worksheet,
  $row_offset,
  $xls_formats,
  $item,
  $groupid,
  $courseid = false 
)
abstract

Adds summary information about an item to the Excel export file.

Parameters
object$worksheeta reference to the pear_spreadsheet-object
integer$row_offset
stdClass$xls_formatssee analysis_to_excel.php
object$itemthe db-object from feedback_item
integer$groupid
integer$courseid
Return values
integerthe new row_offset

Reimplemented in feedback_item_textfield, feedback_item_textarea, feedback_item_numeric, feedback_item_multichoicerated, feedback_item_multichoice, feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ get_analysed_for_external()

feedback_item_base::get_analysed_for_external (   $item,
  $groupid = false,
  $courseid = false 
)
abstract

Return the analysis data ready for external functions.

Parameters
stdClass$itemthe item (question) information
int$groupidthe group id to filter data (optional)
int$courseidthe course id (optional)
Return values
arrayan array of data with non scalar types json encoded
Since
Moodle 3.3

Reimplemented in feedback_item_textfield, feedback_item_textarea, feedback_item_numeric, feedback_item_multichoicerated, feedback_item_multichoice, feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ get_data()

feedback_item_base::get_data ( )

Gets submitted data from the edit form and saves it in $this->item.

Return values
bool

Reimplemented in feedback_item_pagebreak, and feedback_item_captcha.

◆ get_data_for_external()

feedback_item_base::get_data_for_external (   $item)

Return extra data for external functions.

Some items may have additional configuration data or default values that should be returned for external functions:

  • Info elements: The default value information (course or category name)
  • Captcha: The recaptcha challenge hash key
Parameters
stdClass$itemthe item object
Return values
strthe data, may be json_encoded for large structures

Reimplemented in feedback_item_info, and feedback_item_captcha.

◆ get_display_name()

feedback_item_base::get_display_name (   $item,
  $withpostfix = true 
)

Returns the formatted name of the item for the complete form or response view.

Parameters
stdClass$item
bool$withpostfix
Return values
string

Reimplemented in feedback_item_label, and feedback_item_captcha.

◆ get_display_name_postfix()

feedback_item_base::get_display_name_postfix (   $item)

Returns the postfix to be appended to the display name that is based on other settings.

Parameters
stdClass$item
Return values
string

Reimplemented in feedback_item_numeric.

◆ get_hasvalue()

feedback_item_base::get_hasvalue ( )

Wether this item type has a value that is expected from the user and saved in the stored values.

Return values
int

Reimplemented in feedback_item_label, feedback_item_pagebreak, and feedback_item_captcha.

◆ get_printval()

feedback_item_base::get_printval (   $item,
  $value 
)
abstract

Prepares the value for exporting to Excel.

Parameters
object$itemthe db-object from feedback_item
string$valuea item-related value from feedback_values
Return values
string

Reimplemented in feedback_item_textfield, feedback_item_textarea, feedback_item_numeric, feedback_item_multichoicerated, feedback_item_multichoice, feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ is_cancelled()

feedback_item_base::is_cancelled ( )

Checks if the editing form was cancelled.

Return values
bool

Reimplemented in feedback_item_pagebreak, and feedback_item_captcha.

◆ print_analysed()

feedback_item_base::print_analysed (   $item,
  $itemnr = '',
  $groupid = false,
  $courseid = false 
)
abstract

Prints analysis for the current item.

Parameters
$itemthe db-object from feedback_item
string$itemnr
integer$groupid
integer$courseid
Return values
integerthe new itemnr

Reimplemented in feedback_item_textfield, feedback_item_textarea, feedback_item_numeric, feedback_item_multichoicerated, feedback_item_multichoice, feedback_item_label, feedback_item_info, feedback_item_pagebreak, and feedback_item_captcha.

◆ set_data()

feedback_item_base::set_data (   $itemdata)

Set the item data (to be used by data generators).

Parameters
stdClass$itemdatathe item data to set
Since
Moodle 3.3

◆ show_editform()

feedback_item_base::show_editform ( )

Displays the form for editing an item.

this function only can used after the call of build_editform()

Reimplemented in feedback_item_pagebreak, and feedback_item_captcha.


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