MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / glossary / report.php
blob93496ca6379856d1127453e03df1f74819dbcd39
1 <?php // $Id$
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");
38 switch ($sort) {
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\"");
56 } else {
57 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
58 echo "<tr>";
59 echo "<th class=\"header\" scope=\"col\">&nbsp;</th>";
60 echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$entry->id&amp;sort=firstname\">$strname</a></th>";
61 echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id=$entry->id&amp;sort=rating\">$strrating</a></th>";
62 echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$entry->id&amp;sort=time\">$strtime</a></th>";
63 echo "</tr>";
64 foreach ($ratings as $rating) {
65 if (has_capability('mod/glossary:manageentries', $context)) {
66 echo '<tr class="teacher">';
67 } else {
68 echo '<tr>';
70 echo '<td class="picture">';
71 print_user_picture($rating->id, $glossary->course, $rating->picture, false, false, true);
72 echo '</td>';
73 echo '<td class="author"><a href="'.$CFG->wwwroot.'/user/view.php?id='.$rating->id.'&amp;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>';
76 echo "</tr>\n";
78 echo "</table>";
79 echo "<br />";
82 close_window_button();
83 print_footer('none');