[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 a feedback on the mainsite 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 $current_tab = 'analysis'; 29 30 $id = required_param('id', PARAM_INT); //the POST dominated the GET 31 $courseitemfilter = optional_param('courseitemfilter', '0', PARAM_INT); 32 $courseitemfiltertyp = optional_param('courseitemfiltertyp', '0', PARAM_ALPHANUM); 33 $courseid = optional_param('courseid', false, PARAM_INT); 34 35 $url = new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$id)); 36 navigation_node::override_active_url($url); 37 if ($courseid !== false) { 38 $url->param('courseid', $courseid); 39 } 40 if ($courseitemfilter !== '0') { 41 $url->param('courseitemfilter', $courseitemfilter); 42 } 43 if ($courseitemfiltertyp !== '0') { 44 $url->param('courseitemfiltertyp', $courseitemfiltertyp); 45 } 46 $PAGE->set_url($url); 47 48 list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); 49 $context = context_module::instance($cm->id); 50 51 require_course_login($course, true, $cm); 52 53 $feedback = $PAGE->activityrecord; 54 55 if (!($feedback->publish_stats OR has_capability('mod/feedback:viewreports', $context))) { 56 print_error('error'); 57 } 58 59 $feedbackstructure = new mod_feedback_structure($feedback, $PAGE->cm, $courseid); 60 61 // Process course select form. 62 $courseselectform = new mod_feedback_course_select_form($url, $feedbackstructure); 63 if ($data = $courseselectform->get_data()) { 64 redirect(new moodle_url($url, ['courseid' => $data->courseid])); 65 } 66 67 /// Print the page header 68 $strfeedbacks = get_string("modulenameplural", "feedback"); 69 $strfeedback = get_string("modulename", "feedback"); 70 71 $PAGE->set_heading($course->fullname); 72 $PAGE->set_title($feedback->name); 73 echo $OUTPUT->header(); 74 echo $OUTPUT->heading(format_string($feedback->name)); 75 76 /// print the tabs 77 require ('tabs.php'); 78 79 //get the groupid 80 //lstgroupid is the choosen id 81 $mygroupid = false; 82 83 $courseselectform->display(); 84 85 // Show the summary. 86 $summary = new mod_feedback\output\summary($feedbackstructure); 87 echo $OUTPUT->render_from_template('mod_feedback/summary', $summary->export_for_template($OUTPUT)); 88 89 // Get the items of the feedback. 90 $items = $feedbackstructure->get_items(true); 91 92 if ($courseitemfilter > 0) { 93 $sumvalue = 'SUM(' . $DB->sql_cast_char2real('value', true) . ')'; 94 $sql = "SELECT fv.course_id, c.shortname, $sumvalue AS sumvalue, COUNT(value) as countvalue 95 FROM {feedback_value} fv, {course} c, {feedback_item} fi 96 WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ? 97 GROUP BY course_id, shortname 98 ORDER BY sumvalue desc"; 99 100 if ($courses = $DB->get_records_sql($sql, array($courseitemfiltertyp, $courseitemfilter))) { 101 $item = $DB->get_record('feedback_item', array('id'=>$courseitemfilter)); 102 echo '<h4>'.$item->name.'</h4>'; 103 echo '<div class="clearfix">'; 104 echo '<table>'; 105 echo '<tr><th>Course</th><th>Average</th></tr>'; 106 107 foreach ($courses as $c) { 108 $coursecontext = context_course::instance($c->course_id); 109 $shortname = format_string($c->shortname, true, array('context' => $coursecontext)); 110 111 echo '<tr>'; 112 echo '<td>'.$shortname.'</td>'; 113 echo '<td align="right">'; 114 echo format_float(($c->sumvalue / $c->countvalue), 2); 115 echo '</td>'; 116 echo '</tr>'; 117 } 118 echo '</table>'; 119 } else { 120 echo '<p>'.get_string('noresults').'</p>'; 121 } 122 echo '<p><a href="analysis_course.php?id=' . $id . '">'; 123 echo get_string('back'); 124 echo '</a></p>'; 125 } else { 126 127 // Print the items in an analysed form. 128 foreach ($items as $item) { 129 echo '<table class="analysis">'; 130 $itemobj = feedback_get_item_class($item->typ); 131 $printnr = ($feedback->autonumbering && $item->itemnr) ? ($item->itemnr . '.') : ''; 132 $itemobj->print_analysed($item, $printnr, $mygroupid, $feedbackstructure->get_courseid()); 133 if (preg_match('/rated$/i', $item->typ)) { 134 $url = new moodle_url('/mod/feedback/analysis_course.php', array('id' => $id, 135 'courseitemfilter' => $item->id, 'courseitemfiltertyp' => $item->typ)); 136 $anker = html_writer::link($url, get_string('sort_by_course', 'feedback')); 137 138 echo '<tr><td colspan="2">'.$anker.'</td></tr>'; 139 } 140 echo '</table>'; 141 } 142 } 143 144 echo $OUTPUT->footer(); 145
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |