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   * Process ajax requests
  19   *
  20   * @copyright Andreas Grabs
  21   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  22   * @package mod_feedback
  23   */
  24  
  25  if (!defined('AJAX_SCRIPT')) {
  26      define('AJAX_SCRIPT', true);
  27  }
  28  
  29  require(__DIR__.'/../../config.php');
  30  require_once ('lib.php');
  31  
  32  $id = required_param('id', PARAM_INT);
  33  $action = optional_param('action', '', PARAM_ALPHA);
  34  $sesskey = optional_param('sesskey', false, PARAM_TEXT);
  35  $itemorder = optional_param('itemorder', false, PARAM_SEQUENCE);
  36  
  37  $cm = get_coursemodule_from_id('feedback', $id, 0, false, MUST_EXIST);
  38  $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
  39  $feedback = $DB->get_record('feedback', array('id'=>$cm->instance), '*', MUST_EXIST);
  40  
  41  require_sesskey();
  42  
  43  $context = context_module::instance($cm->id);
  44  require_login($course, true, $cm);
  45  require_capability('mod/feedback:edititems', $context);
  46  
  47  $return = false;
  48  
  49  switch ($action) {
  50      case 'saveitemorder':
  51          $itemlist = explode(',', trim($itemorder, ','));
  52          if (count($itemlist) > 0) {
  53              $return = feedback_ajax_saveitemorder($itemlist, $feedback);
  54          }
  55          break;
  56  }
  57  
  58  echo json_encode($return);
  59  die;