Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
assign_feedback_file Class Reference

Library class for file feedback plugin extending feedback plugin base class. More...

Inheritance diagram for assign_feedback_file:
assign_feedback_plugin assign_plugin

Public Member Functions

 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 - cleanup.
 
 disable ()
 Set this plugin to disabled.
 
 enable ()
 Set this plugin to enabled.
 
 files_for_gradebook (stdClass $grade)
 Return any files this plugin wishes to save to the gradebook.
 
 format_for_gradebook (stdClass $grade)
 If this plugin adds to the gradebook comments field, it must specify the format of the comment.
 
 format_for_log (stdClass $submissionorgrade)
 Formatting for log info.
 
 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.
 
 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 ()
 Return a description of external params suitable for uploading a feedback file from a webservice.
 
 get_file_areas ()
 Get file areas returns a list of areas this plugin stores files.
 
 get_file_feedback ($gradeid)
 Get file feedback information from the database.
 
 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 ($grade, MoodleQuickForm $mform, stdClass $data, $userid)
 Get form elements for grading form.
 
 get_grading_actions ()
 Return a list of the grading actions performed by this plugin.
 
 get_grading_batch_operations ()
 Return a list of the batch grading operations performed by this plugin.
 
 get_name ()
 Get the name of the file feedback plugin.
 
 get_quickgrading_html ($userid, $grade)
 Get quickgrading form elements as html.
 
 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 ()
 Return subtype name of the plugin.
 
 get_type ()
 Should return the type of this plugin.
 
 get_version ()
 Get the installed version of this plugin.
 
 grading_action ($gradingaction)
 Show a grading action form.
 
 grading_batch_operation ($action, $users)
 User has chosen a custom grading batch operation and selected some users.
 
 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 $grade)
 Return true if there are no feedback files.
 
 is_enabled ()
 Allows hiding this plugin from the submission/feedback screen if it is not enabled.
 
 is_feedback_modified (stdClass $grade, stdClass $data)
 Has the feedback file been modified?
 
 is_first ()
 Is this the first plugin in the list?
 
 is_last ()
 Is this the last plugin in the list?
 
 is_quickgrading_modified ($userid, $grade)
 Has the plugin quickgrading form element been modified in the current form submission?
 
 is_visible ()
 Is this plugin enaled?
 
 save (stdClass $grade, stdClass $data)
 Save the feedback files.
 
 save_quickgrading_changes ($userid, $grade)
 Save quickgrading changes.
 
 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.
 
 supports_quickgrading ()
 Override to indicate a plugin supports quickgrading.
 
 supports_review_panel ()
 Supports injecting content into the review panel of the grading app.
 
 text_for_gradebook (stdClass $grade)
 If this plugin adds to the gradebook comments field, it must format the text of the comment.
 
 update_file_count ($grade)
 Update the number of files in the file area.
 
 upgrade (context $oldcontext, stdClass $oldassignment, stdClass $oldsubmission, stdClass $grade, & $log)
 Upgrade the feedback 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 plugin based one.
 
 view (stdClass $grade)
 Display the list of files in the feedback status table.
 
 view_batch_upload_files ($users)
 Upload files and send them to multiple users.
 
 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)
 Called by the assignment module when someone chooses something from the grading navigation or batch operations list.
 
 view_summary (stdClass $grade, & $showviewlink)
 Display the list of files in the feedback status table.
 
 view_upload_zip ()
 View the upload zip form.
 

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

Library class for file feedback plugin extending feedback plugin base class.

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

Member Function Documentation

◆ can_upgrade()

assign_feedback_file::can_upgrade ( $type,
$version )

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

Parameters
string$typeold assignment subtype
int$versionold assignment version
Return values
boolTrue if upgrade is possible

Reimplemented from assign_plugin.

◆ data_preprocessing()

assign_plugin::data_preprocessing ( & $defaultvalues)
inherited

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_feedback_file::delete_instance ( )

The assignment has been deleted - cleanup.

Return values
bool

Reimplemented from assign_plugin.

◆ disable()

assign_plugin::disable ( )
finalinherited

Set this plugin to disabled.

Return values
bool

◆ enable()

assign_plugin::enable ( )
finalinherited

Set this plugin to enabled.

Return values
bool

◆ files_for_gradebook()

assign_feedback_plugin::files_for_gradebook ( stdClass $grade)
inherited

Return any files this plugin wishes to save to the gradebook.

The array being returned should contain the necessary information to identify and copy the files.

eg.

[ 'contextid' => $modulecontext->id, 'component' => ASSIGNFEEDBACK_XYZ_COMPONENT, 'filearea' => ASSIGNFEEDBACK_XYZ_FILEAREA, 'itemid' => $grade->id ]

Parameters
stdClass$gradeThe assign_grades object from the db
Return values
array

Reimplemented in assign_feedback_comments.

◆ format_for_gradebook()

assign_feedback_plugin::format_for_gradebook ( stdClass $grade)
inherited

If this plugin adds to the gradebook comments field, it must specify the format of the comment.

