Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

Contains the Guide grading form renderer in all of its glory

Copyright: 2012 Dan Marsden <dan@danmarsden.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 793 lines (42 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: gradingform_guide_renderer  - X-Ref

Grading method plugin renderer

criterion_template($mode, $options, $elementname = '{NAME}', $criterion = null, $value = null,$validationerrors = null, $comments = null)   X-Ref
This function returns html code for displaying criterion. Depending on $mode it may be the
code to edit guide, to preview the guide, to evaluate somebody or to review the evaluation.

This function may be called from display_guide() to display the whole guide, or it can be
called by itself to return a template used by JavaScript to add new empty criteria to the
guide being designed.
In this case it will use macros like {NAME}, {LEVELS}, {CRITERION-id}, etc.

When overriding this function it is very important to remember that all elements of html
form (in edit or evaluate mode) must have the name $elementname.

Also JavaScript relies on the class names of elements and when developer changes them
script might stop working.

param: int $mode guide display mode, one of gradingform_guide_controller::DISPLAY_* {@link gradingform_guide_controller()}
param: array $options An array of options.
param: string $elementname the name of the form element (in editor mode) or the prefix for div ids (in view mode)
param: array $criterion criterion data
param: array $value (only in view mode) teacher's feedback on this criterion
param: array $validationerrors An array containing validation errors to be shown
param: array $comments Array of frequently used comments.
return: string

comment_template($mode, $elementname = '{NAME}', $comment = null)   X-Ref
This function returns html code for displaying criterion. Depending on $mode it may be the
code to edit guide, to preview the guide, to evaluate somebody or to review the evaluation.

This function may be called from display_guide() to display the whole guide, or it can be
called by itself to return a template used by JavaScript to add new empty criteria to the
guide being designed.
In this case it will use macros like {NAME}, {LEVELS}, {CRITERION-id}, etc.

When overriding this function it is very important to remember that all elements of html
form (in edit or evaluate mode) must have the name $elementname.

Also JavaScript relies on the class names of elements and when developer changes them
script might stop working.

param: int $mode guide display mode, one of gradingform_guide_controller::DISPLAY_* {@link gradingform_guide_controller}
param: string $elementname the name of the form element (in editor mode) or the prefix for div ids (in view mode)
param: array $comment
return: string

guide_template($mode, $options, $elementname, $criteriastr, $commentstr)   X-Ref
This function returns html code for displaying guide template (content before and after
criteria list). Depending on $mode it may be the code to edit guide, to preview the guide,
to evaluate somebody or to review the evaluation.

This function is called from display_guide() to display the whole guide.

When overriding this function it is very important to remember that all elements of html
form (in edit or evaluate mode) must have the name $elementname.

Also JavaScript relies on the class names of elements and when developer changes them
script might stop working.

param: int $mode guide display mode, one of gradingform_guide_controller::DISPLAY_* {@link gradingform_guide_controller}
param: array $options An array of options provided to {@link gradingform_guide_renderer::guide_edit_options()}
param: string $elementname the name of the form element (in editor mode) or the prefix for div ids (in view mode)
param: string $criteriastr evaluated templates for this guide's criteria
param: string $commentstr
return: string

guide_edit_options($mode, $options)   X-Ref
Generates html template to view/edit the guide options. Expression {NAME} is used in
template for the form element name

param: int $mode guide display mode, one of gradingform_guide_controller::DISPLAY_* {@link gradingform_guide_controller}
param: array $options
return: string

display_guide($criteria, $comments, $options, $mode, $elementname = null, $values = null,$validationerrors = null)   X-Ref
This function returns html code for displaying guide. Depending on $mode it may be the code
to edit guide, to preview the guide, to evaluate somebody or to review the evaluation.

It is very unlikely that this function needs to be overriden by theme. It does not produce
any html code, it just prepares data about guide design and evaluation, adds the CSS
class to elements and calls the functions level_template, criterion_template and
guide_template

param: array $criteria data about the guide design
param: array $comments
param: array $options
param: int $mode guide display mode, one of gradingform_guide_controller::DISPLAY_* {@link gradingform_guide_controller}
param: string $elementname the name of the form element (in editor mode) or the prefix for div ids (in view mode)
param: array $values evaluation result
param: array $validationerrors
return: string

get_css_class_suffix($idx, $maxidx)   X-Ref
Help function to return CSS class names for element (first/last/even/odd) with leading space

param: int $idx index of this element in the row/column
param: int $maxidx maximum index of the element in the row/column
return: string

display_instances($instances, $defaultcontent, $cangrade)   X-Ref
Displays for the student the list of instances or default content if no instances found

param: array $instances array of objects of type gradingform_guide_instance
param: string $defaultcontent default string that would be displayed without advanced grading
param: bool $cangrade whether current user has capability to grade in this context
return: string

display_instance(gradingform_guide_instance $instance, $idx, $cangrade)   X-Ref
Displays one grading instance

param: gradingform_guide_instance $instance
param: int $idx unique number of instance on page
param: bool $cangrade whether current user has capability to grade in this context

display_regrade_confirmation($elementname, $changelevel, $value)   X-Ref
Displays a confirmation message after a regrade has occured

param: string $elementname
param: int $changelevel
param: int $value The regrade option that was used
return: string

display_guide_mapping_explained($scores)   X-Ref
Generates and returns HTML code to display information box about how guide score is converted to the grade

param: array $scores
return: string