Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

   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 confirm dialog to use template and create new items from template
  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("../../config.php");
  26  require_once ("lib.php");
  27  
  28  $id = required_param('id', PARAM_INT);
  29  $templateid = optional_param('templateid', false, PARAM_INT);
  30  $mode = optional_param('mode', '', PARAM_ALPHA);
  31  
  32  if (!$templateid) {
  33      redirect('edit.php?id='.$id);
  34  }
  35  
  36  $url = new moodle_url('/mod/feedback/use_templ.php', array('id'=>$id, 'templateid'=>$templateid));
  37  $PAGE->set_url($url);
  38  
  39  list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
  40  $context = context_module::instance($cm->id);
  41  
  42  require_login($course, true, $cm);
  43  
  44  $feedback = $PAGE->activityrecord;
  45  $feedbackstructure = new mod_feedback_structure($feedback, $cm, 0, $templateid);
  46  
  47  require_capability('mod/feedback:edititems', $context);
  48  
  49  /// Print the page header
  50  $strfeedbacks = get_string("modulenameplural", "feedback");
  51  $strfeedback  = get_string("modulename", "feedback");
  52  
  53  $params = ['id' => $id];
  54  $params += ($mode ? ['mode' => $mode] : []);
  55  $activeurl = new moodle_url('/mod/feedback/manage_templates.php', $params);
  56  $PAGE->set_url($activeurl);
  57  
  58  if ($mode == 'manage') {
  59      navigation_node::override_active_url($activeurl);
  60  } else {
  61      navigation_node::override_active_url(new moodle_url('/mod/feedback/view.php', $params));
  62  }
  63  
  64  $PAGE->set_heading($course->fullname);
  65  $PAGE->set_title($feedback->name);
  66  $PAGE->activityheader->set_attrs([
  67      "hidecompletion" => true,
  68      "description" => ''
  69  ]);
  70  $actionbar = new \mod_feedback\output\edit_template_action_bar($cm->id, $templateid, $mode);
  71  /** @var \mod_feedback\output\renderer $renderer */
  72  $renderer = $PAGE->get_renderer('mod_feedback');
  73  
  74  echo $OUTPUT->header();
  75  echo $renderer->main_action_bar($actionbar);
  76  
  77  $form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_VIEW_TEMPLATE,
  78          $feedbackstructure, 'feedback_preview_form', ['templateid' => $templateid]);
  79  $form->display();
  80  
  81  echo $OUTPUT->footer();
  82