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

Form element for handling rubric editor. More...

Inheritance diagram for MoodleQuickForm_rubriceditor:

Public Member Functions

 __construct ($elementName=null, $elementLabel=null, $attributes=null)
 Constructor for rubric editor.
 
 add_regrade_confirmation ($changelevel)
 Specifies that confirmation about re-grading needs to be added to this rubric editor.
 
 exportValue (&$submitValues, $assoc=false)
 Prepares the data for saving.
 
 getElementTemplateType ()
 The renderer will take care itself about different display in normal and frozen states.
 
 getHelpButton ()
 get html for help button
 
 MoodleQuickForm_rubriceditor ($elementName=null, $elementLabel=null, $attributes=null)
 Old syntax of class constructor.
 
 non_js_button_pressed ($value)
 Checks if a submit button was pressed which is supposed to be processed on client side by JS but user seem to have disabled JS in the browser.
 
 toHtml ()
 Returns html string to display this element.
 
 validate ($value)
 Validates that rubric has at least one criterion, at least two levels within one criterion, each level has a valid score, all levels have filled definitions and all criteria have filled descriptions.
 

Public Attributes

string $_helpbutton = ''
 help message
 

Protected Member Functions

 get_next_id ($ids)
 Scans array $ids to find the biggest element ! NEWID*, increments it by 1 and returns.
 
 prepare_data ($value=null, $withvalidation=false)
 Prepares the data passed in $_POST:
 

Protected Attributes

bool $nonjsbuttonpressed = false
 If non-submit (JS) button was pressed: null - unknown, true/false - button was/wasn't pressed.
 
bool $regradeconfirmation = false
 Message to display in front of the editor (that there exist grades on this rubric being edited)
 
string bool $validationerrors = null
 stores the result of the last validation: null - undefined, false - no errors, string - error(s) text
 
bool $wasvalidated = false
 if element has already been validated
 

Detailed Description

Form element for handling rubric editor.

The rubric editor is defined as a separate form element. This allows us to render criteria, levels and buttons using the rubric's own renderer. Also, the required Javascript library is included, which processes, on the client, buttons needed for reordering, adding and deleting criteria.

If Javascript is disabled when one of those special buttons is pressed, the form element is not validated and, instead of submitting the form, we process button presses.

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

Constructor & Destructor Documentation

◆ __construct()

MoodleQuickForm_rubriceditor::__construct ( $elementName = null,
$elementLabel = null,
$attributes = null )

Constructor for rubric editor.

Parameters
string$elementName
string$elementLabel
array$attributes

Member Function Documentation

◆ add_regrade_confirmation()

MoodleQuickForm_rubriceditor::add_regrade_confirmation ( $changelevel)

Specifies that confirmation about re-grading needs to be added to this rubric editor.

$changelevel is saved in $this->regradeconfirmation and retrieved in toHtml()

See also
gradingform_rubric_controller\update_or_check_rubric()
Parameters
int$changelevel

◆ exportValue()

MoodleQuickForm_rubriceditor::exportValue ( & $submitValues,
$assoc = false )

Prepares the data for saving.

See also
prepare_data()
Parameters
array$submitValues
boolean$assoc
Return values
array

◆ get_next_id()

MoodleQuickForm_rubriceditor::get_next_id ( $ids)
protected

Scans array $ids to find the biggest element ! NEWID*, increments it by 1 and returns.

Parameters
array$ids
Return values
string

◆ getElementTemplateType()

MoodleQuickForm_rubriceditor::getElementTemplateType ( )

The renderer will take care itself about different display in normal and frozen states.

Return values
string

◆ getHelpButton()

MoodleQuickForm_rubriceditor::getHelpButton ( )

get html for help button

Return values
stringhtml for help button

◆ MoodleQuickForm_rubriceditor()

MoodleQuickForm_rubriceditor::MoodleQuickForm_rubriceditor ( $elementName = null,
$elementLabel = null,
$attributes = null )

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ non_js_button_pressed()

MoodleQuickForm_rubriceditor::non_js_button_pressed ( $value)

Checks if a submit button was pressed which is supposed to be processed on client side by JS but user seem to have disabled JS in the browser.

(buttons 'add criteria', 'add level', 'move up', 'move down', etc.) In this case the form containing this element is prevented from being submitted

Parameters
array$value
Return values
booleantrue if non-submit button was pressed and not processed by JS

◆ prepare_data()

MoodleQuickForm_rubriceditor::prepare_data ( $value = null,
$withvalidation = false )
protected

Prepares the data passed in $_POST:

  • processes the pressed buttons 'addlevel', 'addcriterion', 'moveup', 'movedown', 'delete' (when JavaScript is disabled) sets $this->nonjsbuttonpressed to true/false if such button was pressed
  • if options not passed (i.e. we create a new rubric) fills the options array with the default values
  • if options are passed completes the options array with unchecked checkboxes
  • if $withvalidation is set, adds 'error_xxx' attributes to elements that contain errors and creates an error string and stores it in $this->validationerrors
Parameters
array$value
boolean$withvalidationwhether to enable data validation
Return values
array

◆ toHtml()

MoodleQuickForm_rubriceditor::toHtml ( )

Returns html string to display this element.

Return values
string

◆ validate()

MoodleQuickForm_rubriceditor::validate ( $value)

Validates that rubric has at least one criterion, at least two levels within one criterion, each level has a valid score, all levels have filled definitions and all criteria have filled descriptions.

Parameters
array$value
Return values
string|falseerror text or false if no errors found

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