(From weblib.php) define('FORMAT_MOODLE', '0'); // Does all sorts of transformations and filtering define('FORMAT_HTML', '1'); // Plain HTML (with some tags stripped) define('FORMAT_PLAIN', '2'); // Plain text (even tags are printed in full) define('FORMAT_WIKI', '3'); // Wiki-formatted text define('FORMAT_MARKDOWN', '4'); // Markdown-formatted

Only one feedback plugin can push comments to the gradebook and that is chosen by the assignment settings page.

Parameters
stdClass$gradeThe grade
Return values
int

Reimplemented in assign_feedback_comments.

◆ format_for_log()

assign_plugin::format_for_log ( stdClass $submissionorgrade)
inherited

Formatting for log info.

Parameters
stdClass$submissionorgradeassign_submission or assign_grade The new submission or grade
Return values
string

Reimplemented in assign_submission_file, and assign_submission_onlinetext.

◆ get_config()

assign_plugin::get_config ( $setting = null)
finalinherited

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 ( )
inherited

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_feedback_file::get_config_for_external ( )

Return the plugin configs for external functions.

Return values
arraythe list of settings
Since
Moodle 3.2

Reimplemented from assign_plugin.

◆ get_editor_fields()

assign_plugin::get_editor_fields ( )
inherited

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 )
inherited

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 )
inherited

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 ( )
finalinherited

What was the last error?

Return values
string

◆ get_external_parameters()

assign_feedback_file::get_external_parameters ( )

Return a description of external params suitable for uploading a feedback file from a webservice.

Return values
core_external\external_description|null

Reimplemented from assign_plugin.

◆ get_file_areas()

assign_feedback_file::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 from assign_plugin.

◆ get_file_feedback()

assign_feedback_file::get_file_feedback ( $gradeid)

Get file feedback information from the database.

Parameters
int$gradeid
Return values
mixed

◆ get_file_info()

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

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 )
inherited

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 )
inherited

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_feedback_file::get_form_elements_for_user ( $grade,
MoodleQuickForm $mform,
stdClass $data,
$userid )

Get form elements for grading form.

Parameters
stdClass$grade
MoodleQuickForm$mform
stdClass$data
int$useridThe userid we are currently grading
Return values
booltrue if elements were added to the form

Reimplemented from assign_plugin.

◆ get_grading_actions()

assign_feedback_file::get_grading_actions ( )

Return a list of the grading actions performed by this plugin.

This plugin supports upload zip.

Return values
arrayThe list of grading actions

Reimplemented from assign_feedback_plugin.

◆ get_grading_batch_operations()

assign_feedback_file::get_grading_batch_operations ( )

Return a list of the batch grading operations performed by this plugin.

This plugin supports batch upload files and upload zip.

Return values
arrayThe list of batch grading operations

Reimplemented from assign_feedback_plugin.

◆ get_name()

assign_feedback_file::get_name ( )

Get the name of the file feedback plugin.

Return values
string

Reimplemented from assign_plugin.

◆ get_quickgrading_html()

assign_feedback_plugin::get_quickgrading_html ( $userid,
$grade )
inherited

Get quickgrading form elements as html.

Parameters
int$useridThe user id in the table this quickgrading element relates to
mixed$gradegrade or null - The grade data. May be null if there are no grades for this user (yet)
Return values
mixed- A html string containing the html form elements required for quickgrading or false to indicate this plugin does not support quickgrading

Reimplemented in assign_feedback_comments.

◆ get_requires()

assign_plugin::get_requires ( )
finalinherited

Get the required moodle version for this plugin.

Return values
string

◆ get_settings()

assign_plugin::get_settings ( MoodleQuickForm $mform)
inherited

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 ( )
finalinherited

Get the numerical sort order for this plugin.

Return values
int

◆ get_subtype()

assign_feedback_plugin::get_subtype ( )
inherited

Return subtype name of the plugin.

Return values
string

Reimplemented from assign_plugin.

◆ get_type()

assign_plugin::get_type ( )
finalinherited

Should return the type of this plugin.

Return values
string- the type

◆ get_version()

assign_plugin::get_version ( )
finalinherited

Get the installed version of this plugin.

Return values
string

◆ grading_action()

assign_feedback_plugin::grading_action ( $gradingaction)
inherited

Show a grading action form.

Parameters
string$gradingactionThe action chosen from the grading actions menu
Return values
stringThe page containing the form

◆ grading_batch_operation()

assign_feedback_file::grading_batch_operation ( $action,
$users )

User has chosen a custom grading batch operation and selected some users.

Parameters
string$action- The chosen action
array$users- An array of user ids
Return values
string- The response html

Reimplemented from assign_feedback_plugin.

◆ has_admin_settings()

assign_plugin::has_admin_settings ( )
finalinherited

Has this plugin got a custom settings.php file?

Return values
bool

◆ has_user_summary()

assign_plugin::has_user_summary ( )
inherited

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 ( )
inherited

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_feedback_file::is_empty ( stdClass $grade)

Return true if there are no feedback files.

Parameters
stdClass$grade

