Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   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  require_once ('use_templ_form.php');
  28  
  29  $id = required_param('id', PARAM_INT);
  30  $templateid = optional_param('templateid', false, PARAM_INT);
  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  $mform = new mod_feedback_use_templ_form();
  50  $mform->set_data(array('id' => $id, 'templateid' => $templateid));
  51  
  52  if ($mform->is_cancelled()) {
  53      redirect('edit.php?id='.$id.'&do_show=templates');
  54  } else if ($formdata = $mform->get_data()) {
  55      feedback_items_from_template($feedback, $templateid, $formdata->deleteolditems);
  56      redirect('edit.php?id=' . $id);
  57  }
  58  
  59  /// Print the page header
  60  $strfeedbacks = get_string("modulenameplural", "feedback");
  61  $strfeedback  = get_string("modulename", "feedback");
  62  
  63  navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php',
  64          array('id' => $id, 'do_show' => 'templates')));
  65  $PAGE->set_heading($course->fullname);
  66  $PAGE->set_title($feedback->name);
  67  echo $OUTPUT->header();
  68  
  69  /// Print the main part of the page
  70  ///////////////////////////////////////////////////////////////////////////
  71  ///////////////////////////////////////////////////////////////////////////
  72  ///////////////////////////////////////////////////////////////////////////
  73  echo $OUTPUT->heading(format_string($feedback->name));
  74  
  75  echo $OUTPUT->heading(get_string('confirmusetemplate', 'feedback'), 4);
  76  
  77  $mform->display();
  78  
  79  $form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_VIEW_TEMPLATE,
  80          $feedbackstructure, 'feedback_preview_form', ['templateid' => $templateid]);
  81  $form->display();
  82  
  83  echo $OUTPUT->footer();
  84