2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * prints the overview of all feedbacks included into the current course
20 * @author Andreas Grabs
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
25 require_once("../../config.php");
26 require_once("lib.php");
28 $id = required_param('id', PARAM_INT
);
30 $url = new moodle_url('/mod/feedback/index.php', array('id'=>$id));
34 if (!$course = $DB->get_record('course', array('id'=>$id))) {
35 print_error('invalidcourseid');
38 if (!$context = get_context_instance(CONTEXT_COURSE
, $course->id
)) {
39 print_error('badcontext');
42 require_login($course);
43 $PAGE->set_pagelayout('incourse');
45 add_to_log($course->id
, 'feedback', 'view all', $url->out(false), $course->id
);
48 /// Print the page header
49 $strfeedbacks = get_string("modulenameplural", "feedback");
50 $strfeedback = get_string("modulename", "feedback");
52 $PAGE->navbar
->add($strfeedbacks);
53 $PAGE->set_heading(format_string($course->fullname
));
54 $PAGE->set_title(get_string('modulename', 'feedback').' '.get_string('activities'));
55 echo $OUTPUT->header();
57 /// Get all the appropriate data
59 if (! $feedbacks = get_all_instances_in_course("feedback", $course)) {
60 $url = new moodle_url('/course/view.php', array('id'=>$course->id
));
61 notice(get_string('thereareno', 'moodle', $strfeedbacks), $url);
65 $usesections = course_format_uses_sections($course->format
);
67 $sections = get_all_sections($course->id
);
70 /// Print the list of instances (your module will probably extend this)
73 $strname = get_string("name");
74 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
75 $strresponses = get_string('responses', 'feedback');
77 $table = new html_table();
80 if (has_capability('mod/feedback:viewreports', $context)) {
81 $table->head
= array ($strsectionname, $strname, $strresponses);
82 $table->align
= array ("center", "left", 'center');
84 $table->head
= array ($strsectionname, $strname);
85 $table->align
= array ("center", "left");
88 if (has_capability('mod/feedback:viewreports', $context)) {
89 $table->head
= array ($strname, $strresponses);
90 $table->align
= array ("left", "center");
92 $table->head
= array ($strname);
93 $table->align
= array ("left");
98 foreach ($feedbacks as $feedback) {
99 //get the responses of each feedback
100 $viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$feedback->coursemodule
));
102 if (has_capability('mod/feedback:viewreports', $context)) {
103 $completed_feedback_count = intval(feedback_get_completeds_group_count($feedback));
106 $dimmedclass = $feedback->visible ?
'' : 'class="dimmed"';
107 $link = '<a '.$dimmedclass.' href="'.$viewurl->out().'">'.$feedback->name
.'</a>';
110 $tabledata = array (get_section_name($course, $sections[$feedback->section
]), $link);
112 $tabledata = array ($link);
114 if (has_capability('mod/feedback:viewreports', $context)) {
115 $tabledata[] = $completed_feedback_count;
118 $table->data
[] = $tabledata;
124 echo html_writer
::table($table);
128 echo $OUTPUT->footer();