[ 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 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 require_once($CFG->libdir.'/tablelib.php'); 28 29 //////////////////////////////////////////////////////// 30 //get the params 31 //////////////////////////////////////////////////////// 32 $id = required_param('id', PARAM_INT); 33 $userid = optional_param('userid', false, PARAM_INT); 34 $do_show = required_param('do_show', PARAM_ALPHA); 35 $perpage = optional_param('perpage', FEEDBACK_DEFAULT_PAGE_COUNT, PARAM_INT); // how many per page 36 $showall = optional_param('showall', false, PARAM_INT); // should we show all users 37 // $SESSION->feedback->current_tab = $do_show; 38 $current_tab = $do_show; 39 40 //////////////////////////////////////////////////////// 41 //get the objects 42 //////////////////////////////////////////////////////// 43 44 if (! $cm = get_coursemodule_from_id('feedback', $id)) { 45 print_error('invalidcoursemodule'); 46 } 47 48 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 49 print_error('coursemisconf'); 50 } 51 52 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { 53 print_error('invalidcoursemodule'); 54 } 55 56 $url = new moodle_url('/mod/feedback/show_entries.php', array('id'=>$cm->id, 'do_show'=>$do_show)); 57 58 $PAGE->set_url($url); 59 60 $context = context_module::instance($cm->id); 61 62 require_login($course, true, $cm); 63 64 require_capability('mod/feedback:viewreports', $context); 65 66 //////////////////////////////////////////////////////// 67 //get the responses of given user 68 //////////////////////////////////////////////////////// 69 if ($do_show == 'showoneentry') { 70 //get the feedbackitems 71 $feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position'); 72 73 $params = array('feedback'=>$feedback->id, 74 'userid'=>$userid, 75 'anonymous_response'=>FEEDBACK_ANONYMOUS_NO); 76 77 $feedbackcompleted = $DB->get_record('feedback_completed', $params); //arb 78 } 79 80 /// Print the page header 81 $strfeedbacks = get_string("modulenameplural", "feedback"); 82 $strfeedback = get_string("modulename", "feedback"); 83 84 $PAGE->set_heading($course->fullname); 85 $PAGE->set_title($feedback->name); 86 echo $OUTPUT->header(); 87 echo $OUTPUT->heading(format_string($feedback->name)); 88 89 require ('tabs.php'); 90 91 /// Print the main part of the page 92 /////////////////////////////////////////////////////////////////////////// 93 /////////////////////////////////////////////////////////////////////////// 94 /////////////////////////////////////////////////////////////////////////// 95 96 //////////////////////////////////////////////////////// 97 /// Print the links to get responses and analysis 98 //////////////////////////////////////////////////////// 99 if ($do_show == 'showentries') { 100 //print the link to analysis 101 if (has_capability('mod/feedback:viewreports', $context)) { 102 //get the effective groupmode of this course and module 103 if (isset($cm->groupmode) && empty($course->groupmodeforce)) { 104 $groupmode = $cm->groupmode; 105 } else { 106 $groupmode = $course->groupmode; 107 } 108 109 $groupselect = groups_print_activity_menu($cm, $url->out(), true); 110 $mygroupid = groups_get_activity_group($cm); 111 112 // preparing the table for output 113 $baseurl = new moodle_url('/mod/feedback/show_entries.php'); 114 $baseurl->params(array('id'=>$id, 'do_show'=>$do_show, 'showall'=>$showall)); 115 116 $tablecolumns = array('userpic', 'fullname', 'completed_timemodified'); 117 $tableheaders = array(get_string('userpic'), get_string('fullnameuser'), get_string('date')); 118 119 if (has_capability('mod/feedback:deletesubmissions', $context)) { 120 $tablecolumns[] = 'deleteentry'; 121 $tableheaders[] = ''; 122 } 123 124 $table = new flexible_table('feedback-showentry-list-'.$course->id); 125 126 $table->define_columns($tablecolumns); 127 $table->define_headers($tableheaders); 128 $table->define_baseurl($baseurl); 129 130 $table->sortable(true, 'lastname', SORT_DESC); 131 $table->set_attribute('cellspacing', '0'); 132 $table->set_attribute('id', 'showentrytable'); 133 $table->set_attribute('class', 'generaltable generalbox'); 134 $table->set_control_variables(array( 135 TABLE_VAR_SORT => 'ssort', 136 TABLE_VAR_IFIRST => 'sifirst', 137 TABLE_VAR_ILAST => 'silast', 138 TABLE_VAR_PAGE => 'spage' 139 )); 140 $table->setup(); 141 142 if ($table->get_sql_sort()) { 143 $sort = $table->get_sql_sort(); 144 } else { 145 $sort = ''; 146 } 147 148 list($where, $params) = $table->get_sql_where(); 149 if ($where) { 150 $where .= ' AND'; 151 } 152 153 //get students in conjunction with groupmode 154 if ($groupmode > 0) { 155 if ($mygroupid > 0) { 156 $usedgroupid = $mygroupid; 157 } else { 158 $usedgroupid = false; 159 } 160 } else { 161 $usedgroupid = false; 162 } 163 164 $matchcount = feedback_count_complete_users($cm, $usedgroupid); 165 $table->initialbars(true); 166 167 if ($showall) { 168 $startpage = false; 169 $pagecount = false; 170 } else { 171 $table->pagesize($perpage, $matchcount); 172 $startpage = $table->get_page_start(); 173 $pagecount = $table->get_page_size(); 174 } 175 176 $students = feedback_get_complete_users($cm, $usedgroupid, $where, $params, $sort, $startpage, $pagecount); 177 $str_analyse = get_string('analysis', 'feedback'); 178 $str_complete = get_string('completed_feedbacks', 'feedback'); 179 $str_course = get_string('course'); 180 181 $completed_fb_count = feedback_get_completeds_group_count($feedback, $mygroupid); 182 if ($feedback->course == SITEID) { 183 $analysisurl = new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$id, 'courseid'=>$courseid)); 184 echo $OUTPUT->box_start('mdl-align'); 185 echo '<a href="'.$analysisurl->out().'">'; 186 echo $str_course.' '.$str_analyse.' ('.$str_complete.': '.intval($completed_fb_count).')'; 187 echo '</a>'; 188 echo $OUTPUT->help_icon('viewcompleted', 'feedback'); 189 echo $OUTPUT->box_end(); 190 } else { 191 $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id, 'courseid'=>$courseid)); 192 echo $OUTPUT->box_start('mdl-align'); 193 echo '<a href="'.$analysisurl->out().'">'; 194 echo $str_analyse.' ('.$str_complete.': '.intval($completed_fb_count).')'; 195 echo '</a>'; 196 echo $OUTPUT->box_end(); 197 } 198 } 199 200 //####### viewreports-start 201 if (has_capability('mod/feedback:viewreports', $context)) { 202 //print the list of students 203 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); 204 echo isset($groupselect) ? $groupselect : ''; 205 echo '<div class="clearer"></div>'; 206 echo $OUTPUT->box_start('mdl-align'); 207 if (!$students) { 208 $table->print_html(); 209 } else { 210 echo print_string('non_anonymous_entries', 'feedback'); 211 echo ' ('.count($students).')<hr />'; 212 213 foreach ($students as $student) { 214 $params = array('userid'=>$student->id, 215 'feedback'=>$feedback->id, 216 'anonymous_response'=>FEEDBACK_ANONYMOUS_NO); 217 218 $completed_count = $DB->count_records('feedback_completed', $params); 219 if ($completed_count > 0) { 220 221 //userpicture and link to the profilepage 222 $fullname_url = $CFG->wwwroot.'/user/view.php?id='.$student->id.'&course='.$course->id; 223 $profilelink = '<strong><a href="'.$fullname_url.'">'.fullname($student).'</a></strong>'; 224 $data = array ($OUTPUT->user_picture($student, array('courseid'=>$course->id)), $profilelink); 225 226 //link to the entry of the user 227 $params = array('feedback'=>$feedback->id, 228 'userid'=>$student->id, 229 'anonymous_response'=>FEEDBACK_ANONYMOUS_NO); 230 231 $feedbackcompleted = $DB->get_record('feedback_completed', $params); 232 $showentryurl_params = array('userid'=>$student->id, 'do_show'=>'showoneentry'); 233 $showentryurl = new moodle_url($url, $showentryurl_params); 234 $showentrylink = '<a href="'.$showentryurl->out().'">'.userdate($feedbackcompleted->timemodified).'</a>'; 235 $data[] = $showentrylink; 236 237 //link to delete the entry 238 if (has_capability('mod/feedback:deletesubmissions', $context)) { 239 $delete_url_params = array('id' => $cm->id, 240 'completedid' => $feedbackcompleted->id, 241 'do_show' => 'showoneentry'); 242 243 $deleteentryurl = new moodle_url($CFG->wwwroot.'/mod/feedback/delete_completed.php', $delete_url_params); 244 $deleteentrylink = '<a href="'.$deleteentryurl->out().'">'. 245 get_string('delete_entry', 'feedback'). 246 '</a>'; 247 $data[] = $deleteentrylink; 248 } 249 $table->add_data($data); 250 } 251 } 252 $table->print_html(); 253 254 $allurl = new moodle_url($baseurl); 255 256 if ($showall) { 257 $allurl->param('showall', 0); 258 echo $OUTPUT->container(html_writer::link($allurl, get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)), 259 array(), 260 'showall'); 261 262 } else if ($matchcount > 0 && $perpage < $matchcount) { 263 $allurl->param('showall', 1); 264 echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), 265 array(), 266 'showall'); 267 } 268 } 269 ?> 270 <hr /> 271 <table width="100%"> 272 <tr> 273 <td align="left" colspan="2"> 274 <?php 275 $params = array('feedback' => $feedback->id, 276 'anonymous_response' => FEEDBACK_ANONYMOUS_YES); 277 278 $feedback_completeds_count = $DB->count_records('feedback_completed', $params); 279 print_string('anonymous_entries', 'feedback'); 280 echo ' ('.$feedback_completeds_count.')'; 281 ?> 282 </td> 283 <td align="right"> 284 <?php 285 $url_params = array('sesskey'=>sesskey(), 286 'userid'=>0, 287 'do_show'=>'showoneentry', 288 'id'=>$id); 289 $aurl = new moodle_url('show_entries_anonym.php', $url_params); 290 echo $OUTPUT->single_button($aurl, get_string('show_entries', 'feedback')); 291 ?> 292 </td> 293 </tr> 294 </table> 295 <?php 296 echo $OUTPUT->box_end(); 297 echo $OUTPUT->box_end(); 298 } 299 300 } 301 //////////////////////////////////////////////////////// 302 /// Print the responses of the given user 303 //////////////////////////////////////////////////////// 304 if ($do_show == 'showoneentry') { 305 echo $OUTPUT->heading(format_text($feedback->name)); 306 307 //print the items 308 if (is_array($feedbackitems)) { 309 $align = right_to_left() ? 'right' : 'left'; 310 $usr = $DB->get_record('user', array('id'=>$userid)); 311 312 if ($feedbackcompleted) { 313 echo $OUTPUT->heading(userdate($feedbackcompleted->timemodified).' ('.fullname($usr).')', 3); 314 } else { 315 echo $OUTPUT->heading(get_string('not_completed_yet', 'feedback'), 3); 316 } 317 318 echo $OUTPUT->box_start('feedback_items'); 319 $itemnr = 0; 320 foreach ($feedbackitems as $feedbackitem) { 321 //get the values 322 $params = array('completed'=>$feedbackcompleted->id, 'item'=>$feedbackitem->id); 323 $value = $DB->get_record('feedback_value', $params); 324 echo $OUTPUT->box_start('feedback_item_box_'.$align); 325 if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) { 326 $itemnr++; 327 echo $OUTPUT->box_start('feedback_item_number_'.$align); 328 echo $itemnr; 329 echo $OUTPUT->box_end(); 330 } 331 332 if ($feedbackitem->typ != 'pagebreak') { 333 echo $OUTPUT->box_start('box generalbox boxalign_'.$align); 334 if (isset($value->value)) { 335 feedback_print_item_show_value($feedbackitem, $value->value); 336 } else { 337 feedback_print_item_show_value($feedbackitem, false); 338 } 339 echo $OUTPUT->box_end(); 340 } 341 echo $OUTPUT->box_end(); 342 } 343 echo $OUTPUT->box_end(); 344 } 345 echo $OUTPUT->continue_button(new moodle_url($url, array('do_show'=>'showentries'))); 346 } 347 /// Finish the page 348 /////////////////////////////////////////////////////////////////////////// 349 /////////////////////////////////////////////////////////////////////////// 350 /////////////////////////////////////////////////////////////////////////// 351 352 echo $OUTPUT->footer(); 353
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 |