3 // For a given entry, 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
);
9 $sort = optional_param('sort', '', PARAM_ALPHA
);
11 if (! $entry = get_record('glossary_entries', 'id', $id)) {
12 error("Entry ID was incorrect");
15 if (! $glossary = get_record('glossary', 'id', $entry->glossaryid
)) {
16 error("Glossary ID was incorrect");
19 if (! $course = get_record('course', 'id', $glossary->course
)) {
20 error("Course ID was incorrect");
23 if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id
, $course->id
)) {
24 error("Course Module ID was incorrect");
27 require_login($course, false, $cm);
28 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
30 if (!$glossary->assessed
) {
31 error("This activity does not use ratings");
34 if (!has_capability('mod/glossary:manageentries', $context) and $USER->id
!= $entry->userid
) {
35 error("You can only look at results for your own entries");
39 case 'firstname': $sqlsort = "u.firstname ASC"; break;
40 case 'rating': $sqlsort = "r.rating ASC"; break;
41 default: $sqlsort = "r.time ASC";
44 $scalemenu = make_grades_menu($glossary->scale
);
46 $strratings = get_string('ratings', 'glossary');
47 $strrating = get_string('rating', 'glossary');
48 $strname = get_string('name');
49 $strtime = get_string('time');
51 print_header("$strratings: $entry->concept");
53 if (!$ratings = glossary_get_ratings($entry->id
, $sqlsort)) {
54 error("No ratings for this entry: \"$entry->concept\"");
57 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
59 echo "<th class=\"header\" scope=\"col\"> </th>";
60 echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$entry->id&sort=firstname\">$strname</a></th>";
61 echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id=$entry->id&sort=rating\">$strrating</a></th>";
62 echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$entry->id&sort=time\">$strtime</a></th>";
64 foreach ($ratings as $rating) {
65 if (has_capability('mod/glossary:manageentries', $context)) {
66 echo '<tr class="teacher">';
70 echo '<td class="picture">';
71 print_user_picture($rating->id
, $glossary->course
, $rating->picture
, false, false, true);
73 echo '<td class="author"><a href="'.$CFG->wwwroot
.'/user/view.php?id='.$rating->id
.'&course='.$glossary->course
.'">'.fullname($rating).'</a></td>';
74 echo '<td style="white-space:nowrap" align="center" class="rating">'.$scalemenu[$rating->rating
].'</td>';
75 echo '<td style="white-space:nowrap" align="center" class="time">'.userdate($rating->time
).'</td>';
82 close_window_button();