[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/feedback/ -> view.php (source)

   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   * the first page to view the feedback
  19   *
  20   * @author Andreas Grabs
  21   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  22   * @package mod_feedback
  23   */
  24  require_once(__DIR__ . '/../../config.php');
  25  require_once($CFG->dirroot . '/mod/feedback/lib.php');
  26  
  27  $id = required_param('id', PARAM_INT);
  28  $courseid = optional_param('courseid', false, PARAM_INT);
  29  
  30  $current_tab = 'view';
  31  
  32  list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
  33  require_course_login($course, true, $cm);
  34  $feedback = $PAGE->activityrecord;
  35  
  36  $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid);
  37  
  38  $context = context_module::instance($cm->id);
  39  
  40  if ($course->id == SITEID) {
  41      $PAGE->set_pagelayout('incourse');
  42  }
  43  $PAGE->set_url('/mod/feedback/view.php', array('id' => $cm->id));
  44  $PAGE->set_title($feedback->name);
  45  $PAGE->set_heading($course->fullname);
  46  
  47  // Check access to the given courseid.
  48  if ($courseid AND $courseid != SITEID) {
  49      require_course_login(get_course($courseid)); // This overwrites the object $COURSE .
  50  }
  51  
  52  // Check whether the feedback is mapped to the given courseid.
  53  if (!has_capability('mod/feedback:edititems', $context) &&
  54          !$feedbackcompletion->check_course_is_mapped()) {
  55      echo $OUTPUT->header();
  56      echo $OUTPUT->notification(get_string('cannotaccess', 'mod_feedback'));
  57      echo $OUTPUT->footer();
  58      exit;
  59  }
  60  
  61  // Trigger module viewed event.
  62  $event = \mod_feedback\event\course_module_viewed::create_from_record($feedback, $cm, $course);
  63  $event->trigger();
  64  
  65  /// Print the page header
  66  echo $OUTPUT->header();
  67  
  68  /// Print the main part of the page
  69  ///////////////////////////////////////////////////////////////////////////
  70  ///////////////////////////////////////////////////////////////////////////
  71  ///////////////////////////////////////////////////////////////////////////
  72  
  73  $previewimg = $OUTPUT->pix_icon('t/preview', get_string('preview'));
  74  $previewlnk = new moodle_url('/mod/feedback/print.php', array('id' => $id));
  75  if ($courseid) {
  76      $previewlnk->param('courseid', $courseid);
  77  }
  78  $preview = html_writer::link($previewlnk, $previewimg);
  79  
  80  echo $OUTPUT->heading(format_string($feedback->name) . $preview);
  81  
  82  // Print the tabs.
  83  require ('tabs.php');
  84  
  85  // Show description.
  86  echo $OUTPUT->box_start('generalbox feedback_description');
  87  $options = (object)array('noclean' => true);
  88  echo format_module_intro('feedback', $feedback, $cm->id);
  89  echo $OUTPUT->box_end();
  90  
  91  //show some infos to the feedback
  92  if (has_capability('mod/feedback:edititems', $context)) {
  93  
  94      echo $OUTPUT->heading(get_string('overview', 'feedback'), 3);
  95  
  96      //get the groupid
  97      $groupselect = groups_print_activity_menu($cm, $CFG->wwwroot.'/mod/feedback/view.php?id='.$cm->id, true);
  98      $mygroupid = groups_get_activity_group($cm);
  99  
 100      echo $groupselect.'<div class="clearer">&nbsp;</div>';
 101      $summary = new mod_feedback\output\summary($feedbackcompletion, $mygroupid, true);
 102      echo $OUTPUT->render_from_template('mod_feedback/summary', $summary->export_for_template($OUTPUT));
 103  
 104      if ($pageaftersubmit = $feedbackcompletion->page_after_submit()) {
 105          echo $OUTPUT->heading(get_string("page_after_submit", "feedback"), 3);
 106          echo $OUTPUT->box($pageaftersubmit, 'generalbox feedback_after_submit');
 107      }
 108  }
 109  
 110  if (!has_capability('mod/feedback:viewreports', $context) &&
 111          $feedbackcompletion->can_view_analysis()) {
 112      $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $id));
 113      echo '<div class="mdl-align"><a href="'.$analysisurl->out().'">';
 114      echo get_string('completed_feedbacks', 'feedback').'</a>';
 115      echo '</div>';
 116  }
 117  
 118  if (has_capability('mod/feedback:mapcourse', $context) && $feedback->course == SITEID) {
 119      echo $OUTPUT->box_start('generalbox feedback_mapped_courses');
 120      echo $OUTPUT->heading(get_string("mappedcourses", "feedback"), 3);
 121      echo '<p>' . get_string('mapcourse_help', 'feedback') . '</p>';
 122      $mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id' => $id));
 123      echo '<p class="mdl-align">' . html_writer::link($mapurl, get_string('mapcourses', 'feedback')) . '</p>';
 124      echo $OUTPUT->box_end();
 125  }
 126  
 127  if ($feedbackcompletion->can_complete()) {
 128      echo $OUTPUT->box_start('generalbox boxaligncenter');
 129      if (!$feedbackcompletion->is_open()) {
 130          // Feedback is not yet open or is already closed.
 131          echo $OUTPUT->notification(get_string('feedback_is_not_open', 'feedback'));
 132          echo $OUTPUT->continue_button(course_get_url($courseid ?: $course->id));
 133      } else if ($feedbackcompletion->can_submit()) {
 134          // Display a link to complete feedback or resume.
 135          $completeurl = new moodle_url('/mod/feedback/complete.php',
 136                  ['id' => $id, 'courseid' => $courseid]);
 137          if ($startpage = $feedbackcompletion->get_resume_page()) {
 138              $completeurl->param('gopage', $startpage);
 139              $label = get_string('continue_the_form', 'feedback');
 140          } else {
 141              $label = get_string('complete_the_form', 'feedback');
 142          }
 143          echo html_writer::div(html_writer::link($completeurl, $label), 'complete-feedback');
 144      } else {
 145          // Feedback was already submitted.
 146          echo $OUTPUT->notification(get_string('this_feedback_is_already_submitted', 'feedback'));
 147          $OUTPUT->continue_button(course_get_url($courseid ?: $course->id));
 148      }
 149      echo $OUTPUT->box_end();
 150  }
 151  
 152  echo $OUTPUT->footer();
 153  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1