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.

Differences Between: [Versions 401 and 403]

This file contains the functions for assign_plugin abstract class

Copyright: 2012 NetSpot {@link http://www.netspot.com.au}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 705 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: assign_plugin  - X-Ref

Abstract class for assign_plugin (submission/feedback).

__construct(assign $assignment, $type)   X-Ref
Constructor for the abstract plugin type class

param: assign $assignment
param: string $type

is_first()   X-Ref
Is this the first plugin in the list?

return: bool

is_last()   X-Ref
Is this the last plugin in the list?

return: bool

get_settings(MoodleQuickForm $mform)   X-Ref
This function should be overridden to provide an array of elements that can be added to a moodle
form for display in the settings page for the assignment.

param: MoodleQuickForm $mform The form to add the elements to
return: $array

data_preprocessing(&$defaultvalues)   X-Ref
Allows the plugin to update the defaultvalues passed in to
the settings form (needed to set up draft areas for editor
and filemanager elements)

param: array $defaultvalues

save_settings(stdClass $formdata)   X-Ref
The assignment subtype is responsible for saving it's own settings as the database table for the
standard type cannot be modified.

param: stdClass $formdata - the data submitted from the form
return: bool - on error the subtype should call set_error and return false.

set_error($msg)   X-Ref
Save the error message from the last error

param: string $msg - the error description

get_error()   X-Ref
What was the last error?

return: string

get_type()   X-Ref
Should return the type of this plugin.

return: string - the type

get_version()   X-Ref
Get the installed version of this plugin

return: string

get_requires()   X-Ref
Get the required moodle version for this plugin

return: string

save(stdClass $submissionorgrade, stdClass $data)   X-Ref
Save any custom data for this form submission

param: stdClass $submissionorgrade - assign_submission or assign_grade.
param: stdClass $data - the data submitted from the form
return: bool - on error the subtype should call set_error and return false.

enable()   X-Ref
Set this plugin to enabled

return: bool

disable()   X-Ref
Set this plugin to disabled

return: bool

is_enabled()   X-Ref
Allows hiding this plugin from the submission/feedback screen if it is not enabled.

return: bool - if false - this plugin will not accept submissions / feedback

get_form_elements_for_user($submissionorgrade, MoodleQuickForm $mform, stdClass $data, $userid)   X-Ref
Get any additional fields for the submission/grading form for this assignment.

param: mixed $submissionorgrade submission|grade - For submission plugins this is the submission data,
param: MoodleQuickForm $mform - This is the form
param: stdClass $data - This is the form data that can be modified for example by a filemanager element
param: int $userid - This is the userid for the current submission.
return: boolean - true if we added anything to the form

get_form_elements($submissionorgrade, MoodleQuickForm $mform, stdClass $data)   X-Ref
Get any additional fields for the submission/grading form for this assignment.
This function is retained for backwards compatibility - new plugins should override {@link get_form_elements_for_user()}.

param: mixed $submissionorgrade submission|grade - For submission plugins this is the submission data,
param: MoodleQuickForm $mform - This is the form
param: stdClass $data - This is the form data that can be modified for example by a filemanager element
return: boolean - true if we added anything to the form

view(stdClass $submissionorgrade)   X-Ref
Should not output anything - return the result as a string so it can be consumed by webservices.

param: stdClass $submissionorgrade assign_submission or assign_grade
return: string - return a string representation of the submission in full

get_sort_order()   X-Ref
Get the numerical sort order for this plugin

return: int

is_visible()   X-Ref
Is this plugin enaled?

return: bool

has_admin_settings()   X-Ref
Has this plugin got a custom settings.php file?

return: bool

set_config($name, $value)   X-Ref
Set a configuration value for this plugin

param: string $name The config key
param: string $value The config value
return: bool

get_config($setting = null)   X-Ref
Get a configuration value for this plugin

param: mixed $setting The config key (string) or null
return: mixed string | false

get_config_file_areas()   X-Ref
Get a list of file areas associated with the plugin configuration.
This is used for backup/restore.

return: array names of the fileareas, can be an empty array

view_summary(stdClass $submissionorgrade, & $showviewlink)   X-Ref
Should not output anything - return the result as a string so it can be consumed by webservices.

param: stdClass $submissionorgrade assign_submission or assign_grade
param: bool $showviewlink Modifed to return whether or not to show a link to the full submission/feedback
return: string - return a string representation of the submission in full

set_editor_text($name, $value, $submissionorgradeid)   X-Ref
Given a field name and value should update the text for this field in the plugins submission or grade

param: string $name Name of the field.
param: string $value Updated text
param: int $submissionorgradeid The id of the submission or grade
return: bool - true if the value was updated

set_editor_format($name, $format, $submissionorgradeid)   X-Ref
Given a field name and value should update the format for this field in the plugins submission or grade

param: string $name Name of the field.
param: int $format Updated format.
param: int $submissionorgradeid The id of the submission or grade.
return: bool - true if the value was updated

get_editor_fields()   X-Ref
Return a list of the fields that can be exported or imported via text.

return: array - The list of field names (strings) and descriptions. ($name => $description)

get_editor_text($name, $submissionorgradeid)   X-Ref
Given a field name, should return the text of an editor field that is part of
this plugin. This is used when exporting to portfolio.

param: string $name Name of the field.
param: int $submissionorgradeid The id of the submission or grade
return: string - The text for the editor field

get_files(stdClass $submissionorgrade, stdClass $user)   X-Ref
Produce a list of files suitable for export that represent this feedback or submission

param: stdClass $submissionorgrade assign_submission or assign_grade
param: stdClass $user The user record for the current submission.
return: array - return an array of files indexed by filename

get_editor_format($name, $submissionid)   X-Ref
Given a field name, should return the format of an editor field that is part of
this plugin. This is used when exporting to portfolio.

param: string $name Name of the field.
param: int $submissionid The id of the submission
return: int - The format for the editor field

can_upgrade($type, $version)   X-Ref
Return true if this plugin can upgrade an old Moodle 2.2 assignment of this type
and version.

param: string $type The old assignment subtype
param: int $version The old assignment version
return: bool True if upgrade is possible

upgrade_settings(context $oldcontext, stdClass $oldassignment, & $log)   X-Ref
Upgrade the settings from the old assignment to the new one

param: context $oldcontext The context for the old assignment module
param: stdClass $oldassignment The data record for the old assignment
param: string $log Record upgrade messages in the log
return: bool true or false - false will trigger a rollback

upgrade(context $oldcontext,stdClass $oldassignment,stdClass $oldsubmissionorgrade,stdClass $submissionorgrade,& $log)   X-Ref
Upgrade the submission from the old assignment to the new one

param: context $oldcontext The data record for the old context
param: stdClass $oldassignment The data record for the old assignment
param: stdClass $oldsubmissionorgrade The data record for the old submission
param: stdClass $submissionorgrade assign_submission or assign_grade The new submission or grade
param: string $log Record upgrade messages in the log
return: boolean true or false - false will trigger a rollback

format_for_log(stdClass $submissionorgrade)   X-Ref
Formatting for log info

param: stdClass $submissionorgrade assign_submission or assign_grade The new submission or grade
return: string

delete_instance()   X-Ref
The assignment has been deleted - remove the plugin specific data

return: bool

cron()   X-Ref
Run cron for this plugin


is_empty(stdClass $submissionorgrade)   X-Ref
Is this assignment plugin empty? (ie no submission or feedback)

param: stdClass $submissionorgrade assign_submission or assign_grade
return: bool

get_file_areas()   X-Ref
Get file areas returns a list of areas this plugin stores files

return: array - An array of fileareas (keys) and descriptions (values)

get_file_info($browser, $filearea, $itemid, $filepath, $filename)   X-Ref
Default implementation of file_get_info for plugins.
This is used by the filebrowser to browse a plugins file areas.

This implementation should work for most plugins but can be overridden if required.
param: file_browser $browser
param: string $filearea
param: int $itemid
param: string $filepath
param: string $filename
return: file_info_stored

view_page($action)   X-Ref
This allows a plugin to render a page in the context of the assignment

If the plugin creates a link to the assignment view.php page with
The following required parameters:
id=coursemoduleid
plugin=type
pluginsubtype=assignfeedback|assignsubmission
pluginaction=customaction

Then this function will be called to display the page with the pluginaction passed as action
param: string $action The plugin specified action
return: string

view_header()   X-Ref
This allows a plugin to render an introductory section which is displayed
right below the activity's "intro" section on the main assignment page.

return: string

has_user_summary()   X-Ref
If this plugin should not include a column in the grading table or a row on the summary page
then return false

return: bool

get_external_parameters()   X-Ref
If this plugin can participate in a webservice (save_submission or save_grade),
return a list of external_params to be included in the definition of that webservice.

return: external_description|null

is_configurable()   X-Ref
If true, the plugin will appear on the module settings page and can be
enabled/disabled per assignment instance.

return: bool

get_config_for_external()   X-Ref
Return the plugin configs for external functions,
in some cases the configs will need formatting or be returned only if the current user has some capabilities enabled.

return: array the list of settings