2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * This file contains the definition for the abstract class for submission_plugin
20 * This class provides all the functionality for submission plugins.
23 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') ||
die();
29 require_once($CFG->dirroot
. '/mod/assign/assignmentplugin.php');
32 * Abstract base class for submission plugin types.
35 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 abstract class assign_submission_plugin
extends assign_plugin
{
41 * return subtype name of the plugin
45 public final function get_subtype() {
46 return 'assignsubmission';
50 * This plugin accepts submissions from a student
51 * The comments plugin has no submission component so should not be counted
52 * when determining whether to show the edit submission link.
55 public function allow_submissions() {
61 * Check if the submission plugin has all the required data to allow the work
62 * to be submitted for grading
63 * @param stdClass $submission the assign_submission record being submitted.
64 * @return bool|string 'true' if OK to proceed with submission, otherwise a
65 * a message to display to the user
67 public function precheck_submission($submission) {
72 * Carry out any extra processing required when the work is submitted for grading
73 * @param stdClass $submission the assign_submission record being submitted.
76 public function submit_for_grading($submission) {
80 * Copy the plugin specific submission data to a new submission record.
82 * @param stdClass $oldsubmission - Old submission record
83 * @param stdClass $submission - New submission record
86 public function copy_submission( stdClass
$oldsubmission, stdClass
$submission) {
91 * Carry out any extra processing required when the work is locked.
93 * @param stdClass|false $submission - assign_submission data if any
94 * @param stdClass $flags - User flags record
97 public function lock($submission, stdClass
$flags) {
101 * Carry out any extra processing required when the work is unlocked.
103 * @param stdClass|false $submission - assign_submission data if any
104 * @param stdClass $flags - User flags record
107 public function unlock($submission, stdClass
$flags) {
111 * Carry out any extra processing required when the work reverted to draft.
113 * @param stdClass $submission - assign_submission data
116 public function revert_to_draft(stdClass
$submission) {
120 * Carry out any extra processing required when a student is given a new attempt
121 * (i.e. when the submission is "reopened"
122 * @param stdClass $oldsubmission The previous attempt
123 * @param stdClass $newsubmission The new attempt
125 public function add_attempt(stdClass
$oldsubmission, stdClass
$newsubmission) {
129 * Determine if a submission is empty
131 * This is distinct from is_empty in that it is intended to be used to
132 * determine if a submission made before saving is empty.
134 * @param stdClass $data The submission data
137 public function submission_is_empty(stdClass
$data) {