Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

File contains definition of class MoodleQuickForm_rubriceditor

Copyright: 2011 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 395 lines (17 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 0 files

Defines 2 classes

MoodleQuickForm_rubriceditor:: (2 methods):
  __construct()
  MoodleQuickForm_rubriceditor()

name:: (9 methods):
  getHelpButton()
  getElementTemplateType()
  add_regrade_confirmation()
  toHtml()
  prepare_data()
  get_next_id()
  non_js_button_pressed()
  validate()
  exportValue()


Class: MoodleQuickForm_rubriceditor  - X-Ref

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.

__construct($elementName=null, $elementLabel=null, $attributes=null)   X-Ref
Constructor for rubric editor

param: string $elementName
param: string $elementLabel
param: array $attributes

MoodleQuickForm_rubriceditor($elementName=null, $elementLabel=null, $attributes=null)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

getHelpButton()   X-Ref
get html for help button

return: string html for help button

getElementTemplateType()   X-Ref
The renderer will take care itself about different display in normal and frozen states

return: string

add_regrade_confirmation($changelevel)   X-Ref
Specifies that confirmation about re-grading needs to be added to this rubric editor.
$changelevel is saved in $this->regradeconfirmation and retrieved in toHtml()

param: int $changelevel

toHtml()   X-Ref
Returns html string to display this element

return: string

prepare_data($value = null, $withvalidation = false)   X-Ref
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

param: array $value
param: boolean $withvalidation whether to enable data validation
return: array

get_next_id($ids)   X-Ref
Scans array $ids to find the biggest element ! NEWID*, increments it by 1 and returns

param: array $ids
return: string

non_js_button_pressed($value)   X-Ref
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

param: array $value
return: boolean true if non-submit button was pressed and not processed by JS

validate($value)   X-Ref
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

param: array $value
return: string|false error text or false if no errors found

exportValue(&$submitValues, $assoc = false)   X-Ref
Prepares the data for saving

param: array $submitValues
param: boolean $assoc
return: array