Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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 single entries 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 //////////////////////////////////////////////////////// 29 //get the params 30 //////////////////////////////////////////////////////// 31 $id = required_param('id', PARAM_INT); 32 $userid = optional_param('userid', false, PARAM_INT); 33 $showcompleted = optional_param('showcompleted', false, PARAM_INT); 34 $deleteid = optional_param('delete', null, PARAM_INT); 35 $courseid = optional_param('courseid', null, PARAM_INT); 36 37 //////////////////////////////////////////////////////// 38 //get the objects 39 //////////////////////////////////////////////////////// 40 41 list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); 42 43 $baseurl = new moodle_url('/mod/feedback/show_entries.php', array('id' => $cm->id)); 44 $PAGE->set_url(new moodle_url($baseurl, array('userid' => $userid, 'showcompleted' => $showcompleted, 45 'delete' => $deleteid))); 46 47 $context = context_module::instance($cm->id); 48 49 require_login($course, true, $cm); 50 $feedback = $PAGE->activityrecord; 51 52 require_capability('mod/feedback:viewreports', $context); 53 54 if ($deleteid) { 55 // This is a request to delete a reponse. 56 require_capability('mod/feedback:deletesubmissions', $context); 57 require_sesskey(); 58 $feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $deleteid); 59 feedback_delete_completed($feedbackstructure->get_completed(), $feedback, $cm); 60 redirect($baseurl); 61 } else if ($showcompleted || $userid) { 62 // Viewing individual response. 63 $feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $showcompleted, $userid); 64 } else { 65 // Viewing list of reponses. 66 $feedbackstructure = new mod_feedback_structure($feedback, $cm, $courseid); 67 } 68 69 $responsestable = new mod_feedback_responses_table($feedbackstructure); 70 $anonresponsestable = new mod_feedback_responses_anon_table($feedbackstructure); 71 72 if ($responsestable->is_downloading()) { 73 $responsestable->download(); 74 } 75 if ($anonresponsestable->is_downloading()) { 76 $anonresponsestable->download(); 77 } 78 79 // Process course select form. 80 $courseselectform = new mod_feedback_course_select_form($baseurl, $feedbackstructure, $feedback->course == SITEID); 81 if ($data = $courseselectform->get_data()) { 82 redirect(new moodle_url($baseurl, ['courseid' => $data->courseid])); 83 } 84 // Print the page header. 85 navigation_node::override_active_url($baseurl); 86 $PAGE->set_heading($course->fullname); 87 $PAGE->set_title($feedback->name); 88 echo $OUTPUT->header(); 89 echo $OUTPUT->heading(format_string($feedback->name)); 90 91 $current_tab = 'showentries'; 92 require ('tabs.php'); 93 94 /// Print the main part of the page 95 /////////////////////////////////////////////////////////////////////////// 96 /////////////////////////////////////////////////////////////////////////// 97 /////////////////////////////////////////////////////////////////////////// 98 99 if ($userid || $showcompleted) { 100 // Print the response of the given user. 101 $completedrecord = $feedbackstructure->get_completed(); 102 103 if ($userid) { 104 $usr = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); 105 $responsetitle = userdate($completedrecord->timemodified) . ' (' . fullname($usr) . ')'; 106 } else { 107 $responsetitle = get_string('response_nr', 'feedback') . ': ' . 108 $completedrecord->random_response . ' (' . get_string('anonymous', 'feedback') . ')'; 109 } 110 111 echo $OUTPUT->heading($responsetitle, 4); 112 113 $form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_VIEW_RESPONSE, 114 $feedbackstructure, 'feedback_viewresponse_form'); 115 $form->display(); 116 117 list($prevresponseurl, $returnurl, $nextresponseurl) = $userid ? 118 $responsestable->get_reponse_navigation_links($completedrecord) : 119 $anonresponsestable->get_reponse_navigation_links($completedrecord); 120 121 echo html_writer::start_div('response_navigation'); 122 123 $responsenavigation = [ 124 'col1content' => '', 125 'col2content' => html_writer::link($returnurl, get_string('back'), ['class' => 'back_to_list']), 126 'col3content' => '', 127 ]; 128 129 if ($prevresponseurl) { 130 $responsenavigation['col1content'] = html_writer::link($prevresponseurl, get_string('prev'), ['class' => 'prev_response']); 131 } 132 133 if ($nextresponseurl) { 134 $responsenavigation['col3content'] = html_writer::link($nextresponseurl, get_string('next'), ['class' => 'next_response']); 135 } 136 137 echo $OUTPUT->render_from_template('core/columns-1to1to1', $responsenavigation); 138 echo html_writer::end_div(); 139 140 } else { 141 // Print the list of responses. 142 $courseselectform->display(); 143 144 // Show non-anonymous responses (always retrieve them even if current feedback is anonymous). 145 $totalrows = $responsestable->get_total_responses_count(); 146 if (!$feedbackstructure->is_anonymous() || $totalrows) { 147 echo $OUTPUT->heading(get_string('non_anonymous_entries', 'feedback', $totalrows), 4); 148 $responsestable->display(); 149 } 150 151 // Show anonymous responses (always retrieve them even if current feedback is not anonymous). 152 $feedbackstructure->shuffle_anonym_responses(); 153 $totalrows = $anonresponsestable->get_total_responses_count(); 154 if ($feedbackstructure->is_anonymous() || $totalrows) { 155 echo $OUTPUT->heading(get_string('anonymous_entries', 'feedback', $totalrows), 4); 156 $anonresponsestable->display(); 157 } 158 159 } 160 161 // Finish the page. 162 echo $OUTPUT->footer(); 163
title
Description
Body
title
Description
Body
title
Description
Body
title
Body