Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

This file contains the definition for the library class for onlinetext submission plugin This class provides all the functionality for the new assign module.

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

Defines 1 class


Class: assign_submission_onlinetext  - X-Ref

library class for onlinetext submission plugin extending submission plugin base class

get_name()   X-Ref
Get the name of the online text submission plugin

return: string

get_onlinetext_submission($submissionid)   X-Ref
Get onlinetext submission information from the database

return: mixed
param: int $submissionid

remove(stdClass $submission)   X-Ref
Remove a submission.

return: boolean
param: stdClass $submission The submission

get_settings(MoodleQuickForm $mform)   X-Ref
Get the settings for onlinetext submission plugin

return: void
param: MoodleQuickForm $mform The form to add elements to

save_settings(stdClass $data)   X-Ref
Save the settings for onlinetext submission plugin

return: bool
param: stdClass $data

get_form_elements($submission, MoodleQuickForm $mform, stdClass $data)   X-Ref
Add form elements for settings

return: true if elements were added to the form
param: mixed $submission can be null
param: MoodleQuickForm $mform
param: stdClass $data

get_edit_options()   X-Ref
Editor format options

return: array

save(stdClass $submission, stdClass $data)   X-Ref
Save data to the database and trigger plagiarism plugin,
if enabled, to scan the uploaded content via events trigger

return: bool
param: stdClass $submission
param: stdClass $data

get_editor_fields()   X-Ref
Return a list of the text fields that can be imported/exported by this plugin

return: array An array of field names and descriptions. (name=>description, ...)

get_editor_text($name, $submissionid)   X-Ref
Get the saved text content from the editor

return: string
param: string $name
param: int $submissionid

get_editor_format($name, $submissionid)   X-Ref
Get the content format for the editor

return: int
param: string $name
param: int $submissionid

view_summary(stdClass $submission, & $showviewlink)   X-Ref
Display onlinetext word count in the submission status table

return: string
param: stdClass $submission
param: bool $showviewlink - If the summary has been truncated set this to true

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

return: array - return an array of files indexed by filename
param: stdClass $submission - For this is the submission data
param: stdClass $user - This is the user record for this submission

view(stdClass $submission)   X-Ref
Display the saved text content from the editor in the view table

return: string
param: stdClass $submission

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

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

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

return: bool Was it a success?
param: context $oldcontext - the database for the old assignment context
param: stdClass $oldassignment - the database for the old assignment instance
param: string $log record log events here

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

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

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

return: string
param: stdClass $submission The new submission

delete_instance()   X-Ref
The assignment has been deleted - cleanup

return: bool

is_empty(stdClass $submission)   X-Ref
No text is set for this plugin

return: bool
param: stdClass $submission

submission_is_empty(stdClass $data)   X-Ref
Determine if a submission is empty

This is distinct from is_empty in that it is intended to be used to
determine if a submission made before saving is empty.

return: bool
param: stdClass $data The submission data

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)

copy_submission(stdClass $sourcesubmission, stdClass $destsubmission)   X-Ref
Copy the student's submission from a previous submission. Used when a student opts to base their resubmission
on the last submission.

param: stdClass $sourcesubmission
param: stdClass $destsubmission

get_external_parameters()   X-Ref
Return a description of external params suitable for uploading an onlinetext submission from a webservice.

return: external_description|null

check_word_count($submissiontext)   X-Ref
Compare word count of onlinetext submission to word limit, and return result.

return: string Error message if limit is enabled and exceeded, otherwise null
param: string $submissiontext Onlinetext submission text from editor

get_config_for_external()   X-Ref
Return the plugin configs for external functions.

return: array the list of settings