2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Process ajax requests
20 * @copyright Andreas Grabs
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22 * @package mod_feedback
25 if (!defined('AJAX_SCRIPT')) {
26 define('AJAX_SCRIPT', true);
29 require(__DIR__
.'/../../config.php');
30 require_once('lib.php');
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
);
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
);
43 $context = context_module
::instance($cm->id
);
44 require_login($course, true, $cm);
45 require_capability('mod/feedback:edititems', $context);
51 $itemlist = explode(',', trim($itemorder, ','));
52 if (count($itemlist) > 0) {
53 $return = feedback_ajax_saveitemorder($itemlist, $feedback);
58 echo json_encode($return);