moodle/mod/forum/rate.php
moodler ebc3bd2b24 Changes throughout Moodle to remove any reserved words from the
Moodle tables.

ie user -> userid in many tables, plus in user_students
   start -> starttime and end -> endtime

I've just done all this as carefully as I could ... I don't think
I missed anything but it's pretty intensive work and I'd be fooling myself
if I didn't think I'd missed a couple.

Note that this version should pretty much be able to bootstrap itself
using PostgreSQL now ... but this is untested
2002-12-23 09:39:26 +00:00

49 lines
1.4 KiB
PHP

<?PHP // $Id$
// Collect ratings, store them, then return to where we came from
require("../../config.php");
require("lib.php");
if (isguest()) {
error("Guests are not allowed to rate posts.", $HTTP_REFERER);
}
require_variable($id); // The course these ratings are part of
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
}
require_login($course->id);
if (isset($HTTP_POST_VARS)) { // form submitted
foreach ($HTTP_POST_VARS as $post => $rating) {
if ($post == "id") {
continue;
}
if ($rating) {
if (record_exists("forum_ratings", "userid", $USER->id, "post", $post)) {
error("You've rated this question before ($post)");
} else {
unset($newrating);
$newrating->userid = $USER->id;
$newrating->time = time();
$newrating->post = $post;
$newrating->rating = $rating;
if (! insert_record("forum_ratings", $newrating)) {
error("Could not insert a new rating ($post = $rating)");
}
}
}
}
redirect($HTTP_REFERER, "Ratings saved");
} else {
error("This page was not accessed correctly");
}
?>