Reimplemented from assign_plugin.

◆ is_enabled()

assign_plugin::is_enabled ( )
inherited

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_feedback_modified()

assign_feedback_file::is_feedback_modified ( stdClass $grade,
stdClass $data )

Has the feedback file been modified?

Parameters
stdClass$gradeGrade object.
stdClass$dataForm data.
Return values
booleanTrue if the file area has been modified, else false.

Reimplemented from assign_feedback_plugin.

◆ is_first()

assign_plugin::is_first ( )
finalinherited

Is this the first plugin in the list?

Return values
bool

◆ is_last()

assign_plugin::is_last ( )
finalinherited

Is this the last plugin in the list?

Return values
bool

◆ is_quickgrading_modified()

assign_feedback_plugin::is_quickgrading_modified ( $userid,
$grade )
inherited

Has the plugin quickgrading form element been modified in the current form submission?

Parameters
int$useridThe user id in the table this quickgrading element relates to
stdClass$gradeThe grade
Return values
boolean- true if the quickgrading form element has been modified

Reimplemented in assign_feedback_comments.

◆ is_visible()

assign_plugin::is_visible ( )
finalinherited

Is this plugin enaled?

Return values
bool

◆ save()

assign_feedback_file::save ( stdClass $grade,
stdClass $data )

Save the feedback files.

Parameters
stdClass$grade
stdClass$data
Return values
bool

Reimplemented from assign_plugin.

◆ save_quickgrading_changes()

assign_feedback_plugin::save_quickgrading_changes ( $userid,
$grade )
inherited

Save quickgrading changes.

Parameters
int$useridThe user id in the table this quickgrading element relates to
stdClass$gradeThe grade
Return values
boolean- true if the grade changes were saved correctly

Reimplemented in assign_feedback_comments.

◆ save_settings()

assign_plugin::save_settings ( stdClass $formdata)
inherited

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 )
finalinherited

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 )
inherited

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 )
inherited

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)
finalprotectedinherited

Save the error message from the last error.

Parameters
string$msg- the error description

◆ supports_quickgrading()

assign_feedback_plugin::supports_quickgrading ( )
inherited

Override to indicate a plugin supports quickgrading.

Return values
boolean- True if the plugin supports quickgrading

Reimplemented in assign_feedback_comments.

◆ supports_review_panel()

assign_feedback_plugin::supports_review_panel ( )
inherited

Supports injecting content into the review panel of the grading app.

Return values
boolTrue if this plugin will add content to the review panel of the grading app.

Reimplemented in assign_feedback_editpdf.

◆ text_for_gradebook()

assign_feedback_plugin::text_for_gradebook ( stdClass $grade)
inherited

If this plugin adds to the gradebook comments field, it must format the text of the comment.

Only one feedback plugin can push comments to the gradebook and that is chosen by the assignment settings page.

Parameters
stdClass$gradeThe grade
Return values
string

Reimplemented in assign_feedback_comments.

◆ update_file_count()

assign_feedback_file::update_file_count ( $grade)

Update the number of files in the file area.

Parameters
stdClass$gradeThe grade record
Return values
bool- true if the value was saved

◆ upgrade()

assign_feedback_file::upgrade ( context $oldcontext,
stdClass $oldassignment,
stdClass $oldsubmission,
stdClass $grade,
& $log )

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

Parameters
context$oldcontext- the database for the old assignment context
stdClass$oldassignmentThe data record for the old assignment
stdClass$oldsubmissionThe data record for the old submission
stdClass$gradeThe data record for the new grade
string$logRecord upgrade messages in the log
Return values
booltrue or false - false will trigger a rollback

Reimplemented from assign_plugin.

◆ upgrade_settings()

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

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

Parameters
context$oldcontext- the context for the old assignment
stdClass$oldassignment- the data for the old assignment
string$log- can be appended to by the upgrade
Return values
boolwas it a success? (false will trigger a rollback)

Reimplemented from assign_plugin.

◆ view()

assign_feedback_file::view ( stdClass $grade)

Display the list of files in the feedback status table.

Parameters
stdClass$grade
Return values
string

Reimplemented from assign_plugin.

◆ view_batch_upload_files()

assign_feedback_file::view_batch_upload_files ( $users)

Upload files and send them to multiple users.

Parameters
array$users- An array of user ids
Return values
string- The response html

◆ view_header()

assign_plugin::view_header ( )
inherited

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_feedback_file::view_page ( $action)

Called by the assignment module when someone chooses something from the grading navigation or batch operations list.

Parameters
string$action- The page to view
Return values
string- The html response

Reimplemented from assign_plugin.

◆ view_summary()

assign_feedback_file::view_summary ( stdClass $grade,
& $showviewlink )

Display the list of files in the feedback status table.

Parameters
stdClass$grade
bool$showviewlink- Set to true to show a link to see the full list of files
Return values
string

Reimplemented from assign_plugin.

◆ view_upload_zip()

assign_feedback_file::view_upload_zip ( )

View the upload zip form.

Return values
string- The html response

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