[ Index ] |
PHP Cross Reference of moodle-2.8 |
[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 * print the single-values of anonymous completeds 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($CFG->libdir.'/tablelib.php'); 28 29 $id = required_param('id', PARAM_INT); 30 $showcompleted = optional_param('showcompleted', false, PARAM_INT); 31 $do_show = optional_param('do_show', false, PARAM_ALPHA); 32 $perpage = optional_param('perpage', FEEDBACK_DEFAULT_PAGE_COUNT, PARAM_INT); // how many per page 33 $showall = optional_param('showall', false, PARAM_INT); // should we show all users 34 35 $current_tab = $do_show; 36 37 $url = new moodle_url('/mod/feedback/show_entries_anonym.php', array('id'=>$id)); 38 // if ($userid !== '') { 39 // $url->param('userid', $userid); 40 // } 41 $PAGE->set_url($url); 42 43 if (! $cm = get_coursemodule_from_id('feedback', $id)) { 44 print_error('invalidcoursemodule'); 45 } 46 47 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 48 print_error('coursemisconf'); 49 } 50 51 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { 52 print_error('invalidcoursemodule'); 53 } 54 55 $context = context_module::instance($cm->id); 56 57 require_login($course, true, $cm); 58 59 require_capability('mod/feedback:viewreports', $context); 60 61 /// Print the page header 62 $strfeedbacks = get_string("modulenameplural", "feedback"); 63 $strfeedback = get_string("modulename", "feedback"); 64 65 $PAGE->set_heading($course->fullname); 66 $PAGE->set_title($feedback->name); 67 echo $OUTPUT->header(); 68 echo $OUTPUT->heading(format_string($feedback->name)); 69 70 /// Print the main part of the page 71 /////////////////////////////////////////////////////////////////////////// 72 /////////////////////////////////////////////////////////////////////////// 73 /////////////////////////////////////////////////////////////////////////// 74 require ('tabs.php'); 75 76 //print the list with anonymous completeds 77 if (!$showcompleted) { 78 79 //get the completeds 80 // if a new anonymous record has not been assigned a random response number 81 $params = array('feedback'=>$feedback->id, 82 'random_response'=>0, 83 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES); 84 85 if ($feedbackcompleteds = $DB->get_records('feedback_completed', $params, 'random_response')) { 86 //then get all of the anonymous records and go through them 87 $params = array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES); 88 $feedbackcompleteds = $DB->get_records('feedback_completed', $params, 'id'); //arb 89 shuffle($feedbackcompleteds); 90 $num = 1; 91 foreach ($feedbackcompleteds as $compl) { 92 $compl->random_response = $num; 93 $DB->update_record('feedback_completed', $compl); 94 $num++; 95 } 96 } 97 98 $params = array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES); 99 $feedbackcompletedscount = $DB->count_records('feedback_completed', $params); 100 101 // preparing the table for output 102 $baseurl = new moodle_url('/mod/feedback/show_entries_anonym.php'); 103 $baseurl->params(array('id'=>$id, 'do_show'=>$do_show, 'showall'=>$showall)); 104 105 $tablecolumns = array('response', 'showresponse'); 106 $tableheaders = array('', ''); 107 108 if (has_capability('mod/feedback:deletesubmissions', $context)) { 109 $tablecolumns[] = 'deleteentry'; 110 $tableheaders[] = ''; 111 } 112 113 $table = new flexible_table('feedback-showentryanonym-list-'.$course->id); 114 115 $table->define_columns($tablecolumns); 116 $table->define_headers($tableheaders); 117 $table->define_baseurl($baseurl); 118 119 $table->sortable(false); 120 $table->set_attribute('cellspacing', '0'); 121 $table->set_attribute('id', 'showentryanonymtable'); 122 $table->set_attribute('class', 'generaltable generalbox'); 123 $table->set_control_variables(array( 124 TABLE_VAR_SORT => 'ssort', 125 TABLE_VAR_IFIRST => 'sifirst', 126 TABLE_VAR_ILAST => 'silast', 127 TABLE_VAR_PAGE => 'spage' 128 )); 129 $table->setup(); 130 131 $matchcount = $feedbackcompletedscount; 132 $table->initialbars(true); 133 134 if ($showall) { 135 $startpage = false; 136 $pagecount = false; 137 } else { 138 $table->pagesize($perpage, $matchcount); 139 $startpage = $table->get_page_start(); 140 $pagecount = $table->get_page_size(); 141 } 142 143 144 $feedbackcompleteds = $DB->get_records('feedback_completed', 145 array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES), 146 'random_response', 147 'id,random_response', 148 $startpage, 149 $pagecount); 150 151 if (is_array($feedbackcompleteds)) { 152 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); 153 echo $OUTPUT->heading(get_string('anonymous_entries', 'feedback'), 3); 154 foreach ($feedbackcompleteds as $compl) { 155 $data = array(); 156 157 $data[] = get_string('response_nr', 'feedback').': '. $compl->random_response; 158 159 //link to the entry 160 $showentryurl = new moodle_url($baseurl, array('showcompleted'=>$compl->id)); 161 $showentrylink = '<a href="'.$showentryurl->out().'">'.get_string('show_entry', 'feedback').'</a>'; 162 $data[] = $showentrylink; 163 164 //link to delete the entry 165 if (has_capability('mod/feedback:deletesubmissions', $context)) { 166 $delet_url_params = array('id'=>$cm->id, 167 'completedid'=>$compl->id, 168 'do_show'=>'', 169 'return'=>'entriesanonym'); 170 171 $deleteentryurl = new moodle_url($CFG->wwwroot.'/mod/feedback/delete_completed.php', $delet_url_params); 172 $deleteentrylink = '<a href="'.$deleteentryurl->out().'">'.get_string('delete_entry', 'feedback').'</a>'; 173 $data[] = $deleteentrylink; 174 } 175 $table->add_data($data); 176 } 177 $table->print_html(); 178 179 $allurl = new moodle_url($baseurl); 180 181 if ($showall) { 182 $allurl->param('showall', 0); 183 $str_showperpage = get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT); 184 echo $OUTPUT->container(html_writer::link($allurl, $str_showperpage), array(), 'showall'); 185 } else if ($matchcount > 0 && $perpage < $matchcount) { 186 $allurl->param('showall', 1); 187 echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall'); 188 } 189 echo $OUTPUT->box_end(); 190 } 191 } 192 //print the items 193 if ($showcompleted) { 194 $continueurl = new moodle_url('/mod/feedback/show_entries_anonym.php', 195 array('id'=>$id, 'do_show'=>'')); 196 197 echo $OUTPUT->continue_button($continueurl); 198 199 //get the feedbackitems 200 $params = array('feedback'=>$feedback->id); 201 $feedbackitems = $DB->get_records('feedback_item', $params, 'position'); 202 $feedbackcompleted = $DB->get_record('feedback_completed', array('id'=>$showcompleted)); 203 if (is_array($feedbackitems)) { 204 $align = right_to_left() ? 'right' : 'left'; 205 206 if ($feedbackcompleted) { 207 echo $OUTPUT->box_start('feedback_info'); 208 echo get_string('chosen_feedback_response', 'feedback'); 209 echo $OUTPUT->box_end(); 210 echo $OUTPUT->box_start('feedback_info'); 211 echo get_string('response_nr', 'feedback').': '; 212 echo $feedbackcompleted->random_response.' ('.get_string('anonymous', 'feedback').')'; 213 echo $OUTPUT->box_end(); 214 } else { 215 echo $OUTPUT->box_start('feedback_info'); 216 echo get_string('not_completed_yet', 'feedback'); 217 echo $OUTPUT->box_end(); 218 } 219 220 echo $OUTPUT->box_start('feedback_items'); 221 $itemnr = 0; 222 foreach ($feedbackitems as $feedbackitem) { 223 //get the values 224 $params = array('completed'=>$feedbackcompleted->id, 'item'=>$feedbackitem->id); 225 $value = $DB->get_record('feedback_value', $params); 226 echo $OUTPUT->box_start('feedback_item_box_'.$align); 227 if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) { 228 $itemnr++; 229 echo $OUTPUT->box_start('feedback_item_number_'.$align); 230 echo $itemnr; 231 echo $OUTPUT->box_end(); 232 } 233 if ($feedbackitem->typ != 'pagebreak') { 234 echo $OUTPUT->box_start('box generalbox boxalign_'.$align); 235 $itemvalue = isset($value->value) ? $value->value : false; 236 feedback_print_item_show_value($feedbackitem, $itemvalue); 237 echo $OUTPUT->box_end(); 238 } 239 echo $OUTPUT->box_end(); 240 } 241 echo $OUTPUT->box_end(); 242 } 243 } 244 /// Finish the page 245 /////////////////////////////////////////////////////////////////////////// 246 /////////////////////////////////////////////////////////////////////////// 247 /////////////////////////////////////////////////////////////////////////// 248 249 echo $OUTPUT->footer(); 250
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |