Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
gradingform_guide_controller Class Reference

This controller encapsulates the guide grading logic. More...

Inheritance diagram for gradingform_guide_controller:
gradingform_controller

Public Member Functions

 create_instance ($raterid, $itemid=null)
 This function is invoked when user (teacher) starts grading. More...
 
 delete_definition ()
 Deletes the form definition and all the associated data. More...
 
 extend_navigation (global_navigation $navigation, navigation_node $node=null)
 Extends the module navigation. More...
 
 extend_settings_navigation (settings_navigation $settingsnav, navigation_node $node=null)
 Extends the module settings navigation with the guide grading settings. More...
 
 fetch_instance (int $raterid, int $itemid, ?int $instanceid)
 If an instanceid is specified and grading instance exists and it is created by this rater for this item, then the instance is returned. More...
 
 form_unavailable_notification ()
 Returns a message why this form is unavailable. More...
 
 get_active_instances ($itemid)
 Returns list of ACTIVE instances for the specified $itemid (intentionally does not return instances with status NEEDUPDATE) More...
 
 get_all_active_instances ($since=0)
 Returns an array of all active instances for this definition. More...
 
 get_allow_grade_decimals ()
 Returns if decimal values are allowed as grades. More...
 
 get_area ()
 Returns gradable area name. More...
 
 get_areaid ()
 Returns gradable area id. More...
 
 get_component ()
 Returns gradable component name. More...
 
 get_context ()
 Returns controller context. More...
 
 get_current_instance ($raterid, $itemid, $idonly=false)
 Returns the current instance (either with status ACTIVE or NEEDUPDATE) for this definition for the specified $raterid and $itemid (if multiple raters are allowed, or only for $itemid otherwise). More...
 
 get_definition ($force=false)
 Returns the grading form definition structure. More...
 
 get_definition_copy (gradingform_controller $target)
 Returns the form definition suitable for cloning into another area. More...
 
 get_definition_for_editing ($addemptycriterion=false)
 Converts the current definition into an object suitable for the editor form's set_data() More...
 
 get_editor_url (moodle_url $returnurl=null)
 Returns URL of a page where the grading form can be defined and edited. More...
 
 get_formatted_description ()
 Formats the definition description for display on page. More...
 
 get_grade_range ()
 Returns the range of grades used in this area. More...
 
 get_min_max_score ()
 Calculates and returns the possible minimum and maximum score (in points) for this guide. More...
 
 get_options ()
 Gets the options of this guide definition, fills the missing options with default values. More...
 
 get_or_create_instance ($instanceid, $raterid, $itemid)
 If instanceid is specified and grading instance exists and it is created by this rater for this item, this instance is returned. More...
 
 get_renderer (moodle_page $page)
 Returns the guide plugin renderer. More...
 
 has_active_instances ()
 Returns true if there are already people who has been graded on this definition. More...
 
 is_form_available ()
 Is the grading form defined and ready for usage? More...
 
 is_form_defined ()
 Is the form definition record available? More...
 
 is_own_form ($userid=null)
 Is the grading form owned by the given user? More...
 
 is_shared_template ()
 Is the grading form saved as a shared public template? More...
 
 mark_for_regrade ()
 Marks all instances filled with this guide with the status INSTANCE_STATUS_NEEDUPDATE.
 
 render_grade ($page, $itemid, $gradinginfo, $defaultcontent, $cangrade)
 Returns html code to be included in student's feedback. More...
 
 render_preview (moodle_page $page)
 Returns the HTML code displaying the preview of the grading form. More...
 
 set_grade_range (array $graderange, $allowgradedecimals=false)
 Sets the range of grades used in this area. More...
 
 update_definition (stdClass $newdefinition, $usermodified=null)
 Saves the guide definition into the database. More...
 
 update_or_check_guide (stdClass $newdefinition, $usermodified=null, $doupdate=false)
 Either saves the guide definition into the database or check if it has been changed. More...
 

Static Public Member Functions

static description_form_field_options ($context)
 Options for displaying the guide description field in the form. More...
 
static get_default_options ()
 Returns the default options for the guide display. More...
 
static get_external_definition_details ()
 
static get_external_instance_filling_details ()
 Returns an array that defines the structure of the guide's filling. More...
 
static sql_search_from_tables ($gdid)
 Prepare the part of the search query to append to the FROM statement. More...
 
static sql_search_where ($token)
 Prepare the parts of the SQL WHERE statement to search for the given token. More...
 

Public Attributes

const DEFINITION_STATUS_DRAFT = 10
 the form is currently being edited and is not ready for usage yet
 
const DEFINITION_STATUS_NULL = 0
 undefined definition status
 
const DEFINITION_STATUS_READY = 20
 the form was marked as ready for actual usage
 
const DISPLAY_EDIT_FROZEN = 2
 guide display mode: Preview the guide design with hidden fields
 
const DISPLAY_EDIT_FULL = 1
 guide display mode: For editing (moderator or teacher creates a guide)
 
const DISPLAY_EVAL = 4
 guide display mode: For evaluation, enabled (teacher grades a student)
 
const DISPLAY_EVAL_FROZEN = 5
 guide display mode: For evaluation, with hidden fields
 
const DISPLAY_PREVIEW = 3
 guide display mode: Preview the guide design (for person with manage permission)
 
const DISPLAY_PREVIEW_GRADED = 8
 guide display mode: Preview the guide (for people being graded)
 
const DISPLAY_REVIEW = 6
 guide display mode: Teacher reviews filled guide
 
