2009-09-24 06:11:39 +00:00
|
|
|
<?php
|
2011-10-28 00:30:42 +02:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2009-09-24 06:11:39 +00:00
|
|
|
|
2008-04-23 09:33:54 +00:00
|
|
|
/**
|
2009-09-24 06:11:39 +00:00
|
|
|
* prints the overview of all feedbacks included into the current course
|
|
|
|
*
|
|
|
|
* @author Andreas Grabs
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
|
|
|
* @package feedback
|
|
|
|
*/
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
$id = required_param('id', PARAM_INT);
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2010-03-28 15:29:49 +00:00
|
|
|
$url = new moodle_url('/mod/feedback/index.php', array('id'=>$id));
|
|
|
|
|
|
|
|
$PAGE->set_url($url);
|
2009-09-24 06:11:39 +00:00
|
|
|
|
|
|
|
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
|
|
|
print_error('invalidcourseid');
|
|
|
|
}
|
2010-04-02 11:34:28 +00:00
|
|
|
|
|
|
|
if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
|
|
|
|
print_error('badcontext');
|
|
|
|
}
|
2009-09-24 06:11:39 +00:00
|
|
|
|
|
|
|
require_login($course->id);
|
2009-12-27 12:02:04 +00:00
|
|
|
$PAGE->set_pagelayout('incourse');
|
2009-09-24 06:11:39 +00:00
|
|
|
|
2010-03-28 15:29:49 +00:00
|
|
|
add_to_log($course->id, 'feedback', 'view all', $url->out(false), $course->id);
|
2008-04-23 09:33:54 +00:00
|
|
|
|
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
/// Print the page header
|
|
|
|
$strfeedbacks = get_string("modulenameplural", "feedback");
|
|
|
|
$strfeedback = get_string("modulename", "feedback");
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
$PAGE->navbar->add($strfeedbacks);
|
2010-05-09 21:37:48 +00:00
|
|
|
$PAGE->set_heading(format_string($course->fullname));
|
2009-09-24 06:11:39 +00:00
|
|
|
$PAGE->set_title(get_string('modulename', 'feedback').' '.get_string('activities'));
|
|
|
|
echo $OUTPUT->header();
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
/// Get all the appropriate data
|
2009-09-07 08:10:42 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
if (! $feedbacks = get_all_instances_in_course("feedback", $course)) {
|
2011-10-28 00:30:42 +02:00
|
|
|
$url = new moodle_url('/course/view.php', array('id'=>$course->id));
|
|
|
|
notice(get_string('thereareno', 'moodle', $strfeedbacks), $url);
|
2009-09-24 06:11:39 +00:00
|
|
|
die;
|
|
|
|
}
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2010-06-08 06:21:25 +00:00
|
|
|
$usesections = course_format_uses_sections($course->format);
|
|
|
|
if ($usesections) {
|
|
|
|
$sections = get_all_sections($course->id);
|
|
|
|
}
|
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
/// Print the list of instances (your module will probably extend this)
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
$timenow = time();
|
|
|
|
$strname = get_string("name");
|
2010-06-08 06:21:25 +00:00
|
|
|
$strsectionname = get_string('sectionname', 'format_'.$course->format);
|
2009-09-24 06:11:39 +00:00
|
|
|
$strresponses = get_string('responses', 'feedback');
|
|
|
|
|
|
|
|
$table = new html_table();
|
|
|
|
|
2010-06-08 06:21:25 +00:00
|
|
|
if ($usesections) {
|
2011-10-28 00:30:42 +02:00
|
|
|
if (has_capability('mod/feedback:viewreports', $context)) {
|
2010-06-08 06:21:25 +00:00
|
|
|
$table->head = array ($strsectionname, $strname, $strresponses);
|
2009-09-24 06:11:39 +00:00
|
|
|
$table->align = array ("center", "left", 'center');
|
2011-10-28 00:30:42 +02:00
|
|
|
} else {
|
2010-06-08 06:21:25 +00:00
|
|
|
$table->head = array ($strsectionname, $strname);
|
2009-09-24 06:11:39 +00:00
|
|
|
$table->align = array ("center", "left");
|
|
|
|
}
|
|
|
|
} else {
|
2011-10-28 00:30:42 +02:00
|
|
|
if (has_capability('mod/feedback:viewreports', $context)) {
|
2009-09-24 06:11:39 +00:00
|
|
|
$table->head = array ($strname, $strresponses);
|
|
|
|
$table->align = array ("left", "center");
|
2011-10-28 00:30:42 +02:00
|
|
|
} else {
|
2009-09-24 06:11:39 +00:00
|
|
|
$table->head = array ($strname);
|
|
|
|
$table->align = array ("left");
|
2008-04-23 09:33:54 +00:00
|
|
|
}
|
2009-09-24 06:11:39 +00:00
|
|
|
}
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
|
|
|
|
foreach ($feedbacks as $feedback) {
|
|
|
|
//get the responses of each feedback
|
2010-03-28 15:29:49 +00:00
|
|
|
$viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$feedback->coursemodule));
|
2009-09-24 06:11:39 +00:00
|
|
|
|
2011-10-28 00:30:42 +02:00
|
|
|
if (has_capability('mod/feedback:viewreports', $context)) {
|
|
|
|
$completed_feedback_count = intval(feedback_get_completeds_group_count($feedback));
|
2009-09-24 06:11:39 +00:00
|
|
|
}
|
|
|
|
|
2010-03-28 15:29:49 +00:00
|
|
|
$dimmedclass = $feedback->visible ? '' : 'class="dimmed"';
|
|
|
|
$link = '<a '.$dimmedclass.' href="'.$viewurl->out().'">'.$feedback->name.'</a>';
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2010-06-08 06:21:25 +00:00
|
|
|
if ($usesections) {
|
|
|
|
$tabledata = array (get_section_name($course, $sections[$feedback->section]), $link);
|
2009-09-24 06:11:39 +00:00
|
|
|
} else {
|
|
|
|
$tabledata = array ($link);
|
|
|
|
}
|
2011-10-28 00:30:42 +02:00
|
|
|
if (has_capability('mod/feedback:viewreports', $context)) {
|
|
|
|
$tabledata[] = $completed_feedback_count;
|
2008-04-23 09:33:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
$table->data[] = $tabledata;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "<br />";
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2010-03-20 22:15:54 +00:00
|
|
|
echo html_writer::table($table);
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
/// Finish the page
|
2008-04-23 09:33:54 +00:00
|
|
|
|
2009-09-24 06:11:39 +00:00
|
|
|
echo $OUTPUT->footer();
|
2008-04-23 09:33:54 +00:00
|
|
|
|