Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
assign_plugin Class Reference

Abstract class for assign_plugin (submission/feedback). More...

Inheritance diagram for assign_plugin:
assign_feedback_plugin assign_submission_plugin assign_feedback_comments assign_feedback_editpdf assign_feedback_file assign_feedback_offline assign_submission_comments assign_submission_file assign_submission_onlinetext

Public Member Functions

 __construct (assign $assignment, $type)
 Constructor for the abstract plugin type class.
 
 can_upgrade ($type, $version)
 Return true if this plugin can upgrade an old Moodle 2.2 assignment of this type and version.
 
 data_preprocessing (&$defaultvalues)
 Allows the plugin to update the defaultvalues passed in to the settings form (needed to set up draft areas for editor and filemanager elements)
 
 delete_instance ()
 The assignment has been deleted - remove the plugin specific data.
 
 disable ()
 Set this plugin to disabled.
 
 enable ()
 Set this plugin to enabled.
 
 format_for_log ()
 
 get_config ($setting=null)
 Get a configuration value for this plugin.
 
 get_config_file_areas ()
 Get a list of file areas associated with the plugin configuration.
 
 get_config_for_external ()
 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.
 
 get_editor_fields ()
 Return a list of the fields that can be exported or imported via text.
 
 get_editor_format ($name, $submissionid)
 Given a field name, should return the format of an editor field that is part of this plugin.
 
 get_editor_text ($name, $submissionorgradeid)
 Given a field name, should return the text of an editor field that is part of this plugin.
 
 get_error ()
 What was the last error?
 
 get_external_parameters ()
 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.
 
 get_file_areas ()
 Get file areas returns a list of areas this plugin stores files.
 
 get_file_info ($browser, $filearea, $itemid, $filepath, $filename)
 Default implementation of file_get_info for plugins.
 
 get_files (stdClass $submissionorgrade, stdClass $user)
 Produce a list of files suitable for export that represent this feedback or submission.
 
 get_form_elements ($submissionorgrade, MoodleQuickForm $mform, stdClass $data)
 Get any additional fields for the submission/grading form for this assignment.
 
 get_form_elements_for_user ($submissionorgrade, MoodleQuickForm $mform, stdClass $data, $userid)
 Get any additional fields for the submission/grading form for this assignment.
 
 get_name ()
 Should return the name of this plugin type.
 
 get_requires ()
 Get the required moodle version for this plugin.
 
 get_settings (MoodleQuickForm $mform)
 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.
 
 get_sort_order ()
 Get the numerical sort order for this plugin.
 
 get_subtype ()
 Should return the subtype of this plugin.
 
 get_type ()
 Should return the type of this plugin.
 
 get_version ()
 Get the installed version of this plugin.
 
 has_admin_settings ()
 Has this plugin got a custom settings.php file?
 
 has_user_summary ()
 If this plugin should not include a column in the grading table or a row on the summary page then return false.
 
 is_configurable ()
 If true, the plugin will appear on the module settings page and can be enabled/disabled per assignment instance.
 
 is_empty (stdClass $submissionorgrade)
 Is this assignment plugin empty? (ie no submission or feedback)
 
 is_enabled ()
 Allows hiding this plugin from the submission/feedback screen if it is not enabled.
 
 is_first ()
 Is this the first plugin in the list?
 
 is_last ()
 Is this the last plugin in the list?
 
 is_visible ()
 Is this plugin enaled?
 
 save (stdClass $submissionorgrade, stdClass $data)
 Save any custom data for this form submission.
 
 save_settings (stdClass $formdata)
 The assignment subtype is responsible for saving it's own settings as the database table for the standard type cannot be modified.
 
 set_config ($name, $value)
 Set a configuration value for this plugin.
 
 set_editor_format ($name, $format, $submissionorgradeid)
 Given a field name and value should update the format for this field in the plugins submission or grade.
 
 set_editor_text ($name, $value, $submissionorgradeid)
 Given a field name and value should update the text for this field in the plugins submission or grade.
 
 upgrade (context $oldcontext, stdClass $oldassignment, stdClass $oldsubmissionorgrade, stdClass $submissionorgrade, & $log)
 Upgrade the submission from the old assignment to the new one.
 
 upgrade_settings (context $oldcontext, stdClass $oldassignment, & $log)
 Upgrade the settings from the old assignment to the new one.
 
 view (stdClass $submissionorgrade)
 Should not output anything - return the result as a string so it can be consumed by webservices.
 
 view_header ()
 This allows a plugin to render an introductory section which is displayed right below the activity's "intro" section on the main assignment page.
 
 view_page ($action)
 This allows a plugin to render a page in the context of the assignment.
 
 view_summary (stdClass $submissionorgrade, & $showviewlink)
 Should not output anything - return the result as a string so it can be consumed by webservices.
 