const DISPLAY_VIEW = 7
 guide display mode: Dispaly filled guide (i.e. More...
 

Protected Member Functions

 delete_plugin_definition ()
 Deletes the guide definition and all the associated information. More...
 
 get_instance ($instance)
 Returns the object of type gradingform_XXX_instance (where XXX is the plugin method name) More...
 
 get_method_name ()
 Returns the name of the grading method plugin, eg 'rubric'. More...
 
 load_definition ()
 Loads the guide form definition if it exists. More...
 

Protected Attributes

string $area
 the name of the gradable area
 
int $areaid
 the id of the gradable area record
 
string $component
 the frankenstyle name of the component
 
stdClass $context
 the context
 
stdClass false $definition = false
 the definition structure
 
boolean null $hasactiveinstances = null
 cached result of function has_active_instances()
 
stdClass false $moduleinstance = false
 the definition structure
 

Detailed Description

This controller encapsulates the guide grading logic.

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

Member Function Documentation

◆ create_instance()

gradingform_controller::create_instance (   $raterid,
  $itemid = null 
)
inherited

This function is invoked when user (teacher) starts grading.

It creates and returns copy of the current ACTIVE instance if it exists. If this is the first grading attempt, a new instance is created. The status of the returned instance is INCOMPLETE

Parameters
int$raterid
int$itemid
Return values
gradingform_instance

◆ delete_definition()

gradingform_controller::delete_definition ( )
inherited

Deletes the form definition and all the associated data.

See also
delete_plugin_definition()
Return values
void

◆ delete_plugin_definition()

gradingform_guide_controller::delete_plugin_definition ( )
protected

Deletes the guide definition and all the associated information.

Reimplemented from gradingform_controller.

◆ description_form_field_options()

static gradingform_guide_controller::description_form_field_options (   $context)
static

Options for displaying the guide description field in the form.

Parameters
context$context
Return values
arrayoptions for the form description field

◆ extend_navigation()

gradingform_guide_controller::extend_navigation ( global_navigation  $navigation,
navigation_node  $node = null 
)

Extends the module navigation.

This function is called when the context for the page is an activity module with the FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.

Parameters
global_navigation$navigationglobal_navigation
navigation_node$nodenavigation_node
Return values
void

Reimplemented from gradingform_controller.

◆ extend_settings_navigation()

gradingform_guide_controller::extend_settings_navigation ( settings_navigation  $settingsnav,
navigation_node  $node = null 
)

Extends the module settings navigation with the guide grading settings.

This function is called when the context for the page is an activity module with the FEATURE_ADVANCED_GRADING, the user has the permission moodle/grade:managegradingforms and there is an area with the active grading method set to 'guide'.

Parameters
settings_navigation$settingsnavsettings_navigation
navigation_node$nodenavigation_node

Reimplemented from gradingform_controller.

◆ fetch_instance()

gradingform_controller::fetch_instance ( int  $raterid,
int  $itemid,
?int  $instanceid 
)
inherited

If an instanceid is specified and grading instance exists and it is created by this rater for this item, then the instance is returned.

If instanceid is not known, then null can be passed to fetch the current instance matchign the specified raterid and itemid.

If the instanceid is falsey, or no instance was found, then create a new instance for the specified rater and item.

Parameters
int$raterid
int$itemid
int$instanceid
Return values
gradingform_instance
Exceptions
dml_exception

◆ form_unavailable_notification()

gradingform_controller::form_unavailable_notification ( )
inherited

Returns a message why this form is unavailable.

Maybe overriden by plugins to give more details.

See also
is_form_available()
Return values
string

◆ get_active_instances()

gradingform_controller::get_active_instances (   $itemid)
inherited

Returns list of ACTIVE instances for the specified $itemid (intentionally does not return instances with status NEEDUPDATE)

Parameters
int$itemid
Return values
arrayof gradingform_instance objects

◆ get_all_active_instances()

gradingform_controller::get_all_active_instances (   $since = 0)
inherited

Returns an array of all active instances for this definition.

(intentionally does not return instances with status NEEDUPDATE)

Parameters
intsince only return instances with timemodified >= since
Return values
arrayof gradingform_instance objects

◆ get_allow_grade_decimals()

gradingform_controller::get_allow_grade_decimals ( )
finalinherited

Returns if decimal values are allowed as grades.

Return values
bool

◆ get_area()

gradingform_controller::get_area ( )
inherited

Returns gradable area name.

Return values
stringgradable area name

◆ get_areaid()

gradingform_controller::get_areaid ( )
inherited

Returns gradable area id.

Return values
intgradable area id

◆ get_component()

gradingform_controller::get_component ( )
inherited

Returns gradable component name.

Return values
stringgradable component name

◆ get_context()

gradingform_controller::get_context ( )
inherited

Returns controller context.

Return values
stdClasscontroller context

◆ get_current_instance()

gradingform_controller::get_current_instance (   $raterid,
  $itemid,
  $idonly = false 
)
inherited

Returns the current instance (either with status ACTIVE or NEEDUPDATE) for this definition for the specified $raterid and $itemid (if multiple raters are allowed, or only for $itemid otherwise).

Parameters
int$raterid
int$itemid
boolean$idonly
Return values
mixedif $idonly=true returns id of the found instance, otherwise returns the instance object

◆ get_default_options()

static gradingform_guide_controller::get_default_options ( )
static

Returns the default options for the guide display.

Return values
array

◆ get_definition()

gradingform_controller::get_definition (   $force = false)
inherited

Returns the grading form definition structure.

Parameters
boolean$forcewhether to force loading from DB even if it was already loaded
Return values
stdClass|falsedefinition data or false if the form is not defined yet

◆ get_definition_copy()

gradingform_guide_controller::get_definition_copy ( gradingform_controller  $target)

Returns the form definition suitable for cloning into another area.

See also
parent::get_definition_copy()
Parameters
gradingform_controller$targetthe controller of the new copy
Return values
stdClassdefinition structure to pass to the target's update_definition()

Reimplemented from gradingform_controller.

◆ get_definition_for_editing()

gradingform_guide_controller::get_definition_for_editing (   $addemptycriterion = false)

Converts the current definition into an object suitable for the editor form's set_data()

Parameters
bool$addemptycriterionwhether to add an empty criterion if the guide is completely empty (just being created)
Return values
stdClass

◆ get_editor_url()

gradingform_controller::get_editor_url ( moodle_url  $returnurl = null)
inherited

Returns URL of a page where the grading form can be defined and edited.

Parameters
moodle_url$returnurloptional URL of a page where the user should be sent once they are finished with editing
Return values
moodle_url

◆ get_external_definition_details()

static gradingform_guide_controller::get_external_definition_details ( )
static
Return values
arrayAn array containing 2 key/value pairs which hold the external_multiple_structure for the 'guide_criteria' and the 'guide_comments'.
See also
gradingform_controller::get_external_definition_details()
Since
Moodle 2.5

Reimplemented from gradingform_controller.

◆ get_external_instance_filling_details()

static gradingform_guide_controller::get_external_instance_filling_details ( )
static

Returns an array that defines the structure of the guide's filling.

This function is used by the web service function core_grading_external::get_gradingform_instances().

Return values
Anarray containing a single key/value pair with the 'criteria' external_multiple_structure
See also
gradingform_controller::get_external_instance_filling_details()
Since
Moodle 2.6

Reimplemented from gradingform_controller.

◆ get_formatted_description()

gradingform_guide_controller::get_formatted_description ( )

Formats the definition description for display on page.

Return values
string

Reimplemented from gradingform_controller.

◆ get_grade_range()

gradingform_controller::get_grade_range ( )
finalinherited

Returns the range of grades used in this area.

Return values
array

◆ get_instance()

gradingform_controller::get_instance (   $instance)
protectedinherited

Returns the object of type gradingform_XXX_instance (where XXX is the plugin method name)

Parameters
mixed$instanceid or row from grading_isntances table
Return values
gradingform_instance

◆ get_method_name()

gradingform_controller::get_method_name ( )
protectedinherited

Returns the name of the grading method plugin, eg 'rubric'.

Return values
stringthe name of the grading method plugin, eg 'rubric'
See also
PARAM_PLUGIN

◆ get_min_max_score()

gradingform_guide_controller::get_min_max_score ( )

Calculates and returns the possible minimum and maximum score (in points) for this guide.

Return values
array

◆ get_options()

gradingform_guide_controller::get_options ( )

Gets the options of this guide definition, fills the missing options with default values.

Return values
array

◆ get_or_create_instance()

gradingform_guide_controller::get_or_create_instance (   $instanceid,
  $raterid,
  $itemid 
)

If instanceid is specified and grading instance exists and it is created by this rater for this item, this instance is returned.

If there exists a draft for this raterid+itemid, take this draft (this is the change from parent) Otherwise new instance is created for the specified rater and itemid

Parameters
int$instanceid
int$raterid
int$itemid
Return values
gradingform_instance

Reimplemented from gradingform_controller.

◆ get_renderer()

gradingform_guide_controller::get_renderer ( moodle_page  $page)

Returns the guide plugin renderer.

Parameters
moodle_page$pagethe target page
Return values
gradingform_guide_renderer

◆ has_active_instances()

gradingform_controller::has_active_instances ( )
inherited

Returns true if there are already people who has been graded on this definition.

In this case plugins may restrict changes of the grading definition

Return values
boolean

◆ is_form_available()

gradingform_controller::is_form_available ( )
inherited

Is the grading form defined and ready for usage?

Return values
boolean

◆ is_form_defined()

gradingform_controller::is_form_defined ( )
inherited

Is the form definition record available?

Note that this actually checks whether the process of defining the form ever started and not whether the form definition should be considered as final.

Return values
boolean

◆ is_own_form()

gradingform_controller::is_own_form (   $userid = null)
inherited

Is the grading form owned by the given user?

The form owner is the user who created this instance of the form.

Parameters
int$useridthe user id to check, defaults to the current user
Return values
boolean|nullnull if the form not defined yet, boolean otherwise

◆ is_shared_template()

gradingform_controller::is_shared_template ( )
inherited

Is the grading form saved as a shared public template?

Return values
boolean

◆ load_definition()

gradingform_guide_controller::load_definition ( )
protected

Loads the guide form definition if it exists.

There is a new array called 'guide_criteria' appended to the list of parent's definition properties.

Reimplemented from gradingform_controller.

◆ render_grade()

gradingform_guide_controller::render_grade (   $page,
  $itemid,
  $gradinginfo,
  $defaultcontent,
  $cangrade 
)

Returns html code to be included in student's feedback.

Parameters
moodle_page$page
int$itemid
array$gradinginforesult of function grade_get_grades
string$defaultcontentdefault string to be returned if no active grading is found
bool$cangradewhether current user has capability to grade in this context
Return values
string

Reimplemented from gradingform_controller.

◆ render_preview()

gradingform_guide_controller::render_preview ( moodle_page  $page)

Returns the HTML code displaying the preview of the grading form.

Parameters
moodle_page$pagethe target page
Return values
string

Reimplemented from gradingform_controller.

◆ set_grade_range()

gradingform_controller::set_grade_range ( array  $graderange,
  $allowgradedecimals = false 
)
finalinherited

Sets the range of grades used in this area.

This is usually either range like 0-100 or the scale where keys start from 1.

Typically modules will call it: $controller->set_grade_range(make_grades_menu($gradingtype), $gradingtype > 0); Negative $gradingtype means that scale is used and the grade must be rounded to the nearest int. Positive $gradingtype means that range 0..$gradingtype is used for the grades and in this case grade does not have to be rounded.

Sometimes modules always expect grade to be rounded (like mod_assignment does).

Parameters
array$graderangearray where first key is the minimum grade and the last key is the maximum grade.
bool$allowgradedecimalsif decimal values are allowed as grades.

◆ sql_search_from_tables()

static gradingform_guide_controller::sql_search_from_tables (   $gdid)
static

Prepare the part of the search query to append to the FROM statement.

Parameters
string$gdidthe alias of grading_definitions.id column used by the caller
Return values
string

Reimplemented from gradingform_controller.

◆ sql_search_where()

static gradingform_guide_controller::sql_search_where (   $token)
static

Prepare the parts of the SQL WHERE statement to search for the given token.

The returned array cosists of the list of SQL comparions and the list of respective parameters for the comparisons. The returned chunks will be joined with other conditions using the OR operator.

Parameters
string$tokentoken to search for
Return values
arrayAn array containing two more arrays Array of search SQL fragments Array of params for the search fragments

Reimplemented from gradingform_controller.

◆ update_definition()

gradingform_guide_controller::update_definition ( stdClass  $newdefinition,
  $usermodified = null 
)

Saves the guide definition into the database.

See also
parent::update_definition()
Parameters
stdClass$newdefinitionguide definition data as coming from gradingform_guide_editguide::get_data()
int$usermodifiedoptional userid of the author of the definition, defaults to the current user

Reimplemented from gradingform_controller.

◆ update_or_check_guide()

gradingform_guide_controller::update_or_check_guide ( stdClass  $newdefinition,
  $usermodified = null,
  $doupdate = false 
)

Either saves the guide definition into the database or check if it has been changed.

Returns the level of changes: 0 - no changes 1 - only texts or criteria sortorders are changed, students probably do not require re-grading 2 - added levels but maximum score on guide is the same, students still may not require re-grading 3 - removed criteria or changed number of points, students require re-grading but may be re-graded automatically 4 - removed levels - students require re-grading and not all students may be re-graded automatically 5 - added criteria - all students require manual re-grading

Parameters
stdClass$newdefinitionguide definition data as coming from gradingform_guide_editguide::get_data()
int | null$usermodifiedoptional userid of the author of the definition, defaults to the current user
bool$doupdateif true actually updates DB, otherwise performs a check
Return values
int

Member Data Documentation

◆ DISPLAY_VIEW

const gradingform_guide_controller::DISPLAY_VIEW = 7

guide display mode: Dispaly filled guide (i.e.

students see their grades)


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