| 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 |  * print the form to map courses for global feedbacks
 | 
        
           |  |  | 19 |  *
 | 
        
           |  |  | 20 |  * @author Andreas Grabs
 | 
        
           |  |  | 21 |  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 | 
        
           |  |  | 22 |  * @package mod_feedback
 | 
        
           |  |  | 23 |  */
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | require_once(__DIR__ . "/../../config.php");
 | 
        
           |  |  | 26 | require_once($CFG->dirroot . "/mod/feedback/lib.php");
 | 
        
           |  |  | 27 | require_once("$CFG->libdir/tablelib.php");
 | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 | $id = required_param('id', PARAM_INT); // Course Module ID.
 | 
        
           |  |  | 30 |   | 
        
           |  |  | 31 | $url = new moodle_url('/mod/feedback/mapcourse.php', array('id'=>$id));
 | 
        
           |  |  | 32 | $PAGE->set_url($url);
 | 
        
           |  |  | 33 |   | 
        
           |  |  | 34 | list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
 | 
        
           |  |  | 35 | require_login($course, true, $cm);
 | 
        
           |  |  | 36 | $feedback = $PAGE->activityrecord;
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | $context = context_module::instance($cm->id);
 | 
        
           |  |  | 39 | require_capability('mod/feedback:mapcourse', $context);
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 | $coursemap = array_keys(feedback_get_courses_from_sitecourse_map($feedback->id));
 | 
        
           |  |  | 42 | $form = new mod_feedback_course_map_form();
 | 
        
           |  |  | 43 | $form->set_data(array('id' => $cm->id, 'mappedcourses' => $coursemap));
 | 
        
           |  |  | 44 | $mainurl = new moodle_url('/mod/feedback/view.php', ['id' => $id]);
 | 
        
           |  |  | 45 | if ($form->is_cancelled()) {
 | 
        
           |  |  | 46 |     redirect($mainurl);
 | 
        
           |  |  | 47 | } else if ($data = $form->get_data()) {
 | 
        
           |  |  | 48 |     feedback_update_sitecourse_map($feedback, $data->mappedcourses);
 | 
        
           |  |  | 49 |     redirect($mainurl, get_string('mappingchanged', 'feedback'), null, \core\output\notification::NOTIFY_SUCCESS);
 | 
        
           |  |  | 50 | }
 | 
        
           |  |  | 51 |   | 
        
           |  |  | 52 | // Print the page header.
 | 
        
           |  |  | 53 | $strfeedbacks = get_string("modulenameplural", "feedback");
 | 
        
           |  |  | 54 | $strfeedback  = get_string("modulename", "feedback");
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | $PAGE->set_heading($course->fullname);
 | 
        
           |  |  | 57 | $PAGE->set_title($feedback->name);
 | 
        
           |  |  | 58 | echo $OUTPUT->header();
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 | echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'));
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 | $form->display();
 | 
        
           |  |  | 63 |   | 
        
           |  |  | 64 | echo $OUTPUT->footer();
 |