mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
82 lines
2.9 KiB
PHP
Executable File
82 lines
2.9 KiB
PHP
Executable File
<?php // $Id$
|
|
|
|
// For a given post, shows a report of all the ratings it has
|
|
|
|
require_once("../../config.php");
|
|
require_once("lib.php");
|
|
|
|
$id = required_param('id', PARAM_INT);
|
|
$sort = optional_param('sort', '', PARAM_ALPHA);
|
|
|
|
if (!$record = $DB->get_record('data_records', array('id'=>$id))) {
|
|
print_error('invalidrecord', 'data');
|
|
}
|
|
|
|
if (!$data = $DB->get_record('data', array('id'=>$record->dataid))) {
|
|
print_error('invalidid', 'data');
|
|
}
|
|
|
|
if (!$course = $DB->get_record('course', array('id'=>$data->course))) {
|
|
print_error('coursemisconf');
|
|
}
|
|
|
|
if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
|
print_error('invalidcoursemodule');
|
|
}
|
|
|
|
require_login($course->id, false, $cm);
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
|
|
if (!$data->assessed) {
|
|
print_error('norating', 'data');
|
|
}
|
|
|
|
if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) {
|
|
print_error('cannotviewrate', 'data');
|
|
}
|
|
|
|
switch ($sort) {
|
|
case 'firstname': $sqlsort = "u.firstname ASC"; break;
|
|
case 'rating': $sqlsort = "r.rating ASC"; break;
|
|
default: $sqlsort = "r.id ASC";
|
|
}
|
|
|
|
$scalemenu = make_grades_menu($data->scale);
|
|
|
|
$strratings = get_string('ratings', 'data');
|
|
$strrating = get_string('rating', 'data');
|
|
$strname = get_string('name');
|
|
|
|
print_header($strratings);
|
|
|
|
if (!$ratings = data_get_ratings($record->id, $sqlsort)) {
|
|
print_error('noratingforrecord', 'data');
|
|
|
|
} else {
|
|
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
|
|
echo "<tr>";
|
|
echo "<th class=\"header\" scope=\"col\"> </th>";
|
|
echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$record->id&sort=firstname\">$strname</a></th>";
|
|
echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id=$id&sort=rating\">$strrating</a></th>";
|
|
echo "</tr>";
|
|
foreach ($ratings as $rating) {
|
|
if (has_capability('mod/data:manageentries', $context)) {
|
|
echo '<tr class="forumpostheadertopic">';
|
|
} else {
|
|
echo '<tr class="forumpostheader">';
|
|
}
|
|
echo '<td class="picture">';
|
|
print_user_picture($rating->id, $data->course, $rating->picture, false, false, true);
|
|
echo '</td>';
|
|
echo '<td class="author"><a href="'.$CFG->wwwroot.'/user/view.php?id='.$rating->id.'&course='.$data->course.'">'.fullname($rating).'</a></td>';
|
|
echo '<td style="white-space:nowrap" align="center" class="rating">'.$scalemenu[$rating->rating].'</td>';
|
|
echo "</tr>\n";
|
|
}
|
|
echo "</table>";
|
|
echo "<br />";
|
|
}
|
|
|
|
close_window_button();
|
|
print_footer('none');
|
|
?>
|