Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MoodleQuickForm_modgrade Class Reference
Inheritance diagram for MoodleQuickForm_modgrade:
MoodleQuickForm_group templatable

Public Member Functions

 __construct ($elementname=null, $elementlabel=null, $options=array(), $attributes=null)
 Constructor. More...
 
 _createElements ()
 Create elements for this group.
 
 accept (&$renderer, $required=false, $error=null)
 Accepts a renderer. More...
 
 createFormElement ()
 Creates an element to add to the group Expects the same arguments as MoodleQuickForm::createElement()
 
 export_for_template (renderer_base $output)
 Function to export the renderer data in a format that is suitable for a mustache template. More...
 
 exportValue (&$submitvalues, $notused=false)
 Calculate the output value for the element as a whole. More...
 
 getElementTemplateType ()
 Returns element template, nodisplay/static/fieldset. More...
 
string getHelpButton ()
 template type, would cause problems with client side validation so will leave for now More...
 
 MoodleQuickForm_group ($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName=true)
 Old syntax of class constructor. More...
 
 MoodleQuickForm_modgrade ($elementname=null, $elementlabel=null, $options=array(), $attributes=null)
 Old syntax of class constructor. More...
 
 onQuickFormEvent ($event, $arg, &$caller)
 Called by HTML_QuickForm whenever form event is made on this element. More...
 
 setElements ($elements)
 Sets the grouped elements and hides label. More...
 
 setMoodleForm ($mform)
 Stores the form this element was added to This object is later used by MoodleQuickForm_group::createElement(). More...
 
 validateSubmitValue ($values)
 Calls the validateSubmitValue function for the containing elements and returns an error string as soon as it finds one. More...
 

Public Attributes

string $_helpbutton =''
 html for help button, if empty then no help
 
boolean $canrescale = false
 $canrescale Does this activity support rescaling grades?
 
float $currentgrade = false
 $currentgrade The current grademax for the grade_item
 
string $currentgradetype = 'none'
 $currentgradetype The current gradetype - can either be 'none', 'scale', or 'point'
 
int $currentscaleid = null
 $currentscaleid The current scale id
 
boolean $hasgrades = false
 $hasgrades Has this grade_item got any real grades (with values)
 
boolean $isupdate = false
 $isupdate Is this an add or an update ?
 
boolean $useratings = false
 $useratings Set to true if the activity is using ratings, false otherwise
 

Protected Member Functions

 generate_modgrade_subelement_id ($subname)
 Generates the id attribute for the subelement of the modgrade group. More...
 
 process_value ($type='none', $scale=null, $point=null, $rescalegrades=null)
 Process the value for the group based on the selected grade type, and the input for the scale and point elements. More...
 
 validate_point ($val)
 Determines whether a given value is a valid point selection. More...
 
 validate_scale ($val)
 Determines whether a given value is a valid scale selection. More...
 

Protected Attributes

MoodleQuickForm $_mform = null
 
 $_renderedfromtemplate = false
 

Constructor & Destructor Documentation

◆ __construct()

MoodleQuickForm_modgrade::__construct (   $elementname = null,
  $elementlabel = null,
  $options = array(),
  $attributes = null 
)

Constructor.

Parameters
string$elementnameElement's name
mixed$elementlabelLabel(s) for an element
array$optionsOptions to control the element's display. Required - must contain the following options: 'isupdate' - is this a new module or are we editing an existing one? 'currentgrade' - the current grademax in the database for this gradeitem 'hasgrades' - whether or not the grade_item has existing grade_grades 'canrescale' - whether or not the activity supports rescaling grades
mixed$attributesEither a typical HTML attribute string or an associative array

Member Function Documentation

◆ accept()

MoodleQuickForm_group::accept ( $renderer,
  $required = false,
  $error = null 
)
inherited

Accepts a renderer.

Parameters
objectAn HTML_QuickForm_Renderer object
boolWhether a group is required
stringAn error message associated with a group
Return values
void

Reimplemented in MoodleQuickForm_date_selector, MoodleQuickForm_date_time_selector, MoodleQuickForm_defaultcustom, MoodleQuickForm_duration, and MoodleQuickForm_filetypes.

◆ export_for_template()

