3 // For a given post, shows a report of all the ratings it has
5 require_once("../../config.php");
6 require_once("lib.php");
8 $id = required_param('id',PARAM_INT
);
10 if (! $post = get_record("forum_posts", "id", $id)) {
11 error("Post ID was incorrect");
14 if (! $discussion = get_record("forum_discussions", "id", $post->discussion
)) {
15 error("Discussion ID was incorrect");
18 if (! $forum = get_record("forum", "id", $discussion->forum
)) {
19 error("Forum ID was incorrect");
22 if (! $course = get_record("course", "id", $forum->course
)) {
23 error("Course ID was incorrect");
26 if (! $cm = get_coursemodule_from_instance('forum', $forum->id
, $course->id
)) {
27 error('Course Module ID was incorrect');
30 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
32 if (!has_capability('mod/forum:viewrating', $context)) {
33 error('You do not have the capability to view post ratings');
35 if (!has_capability('mod/forum:viewanyrating', $context) and $USER->id
!= $post->userid
) {
36 error("You can only look at results for posts that you made");
43 $scalemenu = make_grades_menu($forum->scale
);
45 $strratings = get_string("ratings", "forum");
46 $strrating = get_string("rating", "forum");
47 $strname = get_string("name");
48 $strtime = get_string("time");
50 print_header("$strratings: ".format_string($post->subject
));
52 if (!$ratings = forum_get_ratings($post->id
, $sort)) {
53 error("No ratings for this post: \"".format_string($post->subject
)."\"");
56 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" width=\"100%\">";
58 echo "<th scope=\"col\"> </th>";
59 echo "<th scope=\"col\"><a href=\"report.php?id=$post->id&sort=u.firstname\">$strname</a>";
60 echo "<th width=\"100%\" scope=\"col\"><a href=\"report.php?id=$post->id&sort=r.rating\">$strrating</a>";
61 echo "<th scope=\"col\"><a href=\"report.php?id=$post->id&sort=r.time\">$strtime</a>";
62 foreach ($ratings as $rating) {
63 echo '<tr class="forumpostheader">';
65 print_user_picture($rating->id
, $forum->course
, $rating->picture
);
66 echo '<td nowrap="nowrap"><p><font size="-1">'.fullname($rating).'</p>';
67 echo '<td nowrap="nowrap" align="center"><p><font size="-1">'.$scalemenu[$rating->rating
]."</p>";
68 echo '<td nowrap="nowrap" align="center"><p><font size="-1">'.userdate($rating->time
)."</p>";
75 close_window_button();