|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00025 require_once("../../config.php"); 00026 require_once("lib.php"); 00027 00028 $id = required_param('id', PARAM_INT); 00029 00030 $url = new moodle_url('/mod/feedback/index.php', array('id'=>$id)); 00031 00032 $PAGE->set_url($url); 00033 00034 if (!$course = $DB->get_record('course', array('id'=>$id))) { 00035 print_error('invalidcourseid'); 00036 } 00037 00038 if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) { 00039 print_error('badcontext'); 00040 } 00041 00042 require_login($course->id); 00043 $PAGE->set_pagelayout('incourse'); 00044 00045 add_to_log($course->id, 'feedback', 'view all', $url->out(false), $course->id); 00046 00047 00049 $strfeedbacks = get_string("modulenameplural", "feedback"); 00050 $strfeedback = get_string("modulename", "feedback"); 00051 00052 $PAGE->navbar->add($strfeedbacks); 00053 $PAGE->set_heading(format_string($course->fullname)); 00054 $PAGE->set_title(get_string('modulename', 'feedback').' '.get_string('activities')); 00055 echo $OUTPUT->header(); 00056 00058 00059 if (! $feedbacks = get_all_instances_in_course("feedback", $course)) { 00060 $url = new moodle_url('/course/view.php', array('id'=>$course->id)); 00061 notice(get_string('thereareno', 'moodle', $strfeedbacks), $url); 00062 die; 00063 } 00064 00065 $usesections = course_format_uses_sections($course->format); 00066 if ($usesections) { 00067 $sections = get_all_sections($course->id); 00068 } 00069 00071 00072 $timenow = time(); 00073 $strname = get_string("name"); 00074 $strsectionname = get_string('sectionname', 'format_'.$course->format); 00075 $strresponses = get_string('responses', 'feedback'); 00076 00077 $table = new html_table(); 00078 00079 if ($usesections) { 00080 if (has_capability('mod/feedback:viewreports', $context)) { 00081 $table->head = array ($strsectionname, $strname, $strresponses); 00082 $table->align = array ("center", "left", 'center'); 00083 } else { 00084 $table->head = array ($strsectionname, $strname); 00085 $table->align = array ("center", "left"); 00086 } 00087 } else { 00088 if (has_capability('mod/feedback:viewreports', $context)) { 00089 $table->head = array ($strname, $strresponses); 00090 $table->align = array ("left", "center"); 00091 } else { 00092 $table->head = array ($strname); 00093 $table->align = array ("left"); 00094 } 00095 } 00096 00097 00098 foreach ($feedbacks as $feedback) { 00099 //get the responses of each feedback 00100 $viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$feedback->coursemodule)); 00101 00102 if (has_capability('mod/feedback:viewreports', $context)) { 00103 $completed_feedback_count = intval(feedback_get_completeds_group_count($feedback)); 00104 } 00105 00106 $dimmedclass = $feedback->visible ? '' : 'class="dimmed"'; 00107 $link = '<a '.$dimmedclass.' href="'.$viewurl->out().'">'.$feedback->name.'</a>'; 00108 00109 if ($usesections) { 00110 $tabledata = array (get_section_name($course, $sections[$feedback->section]), $link); 00111 } else { 00112 $tabledata = array ($link); 00113 } 00114 if (has_capability('mod/feedback:viewreports', $context)) { 00115 $tabledata[] = $completed_feedback_count; 00116 } 00117 00118 $table->data[] = $tabledata; 00119 00120 } 00121 00122 echo "<br />"; 00123 00124 echo html_writer::table($table); 00125 00127 00128 echo $OUTPUT->footer(); 00129