[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/feedback/ -> analysis.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   * shows an analysed view of feedback
  19   *
  20   * @copyright 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  $current_tab = 'analysis';
  29  
  30  $id = required_param('id', PARAM_INT);  //the POST dominated the GET
  31  $courseid = optional_param('courseid', false, PARAM_INT);
  32  
  33  $url = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
  34  if ($courseid !== false) {
  35      $url->param('courseid', $courseid);
  36  }
  37  $PAGE->set_url($url);
  38  
  39  if (! $cm = get_coursemodule_from_id('feedback', $id)) {
  40      print_error('invalidcoursemodule');
  41  }
  42  
  43  if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
  44      print_error('coursemisconf');
  45  }
  46  
  47  if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
  48      print_error('invalidcoursemodule');
  49  }
  50  
  51  $context = context_module::instance($cm->id);
  52  
  53  if ($course->id == SITEID) {
  54      require_login($course, true);
  55  } else {
  56      require_login($course, true, $cm);
  57  }
  58  
  59  //check whether the given courseid exists
  60  if ($courseid AND $courseid != SITEID) {
  61      if ($course2 = $DB->get_record('course', array('id'=>$courseid))) {
  62          require_course_login($course2); //this overwrites the object $course :-(
  63          $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
  64      } else {
  65          print_error('invalidcourseid');
  66      }
  67  }
  68  
  69  if ( !( ((intval($feedback->publish_stats) == 1) AND
  70          has_capability('mod/feedback:viewanalysepage', $context)) OR
  71          has_capability('mod/feedback:viewreports', $context))) {
  72      print_error('error');
  73  }
  74  
  75  /// Print the page header
  76  $strfeedbacks = get_string("modulenameplural", "feedback");
  77  $strfeedback  = get_string("modulename", "feedback");
  78  
  79  $PAGE->navbar->add(get_string('analysis', 'feedback'));
  80  $PAGE->set_heading($course->fullname);
  81  $PAGE->set_title($feedback->name);
  82  echo $OUTPUT->header();
  83  echo $OUTPUT->heading(format_string($feedback->name));
  84  
  85  /// print the tabs
  86  require ('tabs.php');
  87  
  88  
  89  //print analysed items
  90  echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
  91  
  92  //get the groupid
  93  $myurl = $CFG->wwwroot.'/mod/feedback/analysis.php?id='.$cm->id.'&do_show=analysis';
  94  $groupselect = groups_print_activity_menu($cm, $myurl, true);
  95  $mygroupid = groups_get_activity_group($cm);
  96  
  97  if ( has_capability('mod/feedback:viewreports', $context) ) {
  98  
  99      echo isset($groupselect) ? $groupselect : '';
 100      echo '<div class="clearer"></div>';
 101  
 102      //button "export to excel"
 103      echo $OUTPUT->container_start('form-buttons');
 104      $aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id));
 105      echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
 106      echo $OUTPUT->container_end();
 107  }
 108  
 109  //get completed feedbacks
 110  $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
 111  
 112  //show the group, if available
 113  if ($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) {
 114      echo '<b>'.get_string('group').': '.$group->name. '</b><br />';
 115  }
 116  //show the count
 117  echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />';
 118  
 119  // get the items of the feedback
 120  $items = $DB->get_records('feedback_item',
 121                            array('feedback'=>$feedback->id, 'hasvalue'=>1),
 122                            'position');
 123  //show the count
 124  if (is_array($items)) {
 125      echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />';
 126  } else {
 127      $items=array();
 128  }
 129  $check_anonymously = true;
 130  if ($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
 131      if ($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
 132          $check_anonymously = false;
 133      }
 134  }
 135  
 136  echo '<div><table width="80%" cellpadding="10"><tr><td>';
 137  if ($check_anonymously) {
 138      $itemnr = 0;
 139      //print the items in an analysed form
 140      foreach ($items as $item) {
 141          if ($item->hasvalue == 0) {
 142              continue;
 143          }
 144          echo '<table width="100%" class="generalbox">';
 145  
 146          //get the class of item-typ
 147          $itemobj = feedback_get_item_class($item->typ);
 148  
 149          $itemnr++;
 150          if ($feedback->autonumbering) {
 151              $printnr = $itemnr.'.';
 152          } else {
 153              $printnr = '';
 154          }
 155          $itemobj->print_analysed($item, $printnr, $mygroupid);
 156          echo '</table>';
 157      }
 158  } else {
 159      echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'),
 160                                      'insufficient_responses',
 161                                      'feedback', '', '', 3);
 162  }
 163  echo '</td></tr></table></div>';
 164  echo $OUTPUT->box_end();
 165  
 166  echo $OUTPUT->footer();
 167  


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1