Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

   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  $current_tab = 'mapcourse';
  35  
  36  list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
  37  require_login($course, true, $cm);
  38  $feedback = $PAGE->activityrecord;
  39  
  40  $context = context_module::instance($cm->id);
  41  require_capability('mod/feedback:mapcourse', $context);
  42  
  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);
  52  }
  53  
  54  // Print the page header.
  55  $strfeedbacks = get_string("modulenameplural", "feedback");
  56  $strfeedback  = get_string("modulename", "feedback");
  57  
  58  $PAGE->set_heading($course->fullname);
  59  $PAGE->set_title($feedback->name);
  60  echo $OUTPUT->header();
  61  
  62  echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'));
  63  
  64  $form->display();
  65  
  66  echo $OUTPUT->footer();