Static Public Member Functions

static cron ()
 Run cron for this plugin.
 

Protected Member Functions

 set_error ($msg)
 Save the error message from the last error.
 

Protected Attributes

assign $assignment
 $assignment the assignment record that contains the global settings for this assign instance
 

Detailed Description

Abstract class for assign_plugin (submission/feedback).

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

Constructor & Destructor Documentation

◆ __construct()

assign_plugin::__construct ( assign $assignment,
$type )
final

Constructor for the abstract plugin type class.

Parameters
assign$assignment
string$type

Member Function Documentation

◆ can_upgrade()

assign_plugin::can_upgrade ( $type,
$version )

Return true if this plugin can upgrade an old Moodle 2.2 assignment of this type and version.

Parameters
string$typeThe old assignment subtype
int$versionThe old assignment version
Return values
boolTrue if upgrade is possible

Reimplemented in assign_feedback_comments, assign_feedback_file, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.

◆ data_preprocessing()

assign_plugin::data_preprocessing ( & $defaultvalues)

Allows the plugin to update the defaultvalues passed in to the settings form (needed to set up draft areas for editor and filemanager elements)

Parameters
array$defaultvalues

◆ delete_instance()

assign_plugin::delete_instance ( )

The assignment has been deleted - remove the plugin specific data.

Return values
bool

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_submission_file, and assign_submission_onlinetext.

◆ disable()

assign_plugin::disable ( )
final

Set this plugin to disabled.

Return values
bool

◆ enable()

assign_plugin::enable ( )
final

Set this plugin to enabled.

Return values
bool

◆ format_for_log()

assign_plugin::format_for_log ( )
Deprecated
since 2.7

◆ get_config()

assign_plugin::get_config ( $setting = null)
final

Get a configuration value for this plugin.

Parameters
mixed$settingThe config key (string) or null
Return values
mixedstring | false

◆ get_config_file_areas()

assign_plugin::get_config_file_areas ( )

Get a list of file areas associated with the plugin configuration.

This is used for backup/restore.

Return values
arraynames of the fileareas, can be an empty array

◆ get_config_for_external()

assign_plugin::get_config_for_external ( )

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 values
arraythe list of settings
Since
Moodle 3.2

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_feedback_offline, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.

◆ get_editor_fields()

assign_plugin::get_editor_fields ( )

Return a list of the fields that can be exported or imported via text.

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

Reimplemented in assign_feedback_comments, and assign_submission_onlinetext.

◆ get_editor_format()

assign_plugin::get_editor_format ( $name,
$submissionid )

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.

Parameters
string$nameName of the field.
int$submissionidThe id of the submission
Return values
int- The format for the editor field

Reimplemented in assign_submission_onlinetext.

◆ get_editor_text()

assign_plugin::get_editor_text ( $name,
$submissionorgradeid )

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.

Parameters
string$nameName of the field.
int$submissionorgradeidThe id of the submission or grade
Return values
string- The text for the editor field

Reimplemented in assign_feedback_comments, and assign_submission_onlinetext.

◆ get_error()

assign_plugin::get_error ( )
final

What was the last error?

Return values
string

◆ get_external_parameters()

assign_plugin::get_external_parameters ( )

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 values
external_description|null

Reimplemented in assign_feedback_comments, assign_feedback_file, assign_submission_file, and assign_submission_onlinetext.

◆ get_file_areas()

assign_plugin::get_file_areas ( )

Get file areas returns a list of areas this plugin stores files.

Return values
array- An array of fileareas (keys) and descriptions (values)

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_submission_file, and assign_submission_onlinetext.

◆ get_file_info()

assign_plugin::get_file_info ( $browser,
$filearea,
$itemid,
$filepath,
$filename )

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.

Parameters
file_browser$browser
string$filearea
int$itemid
string$filepath
string$filename
Return values
file_info_stored

