Merge branch 'MDL-62560-master'
[moodle.git] / mod / assign / submissionplugin.php
blob29f92200b235b9683d5caf19c084695ce5fed39a
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
8 //
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/>.
17 /**
18 * This file contains the definition for the abstract class for submission_plugin
20 * This class provides all the functionality for submission plugins.
22 * @package mod_assign
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');
31 /**
32 * Abstract base class for submission plugin types.
34 * @package mod_assign
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 {
40 /**
41 * return subtype name of the plugin
43 * @return string
45 public final function get_subtype() {
46 return 'assignsubmission';
49 /**
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.
53 * @return boolean
55 public function allow_submissions() {
56 return true;
60 /**
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) {
68 return true;
71 /**
72 * Carry out any extra processing required when the work is submitted for grading
73 * @param stdClass $submission the assign_submission record being submitted.
74 * @return void
76 public function submit_for_grading($submission) {
79 /**
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
84 * @return bool
86 public function copy_submission( stdClass $oldsubmission, stdClass $submission) {
87 return true;
90 /**
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
95 * @return void
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
105 * @return void
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
114 * @return void
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
135 * @return bool
137 public function submission_is_empty(stdClass $data) {
138 return false;