Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   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.
  13  //
  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/>.
  16  
  17  /**
  18   * This file contains the definition for the abstract class for submission_plugin
  19   *
  20   * This class provides all the functionality for submission plugins.
  21   *
  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
  25   */
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  require_once($CFG->dirroot . '/mod/assign/assignmentplugin.php');
  30  
  31  /**
  32   * Abstract base class for submission plugin types.
  33   *
  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
  37   */
  38  abstract class assign_submission_plugin extends assign_plugin {
  39  
  40      /**
  41       * return subtype name of the plugin
  42       *
  43       * @return string
  44       */
  45      public final function get_subtype() {
  46          return 'assignsubmission';
  47      }
  48  
  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
  54       */
  55      public function allow_submissions() {
  56          return true;
  57      }
  58  
  59  
  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
  66       */
  67      public function precheck_submission($submission) {
  68          return true;
  69      }
  70  
  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
  75       */
  76      public function submit_for_grading($submission) {
  77      }
  78  
  79      /**
  80       * Copy the plugin specific submission data to a new submission record.
  81       *
  82       * @param stdClass $oldsubmission - Old submission record
  83       * @param stdClass $submission - New submission record
  84       * @return bool
  85       */
  86      public function copy_submission( stdClass $oldsubmission, stdClass $submission) {
  87          return true;
  88      }
  89  
  90      /**
  91       * Carry out any extra processing required when the work is locked.
  92       *
  93       * @param stdClass|false $submission - assign_submission data if any
  94       * @param stdClass $flags - User flags record
  95       * @return void
  96       */
  97      public function lock($submission, stdClass $flags) {
  98      }
  99  
 100      /**
 101       * Carry out any extra processing required when the work is unlocked.
 102       *
 103       * @param stdClass|false $submission - assign_submission data if any
 104       * @param stdClass $flags - User flags record
 105       * @return void
 106       */
 107      public function unlock($submission, stdClass $flags) {
 108      }
 109  
 110      /**
 111       * Carry out any extra processing required when the work reverted to draft.
 112       *
 113       * @param stdClass $submission - assign_submission data
 114       * @return void
 115       */
 116      public function revert_to_draft(stdClass $submission) {
 117      }
 118  
 119      /**
 120       * Remove any saved data from this submission.
 121       *
 122       * @param stdClass $submission - assign_submission data
 123       * @return void
 124       */
 125      public function remove(stdClass $submission) {
 126      }
 127  
 128      /**
 129       * Carry out any extra processing required when a student is given a new attempt
 130       * (i.e. when the submission is "reopened"
 131       * @param stdClass $oldsubmission The previous attempt
 132       * @param stdClass $newsubmission The new attempt
 133       */
 134      public function add_attempt(stdClass $oldsubmission, stdClass $newsubmission) {
 135      }
 136  
 137      /**
 138       * Determine if a submission is empty
 139       *
 140       * This is distinct from is_empty in that it is intended to be used to
 141       * determine if a submission made before saving is empty.
 142       *
 143       * @param stdClass $data The submission data
 144       * @return bool
 145       */
 146      public function submission_is_empty(stdClass $data) {
 147          return false;
 148      }
 149  
 150      /**
 151       * Determine if the plugin allows image file conversion
 152       * @return bool
 153       */
 154      public function allow_image_conversion() {
 155          return false;
 156      }
 157  }