2004-09-12 16:24:41 +00:00
|
|
|
<?php // $Id$
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
// For a given post, shows a report of all the ratings it has
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2007-06-03 16:17:39 +00:00
|
|
|
$id = required_param('id', PARAM_INT);
|
|
|
|
$sort = optional_param('sort', '', PARAM_ALPHA);
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2008-06-05 20:16:09 +00:00
|
|
|
if (! $post = $DB->get_record('forum_posts', array('id' => $id))) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('invalidpostid','forum');
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 20:16:09 +00:00
|
|
|
if (! $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion))) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('invaliddiscussion', 'forum');
|
2002-08-02 17:35:40 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 20:16:09 +00:00
|
|
|
if (! $forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('invalidforumid', 'forum');
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 20:16:09 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id' => $forum->course))) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('invalidcourseid');
|
2002-10-21 08:44:56 +00:00
|
|
|
}
|
2007-06-03 16:17:39 +00:00
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2006-08-08 05:13:06 +00:00
|
|
|
}
|
2007-06-03 16:17:39 +00:00
|
|
|
|
|
|
|
require_login($course, false, $cm);
|
2006-08-08 05:13:06 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2007-06-03 16:17:39 +00:00
|
|
|
|
|
|
|
if (!$forum->assessed) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('norate', 'forum');
|
2007-06-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
if (!has_capability('mod/forum:viewrating', $context)) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('noviewrate', 'forum');
|
2006-08-08 05:13:06 +00:00
|
|
|
}
|
2006-08-14 05:55:40 +00:00
|
|
|
if (!has_capability('mod/forum:viewanyrating', $context) and $USER->id != $post->userid) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('noviewanyrate', 'forum');
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2007-06-03 16:17:39 +00:00
|
|
|
switch ($sort) {
|
|
|
|
case 'firstname': $sqlsort = "u.firstname ASC"; break;
|
|
|
|
case 'rating': $sqlsort = "r.rating ASC"; break;
|
|
|
|
default: $sqlsort = "r.time ASC";
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2003-08-25 15:59:39 +00:00
|
|
|
$scalemenu = make_grades_menu($forum->scale);
|
2003-08-15 13:59:24 +00:00
|
|
|
|
2007-06-03 16:17:39 +00:00
|
|
|
$strratings = get_string('ratings', 'forum');
|
|
|
|
$strrating = get_string('rating', 'forum');
|
|
|
|
$strname = get_string('name');
|
|
|
|
$strtime = get_string('time');
|
2003-08-15 13:59:24 +00:00
|
|
|
|
2005-03-26 11:43:16 +00:00
|
|
|
print_header("$strratings: ".format_string($post->subject));
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2007-06-03 16:17:39 +00:00
|
|
|
if (!$ratings = forum_get_ratings($post->id, $sqlsort)) {
|
2008-05-27 04:45:01 +00:00
|
|
|
print_error('noresult', 'forum', '', format_string($post->subject));
|
2003-08-15 13:59:24 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2007-06-03 16:17:39 +00:00
|
|
|
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
|
2003-08-15 13:59:24 +00:00
|
|
|
echo "<tr>";
|
2007-06-03 16:17:39 +00:00
|
|
|
echo "<th class=\"header\" scope=\"col\"> </th>";
|
|
|
|
echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$post->id&sort=firstname\">$strname</a></th>";
|
|
|
|
echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id=$post->id&sort=rating\">$strrating</a></th>";
|
|
|
|
echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$post->id&sort=time\">$strtime</a></th>";
|
|
|
|
echo "</tr>";
|
2002-07-31 14:19:35 +00:00
|
|
|
foreach ($ratings as $rating) {
|
2006-08-08 05:13:06 +00:00
|
|
|
echo '<tr class="forumpostheader">';
|
2003-08-15 13:59:24 +00:00
|
|
|
echo "<td>";
|
2002-08-02 17:35:40 +00:00
|
|
|
print_user_picture($rating->id, $forum->course, $rating->picture);
|
2007-06-03 16:17:39 +00:00
|
|
|
echo '</td><td>'.fullname($rating).'</td>';
|
|
|
|
echo '<td style="white-space:nowrap" align="center" class="rating">'.$scalemenu[$rating->rating]."</td>";
|
|
|
|
echo '<td style="white-space:nowrap" align="center" class="time">'.userdate($rating->time)."</td>";
|
2003-08-15 13:59:24 +00:00
|
|
|
echo "</tr>\n";
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2003-08-15 13:59:24 +00:00
|
|
|
echo "</table>";
|
|
|
|
echo "<br />";
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
close_window_button();
|
2007-06-03 15:31:30 +00:00
|
|
|
print_footer('none');
|
2002-07-31 14:19:35 +00:00
|
|
|
?>
|