MDL-10011 cleanup xhtml and code in report.php - forum, glossary and data mod
This commit is contained in:
+22
-14
@@ -5,26 +5,32 @@
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
$id = required_param('id',PARAM_INT);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$sort = optional_param('sort', '', PARAM_ALPHA);
|
||||
|
||||
if (!$record = get_record('data_records', 'id', $id)) {
|
||||
error("Record ID is incorrect");
|
||||
}
|
||||
|
||||
if (!$data = get_record('data', 'id', $record->dataid)) {
|
||||
error("Data ID is incorrect");
|
||||
}
|
||||
|
||||
if (!$course = get_record('course', 'id', $data->course)) {
|
||||
error("Course is misconfigured");
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (!$data->assessed) {
|
||||
error("This activity does not use ratings");
|
||||
}
|
||||
|
||||
if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) {
|
||||
error("You can not view ratings");
|
||||
}
|
||||
@@ -37,9 +43,9 @@
|
||||
|
||||
$scalemenu = make_grades_menu($data->scale);
|
||||
|
||||
$strratings = get_string("ratings", "data");
|
||||
$strrating = get_string("rating", "data");
|
||||
$strname = get_string("name");
|
||||
$strratings = get_string('ratings', 'data');
|
||||
$strrating = get_string('rating', 'data');
|
||||
$strname = get_string('name');
|
||||
|
||||
print_header($strratings);
|
||||
|
||||
@@ -47,21 +53,23 @@
|
||||
error("No ratings for this record!");
|
||||
|
||||
} else {
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" width=\"100%\">";
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
|
||||
echo "<tr>";
|
||||
echo "<th scope=\"col\"> </th>";
|
||||
echo "<th scope=\"col\"><a href=\"report.php?id=$id&sort=firstname\">$strname</a>";
|
||||
echo "<th width=\"100%\" scope=\"col\"><a href=\"report.php?id=$id&sort=rating\">$strrating</a>";
|
||||
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>";
|
||||
print_user_picture($rating->id, $data->course, $rating->picture);
|
||||
echo '<td nowrap="nowrap"><p><font size="-1">'.fullname($rating).'</p>';
|
||||
echo '<td nowrap="nowrap" align="center"><p><font size="-1">'.$scalemenu[$rating->rating]."</p>";
|
||||
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>";
|
||||
@@ -69,5 +77,5 @@
|
||||
}
|
||||
|
||||
close_window_button();
|
||||
|
||||
print_footer('none');
|
||||
?>
|
||||
|
||||
+34
-27
@@ -5,67 +5,76 @@
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
$id = required_param('id',PARAM_INT);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$sort = optional_param('sort', '', PARAM_ALPHA);
|
||||
|
||||
if (! $post = get_record("forum_posts", "id", $id)) {
|
||||
if (! $post = get_record('forum_posts', 'id', $id)) {
|
||||
error("Post ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
|
||||
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
|
||||
error("Discussion ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $forum = get_record("forum", "id", $discussion->forum)) {
|
||||
if (! $forum = get_record('forum', 'id', $discussion->forum)) {
|
||||
error("Forum ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $forum->course)) {
|
||||
if (! $course = get_record('course', 'id', $forum->course)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
|
||||
if (! $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
|
||||
require_login($course, false, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
|
||||
if (!$forum->assessed) {
|
||||
error("This activity does not use ratings");
|
||||
}
|
||||
|
||||
if (!has_capability('mod/forum:viewrating', $context)) {
|
||||
error('You do not have the capability to view post ratings');
|
||||
error("You do not have the capability to view post ratings");
|
||||
}
|
||||
if (!has_capability('mod/forum:viewanyrating', $context) and $USER->id != $post->userid) {
|
||||
error("You can only look at results for posts that you made");
|
||||
}
|
||||
|
||||
if (!isset($sort)) {
|
||||
$sort = "r.time";
|
||||
switch ($sort) {
|
||||
case 'firstname': $sqlsort = "u.firstname ASC"; break;
|
||||
case 'rating': $sqlsort = "r.rating ASC"; break;
|
||||
default: $sqlsort = "r.time ASC";
|
||||
}
|
||||
|
||||
$scalemenu = make_grades_menu($forum->scale);
|
||||
|
||||
$strratings = get_string("ratings", "forum");
|
||||
$strrating = get_string("rating", "forum");
|
||||
$strname = get_string("name");
|
||||
$strtime = get_string("time");
|
||||
$strratings = get_string('ratings', 'forum');
|
||||
$strrating = get_string('rating', 'forum');
|
||||
$strname = get_string('name');
|
||||
$strtime = get_string('time');
|
||||
|
||||
print_header("$strratings: ".format_string($post->subject));
|
||||
|
||||
if (!$ratings = forum_get_ratings($post->id, $sort)) {
|
||||
if (!$ratings = forum_get_ratings($post->id, $sqlsort)) {
|
||||
error("No ratings for this post: \"".format_string($post->subject)."\"");
|
||||
|
||||
} else {
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" width=\"100%\">";
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
|
||||
echo "<tr>";
|
||||
echo "<th scope=\"col\"> </th>";
|
||||
echo "<th scope=\"col\"><a href=\"report.php?id=$post->id&sort=u.firstname\">$strname</a></th>";
|
||||
echo "<th width=\"100%\" scope=\"col\"><a href=\"report.php?id=$post->id&sort=r.rating\">$strrating</a></th>";
|
||||
echo "<th scope=\"col\"><a href=\"report.php?id=$post->id&sort=r.time\">$strtime</a></th></tr>";
|
||||
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>";
|
||||
foreach ($ratings as $rating) {
|
||||
echo '<tr class="forumpostheader">';
|
||||
echo "<td>";
|
||||
print_user_picture($rating->id, $forum->course, $rating->picture);
|
||||
echo '</td><td nowrap="nowrap"><p>'.fullname($rating).'</p></td>';
|
||||
echo '<td nowrap="nowrap" align="center"><p>'.$scalemenu[$rating->rating]."</p></td>";
|
||||
echo '<td nowrap="nowrap" align="center"><p>'.userdate($rating->time)."</p></td>";
|
||||
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>";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>";
|
||||
@@ -73,7 +82,5 @@
|
||||
}
|
||||
|
||||
close_window_button();
|
||||
|
||||
print_footer('none');
|
||||
|
||||
?>
|
||||
|
||||
+22
-15
@@ -1,34 +1,41 @@
|
||||
<?php // $Id$
|
||||
|
||||
// For a given entry, 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_RAW);
|
||||
$sort = optional_param('sort', '', PARAM_ALPHA);
|
||||
|
||||
if (! $entry = get_record("glossary_entries", "id", $id)) {
|
||||
if (! $entry = get_record('glossary_entries', 'id', $id)) {
|
||||
error("Entry ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $entry->glossaryid)) {
|
||||
if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
|
||||
error("Glossary ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $glossary->course)) {
|
||||
if (! $course = get_record('course', 'id', $glossary->course)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
$module = get_record("modules","name","glossary");
|
||||
$cm = get_record("course_modules","module",$module->id,"instance",$entry->glossaryid);
|
||||
|
||||
if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course, false, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
|
||||
if (!$glossary->assessed) {
|
||||
error("This activity does not use ratings");
|
||||
}
|
||||
|
||||
if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) {
|
||||
error("You can only look at results for your own entries");
|
||||
}
|
||||
|
||||
switch ($sort) {
|
||||
case 'time': $sqlsort = "r.time ASC"; break;
|
||||
case 'firstname': $sqlsort = "u.firstname ASC"; break;
|
||||
case 'rating': $sqlsort = "r.rating ASC"; break;
|
||||
default: $sqlsort = "r.time ASC";
|
||||
@@ -36,10 +43,10 @@
|
||||
|
||||
$scalemenu = make_grades_menu($glossary->scale);
|
||||
|
||||
$strratings = get_string("ratings", "glossary");
|
||||
$strrating = get_string("rating", "glossary");
|
||||
$strname = get_string("name");
|
||||
$strtime = get_string("time");
|
||||
$strratings = get_string('ratings', 'glossary');
|
||||
$strrating = get_string('rating', 'glossary');
|
||||
$strname = get_string('name');
|
||||
$strtime = get_string('time');
|
||||
|
||||
print_header("$strratings: $entry->concept");
|
||||
|
||||
@@ -47,7 +54,7 @@
|
||||
error("No ratings for this entry: \"$entry->concept\"");
|
||||
|
||||
} else {
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" width=\"100%\">";
|
||||
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=$entry->id&sort=firstname\">$strname</a></th>";
|
||||
@@ -73,5 +80,5 @@
|
||||
}
|
||||
|
||||
close_window_button();
|
||||
print_footer();
|
||||
print_footer('none');
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user