Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.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 polyfill to allow a plugin to operate with Moodle 3.3 up.
  19   *
  20   * @package mod_assign
  21   * @copyright 2018 Adrian Greeve <adrian@moodle.com>
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace mod_assign\privacy;
  25  
  26  use core_privacy\local\request\contextlist;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  /**
  31   * The trait used to provide backwards compatability for third-party plugins.
  32   *
  33   * @copyright 2018 Adrian Greeve <adrian@moodle.com>
  34   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  trait submission_legacy_polyfill {
  37  
  38      /**
  39       * Retrieves the contextids associated with the provided userid for this subplugin.
  40       * NOTE if your subplugin must have an entry in the assign_submission table to work, then this
  41       * method can be empty.
  42       *
  43       * @param  int $userid The user ID to get context IDs for.
  44       * @param  \core_privacy\local\request\contextlist $contextlist Use add_from_sql with this object to add your context IDs.
  45       */
  46      public static function get_context_for_userid_within_submission(int $userid, contextlist $contextlist) {
  47          return static::_get_context_for_userid_within_submission($userid, $contextlist);
  48      }
  49  
  50      /**
  51       * Returns student user ids related to the provided teacher ID. If it is possible that a student ID will not be returned by
  52       * the sql query in \mod_assign\privacy\provider::find_grader_info() Then you need to provide some sql to retrive those
  53       * student IDs. This is highly likely if you had to fill in get_context_for_userid_within_submission above.
  54       *
  55       * @param  useridlist $useridlist A user ID list object that you can append your user IDs to.
  56       */
  57      public static function get_student_user_ids(useridlist $useridlist) {
  58          return static::_get_student_user_ids($useridlist);
  59      }
  60  
  61      /**
  62       * This method is used to export any user data this sub-plugin has using the assign_plugin_request_data object to get the
  63       * context and userid.
  64       * assign_plugin_request_data contains:
  65       * - context
  66       * - submission object
  67       * - current path (subcontext)
  68       * - user object
  69       *
  70       * @param  assign_plugin_request_data $exportdata Information to use to export user data for this sub-plugin.
  71       */
  72      public static function export_submission_user_data(assign_plugin_request_data $exportdata) {
  73          return static::_export_submission_user_data($exportdata);
  74      }
  75  
  76      /**
  77       * Any call to this method should delete all user data for the context defined in the deletion_criteria.
  78       * assign_plugin_request_data contains:
  79       * - context
  80       * - assign object
  81       *
  82       * @param assign_plugin_request_data $requestdata Information to use to delete user data for this submission.
  83       */
  84      public static function delete_submission_for_context(assign_plugin_request_data $requestdata) {
  85          return static::_delete_submission_for_context($requestdata);
  86      }
  87  
  88      /**
  89       * A call to this method should delete user data (where practicle) from the userid and context.
  90       * assign_plugin_request_data contains:
  91       * - context
  92       * - submission object
  93       * - user object
  94       * - assign object
  95       *
  96       * @param  assign_plugin_request_data $exportdata Details about the user and context to focus the deletion.
  97       */
  98      public static function delete_submission_for_userid(assign_plugin_request_data $exportdata) {
  99          return static::_delete_submission_for_userid($exportdata);
 100      }
 101  }