| 1 | 
           efrain | 
           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 function for feedback_plugin abstract class
  | 
        
        
            | 
            | 
           19 | 
            *
  | 
        
        
            | 
            | 
           20 | 
            * @package   mod_assign
  | 
        
        
            | 
            | 
           21 | 
            * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  | 
        
        
            | 
            | 
           22 | 
            * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           23 | 
            */
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           defined('MOODLE_INTERNAL') || die();
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           require_once($CFG->dirroot.'/mod/assign/assignmentplugin.php');
  | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
           /**
  | 
        
        
            | 
            | 
           30 | 
            * Abstract class for feedback_plugin inherited from assign_plugin abstract class.
  | 
        
        
            | 
            | 
           31 | 
            *
  | 
        
        
            | 
            | 
           32 | 
            * @package   mod_assign
  | 
        
        
            | 
            | 
           33 | 
            * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  | 
        
        
            | 
            | 
           34 | 
            * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           35 | 
            */
  | 
        
        
            | 
            | 
           36 | 
           abstract class assign_feedback_plugin extends assign_plugin {
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
               /**
  | 
        
        
            | 
            | 
           39 | 
                * Return subtype name of the plugin.
  | 
        
        
            | 
            | 
           40 | 
                *
  | 
        
        
            | 
            | 
           41 | 
                * @return string
  | 
        
        
            | 
            | 
           42 | 
                */
  | 
        
        
            | 
            | 
           43 | 
               public function get_subtype() {
  | 
        
        
            | 
            | 
           44 | 
                   return 'assignfeedback';
  | 
        
        
            | 
            | 
           45 | 
               }
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
            | 
            | 
           47 | 
               /**
  | 
        
        
            | 
            | 
           48 | 
                * If this plugin adds to the gradebook comments field, it must specify the format
  | 
        
        
            | 
            | 
           49 | 
                * of the comment.
  | 
        
        
            | 
            | 
           50 | 
                *
  | 
        
        
            | 
            | 
           51 | 
                * (From weblib.php)
  | 
        
        
            | 
            | 
           52 | 
                * define('FORMAT_MOODLE',   '0');   // Does all sorts of transformations and filtering
  | 
        
        
            | 
            | 
           53 | 
                * define('FORMAT_HTML',     '1');   // Plain HTML (with some tags stripped)
  | 
        
        
            | 
            | 
           54 | 
                * define('FORMAT_PLAIN',    '2');   // Plain text (even tags are printed in full)
  | 
        
        
            | 
            | 
           55 | 
                * define('FORMAT_WIKI',     '3');   // Wiki-formatted text
  | 
        
        
            | 
            | 
           56 | 
                * define('FORMAT_MARKDOWN', '4');   // Markdown-formatted
  | 
        
        
            | 
            | 
           57 | 
                *
  | 
        
        
            | 
            | 
           58 | 
                * Only one feedback plugin can push comments to the gradebook and that is chosen by the assignment
  | 
        
        
            | 
            | 
           59 | 
                * settings page.
  | 
        
        
            | 
            | 
           60 | 
                *
  | 
        
        
            | 
            | 
           61 | 
                * @param stdClass $grade The grade
  | 
        
        
            | 
            | 
           62 | 
                * @return int
  | 
        
        
            | 
            | 
           63 | 
                */
  | 
        
        
            | 
            | 
           64 | 
               public function format_for_gradebook(stdClass $grade) {
  | 
        
        
            | 
            | 
           65 | 
                   return FORMAT_MOODLE;
  | 
        
        
            | 
            | 
           66 | 
               }
  | 
        
        
            | 
            | 
           67 | 
              | 
        
        
            | 
            | 
           68 | 
               /**
  | 
        
        
            | 
            | 
           69 | 
                * If this plugin adds to the gradebook comments field, it must format the text
  | 
        
        
            | 
            | 
           70 | 
                * of the comment.
  | 
        
        
            | 
            | 
           71 | 
                *
  | 
        
        
            | 
            | 
           72 | 
                * Only one feedback plugin can push comments to the gradebook and that is chosen by the assignment
  | 
        
        
            | 
            | 
           73 | 
                * settings page.
  | 
        
        
            | 
            | 
           74 | 
                *
  | 
        
        
            | 
            | 
           75 | 
                * @param stdClass $grade The grade
  | 
        
        
            | 
            | 
           76 | 
                * @return string
  | 
        
        
            | 
            | 
           77 | 
                */
  | 
        
        
            | 
            | 
           78 | 
               public function text_for_gradebook(stdClass $grade) {
  | 
        
        
            | 
            | 
           79 | 
                   return '';
  | 
        
        
            | 
            | 
           80 | 
               }
  | 
        
        
            | 
            | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
               /**
  | 
        
        
            | 
            | 
           83 | 
                * Return any files this plugin wishes to save to the gradebook.
  | 
        
        
            | 
            | 
           84 | 
                *
  | 
        
        
            | 
            | 
           85 | 
                * The array being returned should contain the necessary information to
  | 
        
        
            | 
            | 
           86 | 
                * identify and copy the files.
  | 
        
        
            | 
            | 
           87 | 
                *
  | 
        
        
            | 
            | 
           88 | 
                * eg.
  | 
        
        
            | 
            | 
           89 | 
                *
  | 
        
        
            | 
            | 
           90 | 
                * [
  | 
        
        
            | 
            | 
           91 | 
                *      'contextid' => $modulecontext->id,
  | 
        
        
            | 
            | 
           92 | 
                *      'component' => ASSIGNFEEDBACK_XYZ_COMPONENT,
  | 
        
        
            | 
            | 
           93 | 
                *      'filearea' => ASSIGNFEEDBACK_XYZ_FILEAREA,
  | 
        
        
            | 
            | 
           94 | 
                *      'itemid' => $grade->id
  | 
        
        
            | 
            | 
           95 | 
                * ]
  | 
        
        
            | 
            | 
           96 | 
                *
  | 
        
        
            | 
            | 
           97 | 
                * @param stdClass $grade The assign_grades object from the db
  | 
        
        
            | 
            | 
           98 | 
                * @return array
  | 
        
        
            | 
            | 
           99 | 
                */
  | 
        
        
            | 
            | 
           100 | 
               public function files_for_gradebook(stdClass $grade): array {
  | 
        
        
            | 
            | 
           101 | 
                   return [];
  | 
        
        
            | 
            | 
           102 | 
               }
  | 
        
        
            | 
            | 
           103 | 
              | 
        
        
            | 
            | 
           104 | 
               /**
  | 
        
        
            | 
            | 
           105 | 
                * Override to indicate a plugin supports quickgrading.
  | 
        
        
            | 
            | 
           106 | 
                *
  | 
        
        
            | 
            | 
           107 | 
                * @return boolean - True if the plugin supports quickgrading
  | 
        
        
            | 
            | 
           108 | 
                */
  | 
        
        
            | 
            | 
           109 | 
               public function supports_quickgrading() {
  | 
        
        
            | 
            | 
           110 | 
                   return false;
  | 
        
        
            | 
            | 
           111 | 
               }
  | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
               /**
  | 
        
        
            | 
            | 
           114 | 
                * Get quickgrading form elements as html.
  | 
        
        
            | 
            | 
           115 | 
                *
  | 
        
        
            | 
            | 
           116 | 
                * @param int $userid The user id in the table this quickgrading element relates to
  | 
        
        
            | 
            | 
           117 | 
                * @param mixed $grade grade or null - The grade data.
  | 
        
        
            | 
            | 
           118 | 
                *                     May be null if there are no grades for this user (yet)
  | 
        
        
            | 
            | 
           119 | 
                * @return mixed - A html string containing the html form elements required for
  | 
        
        
            | 
            | 
           120 | 
                *                 quickgrading or false to indicate this plugin does not support quickgrading
  | 
        
        
            | 
            | 
           121 | 
                */
  | 
        
        
            | 
            | 
           122 | 
               public function get_quickgrading_html($userid, $grade) {
  | 
        
        
            | 
            | 
           123 | 
                   return false;
  | 
        
        
            | 
            | 
           124 | 
               }
  | 
        
        
            | 
            | 
           125 | 
              | 
        
        
            | 
            | 
           126 | 
               /**
  | 
        
        
            | 
            | 
           127 | 
                * Has the plugin quickgrading form element been modified in the current form submission?
  | 
        
        
            | 
            | 
           128 | 
                *
  | 
        
        
            | 
            | 
           129 | 
                * @param int $userid The user id in the table this quickgrading element relates to
  | 
        
        
            | 
            | 
           130 | 
                * @param stdClass $grade The grade
  | 
        
        
            | 
            | 
           131 | 
                * @return boolean - true if the quickgrading form element has been modified
  | 
        
        
            | 
            | 
           132 | 
                */
  | 
        
        
            | 
            | 
           133 | 
               public function is_quickgrading_modified($userid, $grade) {
  | 
        
        
            | 
            | 
           134 | 
                   return false;
  | 
        
        
            | 
            | 
           135 | 
               }
  | 
        
        
            | 
            | 
           136 | 
              | 
        
        
            | 
            | 
           137 | 
               /**
  | 
        
        
            | 
            | 
           138 | 
                * Has the plugin form element been modified in the current submission?
  | 
        
        
            | 
            | 
           139 | 
                *
  | 
        
        
            | 
            | 
           140 | 
                * @param stdClass $grade The grade.
  | 
        
        
            | 
            | 
           141 | 
                * @param stdClass $data Form data from the feedback form.
  | 
        
        
            | 
            | 
           142 | 
                * @return boolean - True if the form element has been modified.
  | 
        
        
            | 
            | 
           143 | 
                */
  | 
        
        
            | 
            | 
           144 | 
               public function is_feedback_modified(stdClass $grade, stdClass $data) {
  | 
        
        
            | 
            | 
           145 | 
                   debugging('This plugin (' . $this->get_name() . ') has not overwritten the is_feedback_modified() method.
  | 
        
        
            | 
            | 
           146 | 
                           Please add this method to your plugin', DEBUG_DEVELOPER);
  | 
        
        
            | 
            | 
           147 | 
                   return true;
  | 
        
        
            | 
            | 
           148 | 
               }
  | 
        
        
            | 
            | 
           149 | 
              | 
        
        
            | 
            | 
           150 | 
               /**
  | 
        
        
            | 
            | 
           151 | 
                * Save quickgrading changes.
  | 
        
        
            | 
            | 
           152 | 
                *
  | 
        
        
            | 
            | 
           153 | 
                * @param int $userid The user id in the table this quickgrading element relates to
  | 
        
        
            | 
            | 
           154 | 
                * @param stdClass $grade The grade
  | 
        
        
            | 
            | 
           155 | 
                * @return boolean - true if the grade changes were saved correctly
  | 
        
        
            | 
            | 
           156 | 
                */
  | 
        
        
            | 
            | 
           157 | 
               public function save_quickgrading_changes($userid, $grade) {
  | 
        
        
            | 
            | 
           158 | 
                   return false;
  | 
        
        
            | 
            | 
           159 | 
               }
  | 
        
        
            | 
            | 
           160 | 
              | 
        
        
            | 
            | 
           161 | 
               /**
  | 
        
        
           | 1441 | 
           ariadna | 
           162 | 
                * Return a list of detailed batch grading operations supported by this plugin.
  | 
        
        
            | 
            | 
           163 | 
                *
  | 
        
        
            | 
            | 
           164 | 
                * @return array - An array of objects containing batch operation details. Each object should contain:
  | 
        
        
            | 
            | 
           165 | 
                *                  - 'key': the action identifier (string)
  | 
        
        
            | 
            | 
           166 | 
                *                  - 'label': the button label (string)
  | 
        
        
            | 
            | 
           167 | 
                *                  - 'icon': the button icon (string)
  | 
        
        
            | 
            | 
           168 | 
                *                  - 'confirmationtitle': the title for the confirmation modal (string)
  | 
        
        
            | 
            | 
           169 | 
                *                  - 'confirmationquestion': the question for the confirmation modal (string)
  | 
        
        
            | 
            | 
           170 | 
                */
  | 
        
        
            | 
            | 
           171 | 
               public function get_grading_batch_operation_details() {
  | 
        
        
            | 
            | 
           172 | 
                   return [];
  | 
        
        
            | 
            | 
           173 | 
               }
  | 
        
        
            | 
            | 
           174 | 
              | 
        
        
            | 
            | 
           175 | 
               /**
  | 
        
        
           | 1 | 
           efrain | 
           176 | 
                * Return a list of the batch grading operations supported by this plugin.
  | 
        
        
            | 
            | 
           177 | 
                *
  | 
        
        
            | 
            | 
           178 | 
                * @return array - An array of action and description strings.
  | 
        
        
            | 
            | 
           179 | 
                *                 The action will be passed to grading_batch_operation.
  | 
        
        
           | 1441 | 
           ariadna | 
           180 | 
                * @deprecated since 4.5, use get_grading_batch_operation_details() instead.
  | 
        
        
            | 
            | 
           181 | 
                * @todo Final deprecation in Moodle 6.0. See MDL-82856.
  | 
        
        
           | 1 | 
           efrain | 
           182 | 
                */
  | 
        
        
           | 1441 | 
           ariadna | 
           183 | 
               #[\core\attribute\deprecated('get_grading_batch_operation_details', since: '4.5', mdl: 'MDL-80750')]
  | 
        
        
           | 1 | 
           efrain | 
           184 | 
               public function get_grading_batch_operations() {
  | 
        
        
           | 1441 | 
           ariadna | 
           185 | 
                   \core\deprecation::emit_deprecation([$this, __FUNCTION__]);
  | 
        
        
            | 
            | 
           186 | 
              | 
        
        
            | 
            | 
           187 | 
                   return array_column(static::get_grading_batch_operation_details(), 'confirmationtitle', 'key');
  | 
        
        
           | 1 | 
           efrain | 
           188 | 
               }
  | 
        
        
            | 
            | 
           189 | 
              | 
        
        
            | 
            | 
           190 | 
               /**
  | 
        
        
            | 
            | 
           191 | 
                * Return a list of the grading actions supported by this plugin.
  | 
        
        
            | 
            | 
           192 | 
                *
  | 
        
        
            | 
            | 
           193 | 
                * A grading action is a page that is not specific to a user but to the whole assignment.
  | 
        
        
            | 
            | 
           194 | 
                * @return array - An array of action and description strings.
  | 
        
        
            | 
            | 
           195 | 
                *                 The action will be passed to grading_action.
  | 
        
        
            | 
            | 
           196 | 
                */
  | 
        
        
            | 
            | 
           197 | 
               public function get_grading_actions() {
  | 
        
        
            | 
            | 
           198 | 
                   return array();
  | 
        
        
            | 
            | 
           199 | 
               }
  | 
        
        
            | 
            | 
           200 | 
              | 
        
        
            | 
            | 
           201 | 
               /**
  | 
        
        
            | 
            | 
           202 | 
                * Show a grading action form
  | 
        
        
            | 
            | 
           203 | 
                *
  | 
        
        
            | 
            | 
           204 | 
                * @param string $gradingaction The action chosen from the grading actions menu
  | 
        
        
            | 
            | 
           205 | 
                * @return string The page containing the form
  | 
        
        
            | 
            | 
           206 | 
                */
  | 
        
        
            | 
            | 
           207 | 
               public function grading_action($gradingaction) {
  | 
        
        
            | 
            | 
           208 | 
                   return '';
  | 
        
        
            | 
            | 
           209 | 
               }
  | 
        
        
            | 
            | 
           210 | 
              | 
        
        
            | 
            | 
           211 | 
               /**
  | 
        
        
            | 
            | 
           212 | 
                * Supports injecting content into the review panel of the grading app.
  | 
        
        
            | 
            | 
           213 | 
                *
  | 
        
        
            | 
            | 
           214 | 
                * @return bool True if this plugin will add content to the review panel of the grading app.
  | 
        
        
            | 
            | 
           215 | 
                */
  | 
        
        
            | 
            | 
           216 | 
               public function supports_review_panel() {
  | 
        
        
            | 
            | 
           217 | 
                   return false;
  | 
        
        
            | 
            | 
           218 | 
               }
  | 
        
        
            | 
            | 
           219 | 
              | 
        
        
            | 
            | 
           220 | 
               /**
  | 
        
        
            | 
            | 
           221 | 
                * Show a batch operations form
  | 
        
        
            | 
            | 
           222 | 
                *
  | 
        
        
            | 
            | 
           223 | 
                * @param string $action The action chosen from the batch operations menu
  | 
        
        
            | 
            | 
           224 | 
                * @param array $users The list of selected userids
  | 
        
        
            | 
            | 
           225 | 
                * @return string The page containing the form
  | 
        
        
            | 
            | 
           226 | 
                */
  | 
        
        
            | 
            | 
           227 | 
               public function grading_batch_operation($action, $users) {
  | 
        
        
            | 
            | 
           228 | 
                   return '';
  | 
        
        
            | 
            | 
           229 | 
               }
  | 
        
        
            | 
            | 
           230 | 
           }
  |