◆ get_files()

assign_plugin::get_files ( stdClass $submissionorgrade,
stdClass $user )

Produce a list of files suitable for export that represent this feedback or submission.

Parameters
stdClass$submissionorgradeassign_submission or assign_grade For submission plugins this is the submission data, for feedback plugins it is the grade data
stdClass$userThe user record for the current submission. Needed for url rewriting if this is a group submission.
Return values
array- return an array of files indexed by filename

Reimplemented in assign_submission_file, and assign_submission_onlinetext.

◆ get_form_elements()

assign_plugin::get_form_elements ( $submissionorgrade,
MoodleQuickForm $mform,
stdClass $data )

Get any additional fields for the submission/grading form for this assignment.

This function is retained for backwards compatibility - new plugins should override get_form_elements_for_user().

Parameters
mixed$submissionorgradesubmission|grade - For submission plugins this is the submission data, for feedback plugins it is the grade data
MoodleQuickForm$mform- This is the form
stdClass$data- This is the form data that can be modified for example by a filemanager element
Return values
boolean- true if we added anything to the form

Reimplemented in assign_feedback_offline, assign_submission_file, and assign_submission_onlinetext.

◆ get_form_elements_for_user()

assign_plugin::get_form_elements_for_user ( $submissionorgrade,
MoodleQuickForm $mform,
stdClass $data,
$userid )

Get any additional fields for the submission/grading form for this assignment.

Parameters
mixed$submissionorgradesubmission|grade - For submission plugins this is the submission data, for feedback plugins it is the grade data
MoodleQuickForm$mform- This is the form
stdClass$data- This is the form data that can be modified for example by a filemanager element
int$userid- This is the userid for the current submission. This is passed separately as there may not yet be a submission or grade.
Return values
boolean- true if we added anything to the form

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, and assign_feedback_file.

◆ get_name()

assign_plugin::get_name ( )
abstract

Should return the name of this plugin type.

Return values
string- the name

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_feedback_offline, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.

◆ get_requires()

assign_plugin::get_requires ( )
final

Get the required moodle version for this plugin.

Return values
string

◆ get_settings()

assign_plugin::get_settings ( MoodleQuickForm $mform)

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.

Parameters
MoodleQuickForm$mformThe form to add the elements to
Return values
$array

Reimplemented in assign_feedback_comments, assign_submission_file, and assign_submission_onlinetext.

◆ get_sort_order()

assign_plugin::get_sort_order ( )
final

Get the numerical sort order for this plugin.

Return values
int

◆ get_subtype()

assign_plugin::get_subtype ( )
abstract

Should return the subtype of this plugin.

Return values
string- either 'assignsubmission' or 'feedback'

Reimplemented in assign_feedback_plugin, and assign_submission_plugin.

◆ get_type()

assign_plugin::get_type ( )
final

Should return the type of this plugin.

Return values
string- the type

◆ get_version()

assign_plugin::get_version ( )
final

Get the installed version of this plugin.

Return values
string

◆ has_admin_settings()

assign_plugin::has_admin_settings ( )
final

Has this plugin got a custom settings.php file?

Return values
bool

◆ has_user_summary()

assign_plugin::has_user_summary ( )

If this plugin should not include a column in the grading table or a row on the summary page then return false.

Return values
bool

Reimplemented in assign_feedback_offline.

◆ is_configurable()

assign_plugin::is_configurable ( )

If true, the plugin will appear on the module settings page and can be enabled/disabled per assignment instance.

Return values
bool

Reimplemented in assign_feedback_editpdf, and assign_submission_comments.

◆ is_empty()

assign_plugin::is_empty ( stdClass $submissionorgrade)

Is this assignment plugin empty? (ie no submission or feedback)

Parameters
stdClass$submissionorgradeassign_submission or assign_grade
Return values
bool

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_feedback_offline, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.

◆ is_enabled()

assign_plugin::is_enabled ( )

Allows hiding this plugin from the submission/feedback screen if it is not enabled.

Return values
bool- if false - this plugin will not accept submissions / feedback

Reimplemented in assign_feedback_offline, and assign_submission_comments.

◆ is_first()

assign_plugin::is_first ( )
final

Is this the first plugin in the list?

Return values
bool

◆ is_last()

assign_plugin::is_last ( )
final

Is this the last plugin in the list?

Return values
bool

◆ is_visible()

assign_plugin::is_visible ( )
final

Is this plugin enaled?

Return values
bool

◆ save()

assign_plugin::save ( stdClass $submissionorgrade,
stdClass $data )

Save any custom data for this form submission.

Parameters
stdClass$submissionorgrade- assign_submission or assign_grade. For submission plugins this is the submission data, for feedback plugins it is the grade data
stdClass$data- the data submitted from the form
Return values
bool- on error the subtype should call set_error and return false.

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_submission_file, and assign_submission_onlinetext.

◆ save_settings()

assign_plugin::save_settings ( stdClass $formdata)

The assignment subtype is responsible for saving it's own settings as the database table for the standard type cannot be modified.

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

Reimplemented in assign_feedback_comments, assign_submission_file, and assign_submission_onlinetext.

◆ set_config()

assign_plugin::set_config ( $name,
$value )
final

Set a configuration value for this plugin.

Parameters
string$nameThe config key
string$valueThe config value
Return values
bool

◆ set_editor_format()

assign_plugin::set_editor_format ( $name,
$format,
$submissionorgradeid )

Given a field name and value should update the format for this field in the plugins submission or grade.

Parameters
string$nameName of the field.
int$formatUpdated format.
int$submissionorgradeidThe id of the submission or grade.
Return values
bool- true if the value was updated

◆ set_editor_text()

assign_plugin::set_editor_text ( $name,
$value,
$submissionorgradeid )

Given a field name and value should update the text for this field in the plugins submission or grade.

Parameters
string$nameName of the field.
string$valueUpdated text
int$submissionorgradeidThe id of the submission or grade
Return values
bool- true if the value was updated

Reimplemented in assign_feedback_comments.

◆ set_error()

assign_plugin::set_error ( $msg)
finalprotected

Save the error message from the last error.

Parameters
string$msg- the error description

◆ upgrade()

assign_plugin::upgrade ( context $oldcontext,
stdClass $oldassignment,
stdClass $oldsubmissionorgrade,
stdClass $submissionorgrade,
& $log )

Upgrade the submission from the old assignment to the new one.

Parameters
context$oldcontextThe data record for the old context
stdClass$oldassignmentThe data record for the old assignment
stdClass$oldsubmissionorgradeThe data record for the old submission
stdClass$submissionorgradeassign_submission or assign_grade The new submission or grade
string$logRecord upgrade messages in the log
Return values
booleantrue or false - false will trigger a rollback

Reimplemented in assign_feedback_comments, assign_feedback_file, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.

◆ upgrade_settings()

assign_plugin::upgrade_settings ( context $oldcontext,
stdClass $oldassignment,
& $log )

Upgrade the settings from the old assignment to the new one.

Parameters
context$oldcontextThe context for the old assignment module
stdClass$oldassignmentThe data record for the old assignment
string$logRecord upgrade messages in the log
Return values
booltrue or false - false will trigger a rollback

Reimplemented in assign_feedback_comments, assign_feedback_file, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.

◆ view()

assign_plugin::view ( stdClass $submissionorgrade)

Should not output anything - return the result as a string so it can be consumed by webservices.

Parameters
stdClass$submissionorgradeassign_submission or assign_grade For submission plugins this is the submission data, for feedback plugins it is the grade data
Return values
string- return a string representation of the submission in full

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_submission_file, and assign_submission_onlinetext.

◆ view_header()

assign_plugin::view_header ( )

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 values
string

◆ view_page()

assign_plugin::view_page ( $action)

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

Parameters
string$actionThe plugin specified action
Return values
string

Reimplemented in assign_feedback_file, and assign_feedback_offline.

◆ view_summary()

assign_plugin::view_summary ( stdClass $submissionorgrade,
& $showviewlink )

Should not output anything - return the result as a string so it can be consumed by webservices.

Parameters
stdClass$submissionorgradeassign_submission or assign_grade For submission plugins this is the submission data, for feedback plugins it is the grade data
bool$showviewlinkModifed to return whether or not to show a link to the full submission/feedback
Return values
string- return a string representation of the submission in full

Reimplemented in assign_feedback_comments, assign_feedback_editpdf, assign_feedback_file, assign_submission_comments, assign_submission_file, and assign_submission_onlinetext.


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