MoodleQuickForm_group::export_for_template ( renderer_base  $output)
inherited

Function to export the renderer data in a format that is suitable for a mustache template.

This means:

  1. No complex types - only stdClass, array, int, string, float, bool
  2. Any additional info that is required for the template is pre-calculated (e.g. capability checks).
Parameters
renderer_base$outputUsed to do a final render of any components that need to be rendered for export.
Return values
stdClass|array

Implements templatable.

Reimplemented in MoodleQuickForm_date_selector, and MoodleQuickForm_date_time_selector.

◆ exportValue()

MoodleQuickForm_modgrade::exportValue ( $submitvalues,
  $notused = false 
)

Calculate the output value for the element as a whole.

Parameters
array$submitvaluesThe incoming values from the form.
bool$notusedNot used.
Return values
arrayReturn value for the element, formatted like field name => value.

◆ generate_modgrade_subelement_id()

MoodleQuickForm_modgrade::generate_modgrade_subelement_id (   $subname)
protected

Generates the id attribute for the subelement of the modgrade group.

Uses algorithm similar to what HTML_QuickForm_element::_generateId() does but takes the name of the wrapping modgrade group into account.

Parameters
string$subnamethe name of the HTML_QuickForm_element in this modgrade group
Return values
string

◆ getElementTemplateType()

MoodleQuickForm_group::getElementTemplateType ( )
inherited

Returns element template, nodisplay/static/fieldset.

Return values
string

◆ getHelpButton()

string MoodleQuickForm_group::getHelpButton ( )
inherited

template type, would cause problems with client side validation so will leave for now

set html for help button

◆ MoodleQuickForm_group()

MoodleQuickForm_group::MoodleQuickForm_group (   $elementName = null,
  $elementLabel = null,
  $elements = null,
  $separator = null,
  $appendName = true 
)
inherited

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated:
since Moodle 3.1

◆ MoodleQuickForm_modgrade()

MoodleQuickForm_modgrade::MoodleQuickForm_modgrade (   $elementname = null,
  $elementlabel = null,
  $options = array(),
  $attributes = null 
)

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated:
since Moodle 3.1

◆ onQuickFormEvent()

MoodleQuickForm_modgrade::onQuickFormEvent (   $event,
  $arg,
$caller 
)

Called by HTML_QuickForm whenever form event is made on this element.

Parameters
string$eventName of event
mixed$argevent arguments
moodleform$callercalling object
Return values
mixed

Reimplemented from MoodleQuickForm_group.

◆ process_value()

MoodleQuickForm_modgrade::process_value (   $type = 'none',
  $scale = null,
  $point = null,
  $rescalegrades = null 
)
protected

Process the value for the group based on the selected grade type, and the input for the scale and point elements.

Parameters
string$typeThe value of the grade type select box. Can be 'none', 'scale', or 'point'
string | int$scaleThe value of the scale select box.
string | int$pointThe value of the point grade textbox.
string$rescalegradesThe value of the rescalegrades select.
Return values
intThe resulting value

◆ setElements()

MoodleQuickForm_group::setElements (   $elements)
inherited

Sets the grouped elements and hides label.

Parameters
array$elements

◆ setMoodleForm()

MoodleQuickForm_group::setMoodleForm (   $mform)
inherited

Stores the form this element was added to This object is later used by MoodleQuickForm_group::createElement().

Parameters
null | MoodleQuickForm$mform

◆ validate_point()

MoodleQuickForm_modgrade::validate_point (   $val)
protected

Determines whether a given value is a valid point selection.

Parameters
string | int$valThe value to test.
Return values
boolValid or invalid

◆ validate_scale()

MoodleQuickForm_modgrade::validate_scale (   $val)
protected

Determines whether a given value is a valid scale selection.

Parameters
string | int$valThe value to test.
Return values
boolValid or invalid

◆ validateSubmitValue()

MoodleQuickForm_group::validateSubmitValue (   $values)
inherited

Calls the validateSubmitValue function for the containing elements and returns an error string as soon as it finds one.

Parameters
array$valuesValues of the containing elements.
Return values
string|nullValidation error message or null.

Reimplemented in MoodleQuickForm_filetypes.


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