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