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
This commit is contained in:
moodler 2002-12-23 09:39:26 +00:00
parent 1f48942e7d
commit ebc3bd2b24
68 changed files with 277 additions and 461 deletions

View file

@ -88,6 +88,9 @@ function assignment_upgrade($oldversion) {
if ($oldversion < 2002111500) {
execute_sql(" ALTER TABLE `assignment` ADD `resubmit` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `format` ");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `assignment_submissions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -25,7 +25,7 @@ CREATE TABLE `prefix_assignment` (
CREATE TABLE `prefix_assignment_submissions` (
`id` int(10) unsigned NOT NULL auto_increment,
`assignment` int(10) unsigned NOT NULL default '0',
`user` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`timecreated` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0',
`numfiles` int(10) unsigned NOT NULL default '0',

View file

@ -23,7 +23,7 @@ CREATE TABLE assignment (
CREATE TABLE assignment_submissions (
id SERIAL PRIMARY KEY,
assignment integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
timecreated integer NOT NULL default '0',
timemodified integer NOT NULL default '0',
numfiles integer NOT NULL default '0',

View file

@ -119,8 +119,8 @@ function assignment_cron () {
echo "Processing assignment submission $submission->id\n";
if (! $user = get_record("user", "id", "$submission->user")) {
echo "Could not find user $post->user\n";
if (! $user = get_record("user", "id", "$submission->userid")) {
echo "Could not find user $post->userid\n";
continue;
}
@ -215,7 +215,7 @@ function assignment_grades($assignmentid) {
/// Must return an array of grades, indexed by user, and a max grade.
$return->grades = get_records_menu("assignment_submissions", "assignment",
$assignmentid, "", "user,grade");
$assignmentid, "", "userid,grade");
$return->maxgrade = get_field("assignment", "grade", "id", "$assignmentid");
return $return;
}
@ -228,7 +228,7 @@ function assignment_log_info($log) {
FROM {$CFG->prefix}assignment a,
{$CFG->prefix}user u
WHERE a.id = '$log->info'
AND u.id = '$log->user'");
AND u.id = '$log->userid'");
}
function assignment_get_all_submissions($assignment) {
@ -237,7 +237,7 @@ function assignment_get_all_submissions($assignment) {
return get_records_sql("SELECT a.*
FROM {$CFG->prefix}assignment_submissions a,
{$CFG->prefix}user_students s
WHERE a.user = s.user
WHERE a.userid = s.userid
AND s.course = '$assignment->course'
AND a.assignment = '$assignment->id'
ORDER BY a.timemodified DESC");
@ -251,8 +251,8 @@ function assignment_get_users_done($assignment) {
{$CFG->prefix}user_students s,
{$CFG->prefix}assignment_submissions a
WHERE s.course = '$assignment->course'
AND s.user = u.id
AND u.id = a.user
AND s.userid = u.id
AND u.id = a.userid
AND a.assignment = '$assignment->id'
ORDER BY a.timemodified DESC");
}
@ -284,7 +284,7 @@ function assignment_file_area($assignment, $user) {
}
function assignment_get_submission($assignment, $user) {
return get_record("assignment_submissions", "assignment", $assignment->id, "user", $user->id);
return get_record("assignment_submissions", "assignment", $assignment->id, "userid", $user->id);
}
function assignment_print_difference($time) {

View file

@ -48,7 +48,7 @@
/// Make some easy ways to reference submissions
if ($submissions = assignment_get_all_submissions($assignment)) {
foreach ($submissions as $submission) {
$submissionbyuser[$submission->user] = $submission;
$submissionbyuser[$submission->userid] = $submission;
}
}
@ -56,7 +56,7 @@
foreach($users as $user) {
if (!isset($submissionbyuser[$user->id])) { // Need to create empty entry
$newsubmission->assignment = $assignment->id;
$newsubmission->user = $user->id;
$newsubmission->userid = $user->id;
$newsubmission->timecreated = time();
if (!insert_record("assignment_submissions", $newsubmission)) {
error("Could not insert a new empty submission");
@ -97,7 +97,7 @@
$newsubmission->mailed = 0; // Make sure mail goes out (again, even)
$newsubmission->id = $num;
if (! update_record("assignment_submissions", $newsubmission)) {
notify(get_string("failedupdatefeedback", "assignment", $submission->user));
notify(get_string("failedupdatefeedback", "assignment", $submission->userid));
} else {
$count++;
}
@ -117,7 +117,7 @@
echo "<FORM ACTION=submissions.php METHOD=post>\n";
foreach ($submissions as $submission) {
$user = $users[$submission->user];
$user = $users[$submission->userid];
assignment_print_submission($assignment, $user, $submission, $teachers, $grades);
}

View file

@ -59,7 +59,7 @@
}
} else {
$newsubmission->assignment = $assignment->id;
$newsubmission->user = $USER->id;
$newsubmission->userid = $USER->id;
$newsubmission->timecreated = time();
$newsubmission->timemodified = time();
$newsubmission->numfiles = 1;

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002111500;
$module->version = 2002122300;
$module->cron = 60;
?>

View file

@ -14,6 +14,9 @@ function choice_upgrade($oldversion) {
execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`");
execute_sql(" ALTER TABLE `choice` ADD `answer6` varchar(255) NOT NULL AFTER `answer5`");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `choice_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -40,7 +40,7 @@ CREATE TABLE prefix_choice (
CREATE TABLE prefix_choice_answers (
id int(10) unsigned NOT NULL auto_increment,
choice int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
answer tinyint(4) NOT NULL default '0',
timemodified int(10) NOT NULL default '0',
PRIMARY KEY (id),

View file

@ -4,16 +4,6 @@ function choice_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
if ($oldversion < 2002090800) {
execute_sql(" ALTER TABLE `choice` CHANGE `answer1` `answer1` VARCHAR( 255 )");
execute_sql(" ALTER TABLE `choice` CHANGE `answer2` `answer2` VARCHAR( 255 )");
}
if ($oldversion < 2002102400) {
execute_sql(" ALTER TABLE `choice` ADD `answer3` varchar(255) NOT NULL AFTER `answer2`");
execute_sql(" ALTER TABLE `choice` ADD `answer4` varchar(255) NOT NULL AFTER `answer3`");
execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`");
execute_sql(" ALTER TABLE `choice` ADD `answer6` varchar(255) NOT NULL AFTER `answer5`");
}
return true;
}

View file

@ -38,7 +38,7 @@ CREATE TABLE choice (
CREATE TABLE choice_answers (
id SERIAL PRIMARY KEY,
choice integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
answer integer NOT NULL default '0',
timemodified integer NOT NULL default '0'
);

View file

@ -28,7 +28,7 @@
notice("There are no choices", "../../course/view.php?id=$course->id");
}
if ( $allanswers = get_records("choice_answers", "user", $USER->id)) {
if ( $allanswers = get_records("choice_answers", "userid", $USER->id)) {
foreach ($allanswers as $aa) {
$answers[$aa->choice] = $aa;
}

View file

@ -3,7 +3,7 @@
$CHOICE_MAX_NUMBER = 6;
function choice_user_outline($course, $user, $mod, $choice) {
if ($current = get_record("choice_answers", "choice", $choice->id, "user", $user->id)) {
if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $user->id)) {
$result->info = "'".choice_get_answer($choice, $current->answer)."'";
$result->time = $current->timemodified;
return $result;
@ -13,7 +13,7 @@ function choice_user_outline($course, $user, $mod, $choice) {
function choice_user_complete($course, $user, $mod, $choice) {
if ($current = get_record("choice_answers", "choice", $choice->id, "user", $user->id)) {
if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $user->id)) {
$result->info = "'".choice_get_answer($choice, $current->answer)."'";
$result->time = $current->timemodified;
echo get_string("answered", "choice").": $result->info , last updated ".userdate($result->time);

View file

@ -41,7 +41,7 @@
if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
foreach ($allanswers as $aa) {
$answers[$aa->user] = $aa;
$answers[$aa->userid] = $aa;
}
} else {
$answers = array () ;

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002102400;
$module->version = 2002122300;
$module->cron = 0;
?>

View file

@ -19,7 +19,7 @@
error("Course module is incorrect");
}
if ($current = get_record("choice_answers", "choice", $choice->id, "user", $USER->id)) {
if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $USER->id)) {
$answerchecked[$current->answer] = "CHECKED";
}
@ -36,7 +36,7 @@
add_to_log($course->id, "choice", "update", "view.php?id=$cm->id", "$choice->id");
} else {
$newanswer->choice = $choice->id;
$newanswer->user = $USER->id;
$newanswer->userid = $USER->id;
$newanswer->answer = $form->answer;
$newanswer->timemodified = $timenow;
if (! insert_record("choice_answers", $newanswer)) {

View file

@ -50,6 +50,12 @@ function forum_upgrade($oldversion) {
execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` ");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `forum_posts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `forum_ratings` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `forum_subscriptions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -41,7 +41,7 @@ CREATE TABLE prefix_forum_posts (
id int(10) unsigned NOT NULL auto_increment,
discussion int(10) unsigned NOT NULL default '0',
parent int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
created int(10) unsigned NOT NULL default '0',
modified int(10) unsigned NOT NULL default '0',
mailed tinyint(1) unsigned NOT NULL default '0',
@ -60,7 +60,7 @@ CREATE TABLE prefix_forum_posts (
CREATE TABLE prefix_forum_ratings (
id int(10) unsigned NOT NULL auto_increment,
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
post int(10) unsigned NOT NULL default '0',
time int(10) unsigned NOT NULL default '0',
rating tinyint(4) NOT NULL default '0',
@ -74,7 +74,7 @@ CREATE TABLE prefix_forum_ratings (
CREATE TABLE prefix_forum_subscriptions (
id int(10) unsigned NOT NULL auto_increment,
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
forum int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)

View file

@ -4,51 +4,7 @@ function forum_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
if ($oldversion < 2002073008) {
execute_sql("DELETE FROM modules WHERE name = 'discuss' ");
execute_sql("ALTER TABLE `discuss` RENAME `forum_discussions` ");
execute_sql("ALTER TABLE `discuss_posts` RENAME `forum_posts` ");
execute_sql("ALTER TABLE `discuss_ratings` RENAME `forum_ratings` ");
execute_sql("ALTER TABLE `forum` CHANGE `intro` `intro` TEXT NOT NULL ");
execute_sql("ALTER TABLE `forum` ADD `forcesubscribe` INTEGER DEFAULT '0' NOT NULL AFTER `assessed`");
execute_sql("ALTER TABLE `forum` CHANGE `type` `type` ENUM( 'single', 'news', 'social', 'general',
'eachuser', 'teacher' ) DEFAULT 'general' NOT NULL ");
execute_sql("ALTER TABLE `forum_posts` CHANGE `discuss` `discussion` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'add', 'forum', 'name') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'add discussion', 'forum_discussions', 'name') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'add post', 'forum_posts', 'subject') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'update post', 'forum_posts', 'subject') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'view discussion', 'forum_discussions', 'name') ");
execute_sql("DELETE FROM log_display WHERE module = 'discuss' ");
execute_sql("UPDATE log SET action = 'view discussion' WHERE module = 'discuss' AND action = 'view' ");
execute_sql("UPDATE log SET action = 'add discussion' WHERE module = 'discuss' AND action = 'add' ");
execute_sql("UPDATE log SET module = 'forum' WHERE module = 'discuss' ");
notify("Renamed all the old discuss tables (now part of forum) and created new forum_types");
}
if ($oldversion < 2002080100) {
execute_sql("INSERT INTO log_display VALUES ('forum', 'view subscribers', 'forum', 'name') ");
execute_sql("INSERT INTO log_display VALUES ('forum', 'update', 'forum', 'name') ");
}
if ($oldversion < 2002082900) {
execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ");
}
if ($oldversion < 2002091000) {
if (! execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ")) {
echo "<P>Don't worry about this error - your server already had this upgrade applied";
}
}
if ($oldversion < 2002100300) {
execute_sql(" ALTER TABLE `forum` CHANGE `open` `open` INTEGER DEFAULT '2' NOT NULL ");
execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 ");
execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 ");
}
if ($oldversion < 2002101001) {
execute_sql(" ALTER TABLE `forum_posts` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `message` ");
}
global $CFG;
return true;

View file

@ -38,7 +38,7 @@ CREATE TABLE forum_posts (
id SERIAL PRIMARY KEY,
discussion integer NOT NULL default '0',
parent integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
created integer NOT NULL default '0',
modified integer NOT NULL default '0',
mailed integer NOT NULL default '0',
@ -56,7 +56,7 @@ CREATE TABLE forum_posts (
CREATE TABLE forum_ratings (
id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
post integer NOT NULL default '0',
time integer NOT NULL default '0',
rating integer NOT NULL default '0'
@ -69,7 +69,7 @@ CREATE TABLE forum_ratings (
CREATE TABLE forum_subscriptions (
id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
forum integer NOT NULL default '0'
);
# --------------------------------------------------------

View file

@ -159,8 +159,8 @@ function forum_cron () {
print_string("processingpost", "forum", $post->id);
echo " ... ";
if (! $userfrom = get_record("user", "id", "$post->user")) {
echo "Could not find user $post->user\n";
if (! $userfrom = get_record("user", "id", "$post->userid")) {
echo "Could not find user $post->userid\n";
continue;
}
@ -349,7 +349,7 @@ function forum_grades($forumid) {
}
if ($ratings = forum_get_user_grades($forumid)) {
foreach ($ratings as $rating) {
$u = $rating->user;
$u = $rating->userid;
$r = $rating->rating;
if (!isset($sumrating[$u])) {
$sumrating[$u][1] = 0;
@ -376,34 +376,34 @@ function forum_get_post_full($postid) {
/// Gets a post with all info ready for forum_print_post
global $CFG;
return get_record_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
return get_record_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.id = '$postid'
AND p.user = u.id");
AND p.userid = u.id");
}
function forum_get_discussion_posts($discussion, $sort) {
/// Gets posts with all info ready for forum_print_post
global $CFG;
return get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.discussion = $discussion
AND p.parent > 0
AND p.user = u.id $sort");
AND p.userid = u.id $sort");
}
function forum_get_child_posts($parent) {
/// Gets posts with all info ready for forum_print_post
global $CFG;
return get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.parent = '$parent'
AND p.user = u.id
AND p.userid = u.id
ORDER BY p.created ASC");
}
@ -418,13 +418,13 @@ function forum_search_posts($search, $courseid) {
$notteacherforum = "";
}
return get_records_sql("SELECT p.*,u.firstname,u.lastname,u.email,u.picture,u.id as userid
return get_records_sql("SELECT p.*,u.firstname,u.lastname,u.email,u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}user u,
{$CFG->prefix}forum f
WHERE (p.message LIKE '%$search%' OR p.subject LIKE '%$search%')
AND p.user = u.id
AND p.userid = u.id
AND p.discussion = d.id
AND d.course = '$courseid'
AND d.forum = f.id
@ -439,7 +439,7 @@ function forum_get_ratings($postid, $sort="u.firstname ASC") {
FROM {$CFG->prefix}forum_ratings r,
{$CFG->prefix}user u
WHERE r.post = '$postid'
AND r.user = u.id
AND r.userid = u.id
ORDER BY $sort");
}
@ -458,7 +458,7 @@ function forum_get_user_posts($forumid, $userid) {
/// Get all the posts for a user in a forum suitable for forum_print_post
global $CFG;
return get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum f,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
@ -466,8 +466,8 @@ function forum_get_user_posts($forumid, $userid) {
WHERE f.id = '$forumid'
AND d.forum = f.id
AND p.discussion = d.id
AND p.user = '$userid'
AND p.user = u.id
AND p.userid = '$userid'
AND p.userid = u.id
ORDER BY p.modified ASC");
}
@ -477,25 +477,25 @@ function forum_get_post_from_log($log) {
if ($log->action == "add post") {
return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture, u.id as userid
return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.id = '$log->info'
AND d.id = p.discussion
AND p.user = u.id
AND p.userid = u.id
AND u.deleted <> '1'");
} else if ($log->action == "add discussion") {
return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture, u.id as userid
return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE d.id = '$log->info'
AND d.firstpost = p.id
AND p.user = u.id
AND p.userid = u.id
AND u.deleted <> '1'");
}
return NULL;
@ -506,7 +506,7 @@ function forum_get_user_grades($forumid) {
/// Get all user grades for a forum
global $CFG;
return get_records_sql("SELECT r.id, p.user, r.rating
return get_records_sql("SELECT r.id, p.userid, r.rating
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_ratings r
@ -538,14 +538,14 @@ function forum_count_unrated_posts($discussionid, $userid) {
FROM {$CFG->prefix}forum_posts
WHERE parent > 0
AND discussion = '$discussionid'
AND user <> '$userid' ")) {
AND userid <> '$userid' ")) {
if ($rated = get_record_sql("SELECT count(*) as num
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_ratings r
WHERE p.discussion = '$discussionid'
AND p.id = r.post
AND r.user = '$userid'")) {
AND r.userid = '$userid'")) {
$difference = $posts->num - $rated->num;
if ($difference > 0) {
return $difference;
@ -569,14 +569,14 @@ function forum_get_discussions($forum="0", $forum_sort="DESC", $user=0) {
} else {
$userselect = "";
}
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE d.forum = '$forum'
AND p.discussion = d.id
AND p.parent= 0
AND p.user = u.id $userselect
AND p.userid = u.id $userselect
ORDER BY p.created $forum_sort");
}
@ -587,7 +587,7 @@ function forum_get_user_discussions($courseid, $userid) {
global $CFG;
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture,
u.id as userid, f.type as forumtype, f.name as forumname, f.id as forumid
f.type as forumtype, f.name as forumname, f.id as forumid
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u,
@ -595,7 +595,7 @@ function forum_get_user_discussions($courseid, $userid) {
WHERE d.course = '$courseid'
AND p.discussion = d.id
AND p.parent = 0
AND p.user = u.id
AND p.userid = u.id
AND u.id = '$userid'
AND d.forum = f.id
ORDER BY p.created ASC");
@ -615,7 +615,7 @@ function forum_subscribed_users($course, $forum) {
FROM {$CFG->prefix}user u,
{$CFG->prefix}forum_subscriptions s
WHERE s.forum = '$forum->id'
AND s.user = u.id
AND s.userid = u.id
AND u.deleted <> 1");
}
@ -997,7 +997,7 @@ function forum_print_ratings($post) {
function forum_print_rating($post, $user) {
global $FORUM_POST_RATINGS;
if ($rating = get_record("forum_ratings", "user", $user, "post", $post)) {
if ($rating = get_record("forum_ratings", "userid", $user, "post", $post)) {
if ($FORUM_POST_RATINGS[$rating->rating]) {
echo "<FONT SIZE=-1>".get_string("youratedthis", "forum").": <FONT COLOR=green>";
echo $FORUM_POST_RATINGS[$rating->rating];
@ -1214,7 +1214,7 @@ function forum_add_discussion($discussion) {
$post->discussion = 0;
$post->parent = 0;
$post->user = $USER->id;
$post->userid = $USER->id;
$post->created = $timenow;
$post->modified = $timenow;
$post->mailed = 0;
@ -1333,13 +1333,13 @@ function forum_is_subscribed($userid, $forumid) {
if (forum_is_forcesubscribed($forumid)) {
return true;
}
return record_exists("forum_subscriptions", "user", $userid, "forum", $forumid);
return record_exists("forum_subscriptions", "userid", $userid, "forum", $forumid);
}
function forum_subscribe($userid, $forumid) {
/// Adds user to the subscriber list
$sub->user = $userid;
$sub->userid = $userid;
$sub->forum = $forumid;
return insert_record("forum_subscriptions", $sub);
@ -1347,7 +1347,7 @@ function forum_subscribe($userid, $forumid) {
function forum_unsubscribe($userid, $forumid) {
/// Removes user from the subscriber list
return delete_records("forum_subscriptions", "user", $userid, "forum", $forumid);
return delete_records("forum_subscriptions", "userid", $userid, "forum", $forumid);
}
@ -1482,7 +1482,7 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode) {
global $USER;
$ownpost = ($USER->id == $post->user);
$ownpost = ($USER->id == $post->userid);
$reply = forum_user_can_post($forum);
forum_print_post($post, $course->id, $ownpost, $reply, $link=false, $rate=false);
@ -1541,7 +1541,7 @@ function forum_print_posts_flat($discussion, $course, $direction, $assessed, $re
if ($posts = forum_get_discussion_posts($discussion, $sort)) {
foreach ($posts as $post) {
$ownpost = ($USER->id == $post->user);
$ownpost = ($USER->id == $post->userid);
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);
}
} else {
@ -1559,7 +1559,7 @@ function forum_print_posts_threaded($parent, $course, $depth, $assessed, $reply)
echo "<UL>";
if ($depth > 0) {
$ownpost = ($USER->id == $post->user);
$ownpost = ($USER->id == $post->userid);
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed); // link=true?
echo "<BR>";
} else {
@ -1586,7 +1586,7 @@ function forum_print_posts_nested($parent, $course, $assessed, $reply) {
if ($posts = forum_get_child_posts($parent)) {
foreach ($posts as $post) {
$ownpost = ($USER->id == $post->user);
$ownpost = ($USER->id == $post->userid);
echo "<UL>";
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);

View file

@ -55,7 +55,7 @@
<input type="hidden" name=forum value="<? p($post->forum) ?>">
<input type="hidden" name=discussion value="<? p($post->discussion) ?>">
<input type="hidden" name=parent value="<? p($post->parent) ?>">
<input type="hidden" name=user value="<? p($post->user) ?>">
<input type="hidden" name=user value="<? p($post->userid) ?>">
<input type="hidden" name=edit value="<? p($post->edit) ?>">
<input type="submit" value="<? print_string("savechanges"); ?>">
</td>

View file

@ -94,7 +94,7 @@
$post->discussion = 0; // ie discussion # not defined yet
$post->parent = 0;
$post->subject = "";
$post->user = $USER->id;
$post->userid = $USER->id;
$post->message = "";
$post->format = $defaultformat;
@ -125,7 +125,7 @@
$post->discussion = $parent->discussion;
$post->parent = $parent->id;
$post->subject = $parent->subject;
$post->user = $USER->id;
$post->userid = $USER->id;
$post->message = "";
$post->format = $defaultformat;
@ -141,7 +141,7 @@
if (! $post = forum_get_post_full($edit)) {
error("Post ID was incorrect");
}
if ($post->user <> $USER->id) {
if ($post->userid <> $USER->id) {
error("You can't edit other people's posts!");
}
if ((time() - $post->created) > $CFG->maxeditingtime) {
@ -183,7 +183,7 @@
if (! $forum = get_record("forum", "id", $discussion->forum)) {
error("The forum number was incorrect ($discussion->forum)");
}
if (($post->user <> $USER->id) and !isteacher($forum->course)) {
if (($post->userid <> $USER->id) and !isteacher($forum->course)) {
error("You can't delete other people's posts!");
}

View file

@ -25,11 +25,11 @@
continue;
}
if ($rating) {
if (record_exists("forum_ratings", "user", $USER->id, "post", $post)) {
if (record_exists("forum_ratings", "userid", $USER->id, "post", $post)) {
error("You've rated this question before ($post)");
} else {
unset($newrating);
$newrating->user = $USER->id;
$newrating->userid = $USER->id;
$newrating->time = time();
$newrating->post = $post;
$newrating->rating = $rating;

View file

@ -23,7 +23,7 @@
error("Course ID was incorrect");
}
if (!isteacher($course->id) and $USER->id != $post->user) {
if (!isteacher($course->id) and $USER->id != $post->userid) {
error("You can only look at results for posts you own");
}

View file

@ -3,8 +3,8 @@
require("../../config.php");
require("lib.php");
require_variable($id); // course id
optional_variable($search, ""); // user id
require_variable($id); // course id
optional_variable($search, ""); // search string
$search = strip_tags($search);

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002101001;
$module->version = 2002122300;
$module->cron = 60;
?>

View file

@ -14,6 +14,10 @@ function journal_upgrade($oldversion) {
if ($oldversion < 2002101200) {
execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `journal_entries` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return $result;
}

View file

@ -33,7 +33,7 @@ CREATE TABLE prefix_journal (
CREATE TABLE prefix_journal_entries (
id int(10) unsigned NOT NULL auto_increment,
journal int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
modified int(10) unsigned NOT NULL default '0',
text text NOT NULL,
format tinyint(2) NOT NULL default '0',

View file

@ -6,14 +6,5 @@ function journal_upgrade($oldversion) {
$result = true;
if ($oldversion < 20020810) {
if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` INTEGER DEFAULT '0' NOT NULL")) {
$result = false;
}
}
if ($oldversion < 2002101200) {
execute_sql(" ALTER TABLE `journal_entries` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `text` ");
}
return $result;
}

View file

@ -32,7 +32,7 @@ CREATE TABLE journal (
CREATE TABLE journal_entries (
id SERIAL PRIMARY KEY,
journal integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
modified integer NOT NULL default '0',
text text NOT NULL default '',
format integer NOT NULL default '0',

View file

@ -22,7 +22,7 @@
error("Course module is incorrect");
}
$entry = get_record("journal_entries", "user", $USER->id, "journal", $journal->id);
$entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id);
/// If data submitted, then process and store.
@ -43,7 +43,7 @@
}
add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id");
} else {
$newentry->user = $USER->id;
$newentry->userid = $USER->id;
$newentry->journal = $journal->id;
$newentry->modified = $timenow;
$newentry->text = $text;

View file

@ -49,7 +49,7 @@
foreach ($journals as $journal) {
$entrytext = get_field("journal_entries", "text", "user", $USER->id, "journal", $journal->id");
$entrytext = get_field("journal_entries", "text", "userid", $USER->id, "journal", $journal->id");
$journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
if ($journal->daysopen) {

View file

@ -9,7 +9,7 @@ $JOURNAL_RATING = array ("3" => get_string("journalrating3", "journal"),
// STANDARD MODULE FUNCTIONS /////////////////////////////////////////////////////////
function journal_user_outline($course, $user, $mod, $journal) {
if ($entry = get_record("journal_entries", "user", $user->id, "journal", $journal->id)) {
if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
$numwords = count(preg_split("/\w\b/", $entry->text)) - 1;
@ -23,7 +23,7 @@ function journal_user_outline($course, $user, $mod, $journal) {
function journal_user_complete($course, $user, $mod, $journal) {
if ($entry = get_record("journal_entries", "user", $user->id, "journal", $journal->id)) {
if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
print_simple_box_start();
if ($entry->modified) {
@ -58,8 +58,8 @@ function journal_cron () {
echo "Processing journal entry $entry->id\n";
if (! $user = get_record("user", "id", "$entry->user")) {
echo "Could not find user $post->user\n";
if (! $user = get_record("user", "id", "$entry->userid")) {
echo "Could not find user $entry->userid\n";
continue;
}
@ -156,7 +156,7 @@ function journal_grades($journalid) {
/// Must return an array of grades, indexed by user, and a max grade.
global $JOURNAL_RATING;
if ($return->grades = get_records_menu("journal_entries", "journal", $journalid, "", "user,rating")) {
if ($return->grades = get_records_menu("journal_entries", "journal", $journalid, "", "userid,rating")) {
foreach ($return->grades as $key => $value) {
if ($value) {
$return->grades[$key] = $JOURNAL_RATING[$value];
@ -179,9 +179,9 @@ function journal_get_users_done($journal) {
{$CFG->prefix}user_students s,
{$CFG->prefix}user_teachers t,
{$CFG->prefix}journal_entries j
WHERE ((s.course = '$journal->course' AND s.user = u.id)
OR (t.course = '$journal->course' AND t.user = u.id))
AND u.id = j.user
WHERE ((s.course = '$journal->course' AND s.userid = u.id)
OR (t.course = '$journal->course' AND t.userid = u.id))
AND u.id = j.userid
AND j.journal = '$journal->id'
ORDER BY j.modified DESC");
}
@ -205,7 +205,7 @@ function journal_log_info($log) {
{$CFG->prefix}user u
WHERE e.id = '$log->info'
AND e.journal = j.id
AND e.user = u.id");
AND e.userid = u.id");
}
// OTHER JOURNAL FUNCTIONS ///////////////////////////////////////////////////////////////////

View file

@ -26,7 +26,7 @@
// make some easy ways to access the entries.
if ( $eee = get_records("journal_entries", "journal", $journal->id)) {
foreach ($eee as $ee) {
$entrybyuser[$ee->user] = $ee;
$entrybyuser[$ee->userid] = $ee;
$entrybyentry[$ee->id] = $ee;
}
@ -67,14 +67,14 @@
$newentry->mailed = 0; // Make sure mail goes out (again, even)
$newentry->id = $num;
if (! update_record("journal_entries", $newentry)) {
notify("Failed to update the journal feedback for user $entry->user");
notify("Failed to update the journal feedback for user $entry->userid");
} else {
$count++;
}
$entrybyuser[$entry->user]->rating = $vals[r];
$entrybyuser[$entry->user]->comment = $vals[c];
$entrybyuser[$entry->user]->teacher = $USER->id;
$entrybyuser[$entry->user]->timemarked = $timenow;
$entrybyuser[$entry->userid]->rating = $vals[r];
$entrybyuser[$entry->userid]->comment = $vals[c];
$entrybyuser[$entry->userid]->teacher = $USER->id;
$entrybyuser[$entry->userid]->timemarked = $timenow;
}
}
add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users");

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002101200;
$module->version = 2002122300;
$module->cron = 60;
?>

View file

@ -81,7 +81,7 @@
}
if ($entry = get_record("journal_entries", "user", $USER->id, "journal", $journal->id)) {
if ($entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id)) {
if (empty($entry->text)) {
echo "<P ALIGN=center><B>".get_string("blankentry","journal")."</B></P>";

View file

@ -24,6 +24,11 @@ function quiz_upgrade($oldversion) {
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `quiz_grades` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `quiz_attempts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -55,7 +55,7 @@ CREATE TABLE `prefix_quiz_answers` (
CREATE TABLE `prefix_quiz_attempts` (
`id` int(10) unsigned NOT NULL auto_increment,
`quiz` int(10) unsigned NOT NULL default '0',
`user` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`attempt` smallint(6) NOT NULL default '0',
`sumgrades` varchar(10) NOT NULL default '0.0',
`timestart` int(10) unsigned NOT NULL default '0',
@ -86,7 +86,7 @@ CREATE TABLE `prefix_quiz_categories` (
CREATE TABLE `prefix_quiz_grades` (
`id` int(10) unsigned NOT NULL auto_increment,
`quiz` int(10) unsigned NOT NULL default '0',
`user` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`grade` varchar(10) NOT NULL default '0.0',
`timemodified` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)

View file

@ -6,24 +6,6 @@ function quiz_upgrade($oldversion) {
global $CFG;
if ($oldversion < 2002101800) {
execute_sql(" ALTER TABLE `quiz_attempts` ".
" ADD `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `sumgrades` , ".
" ADD `timefinish` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timestart` ");
execute_sql(" UPDATE `quiz_attempts` SET timestart = timemodified ");
execute_sql(" UPDATE `quiz_attempts` SET timefinish = timemodified ");
}
if ($oldversion < 2002102101) {
execute_sql(" DELETE FROM log_display WHERE module = 'quiz' ");
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'view', 'quiz', 'name') ");
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'report', 'quiz', 'name') ");
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'attempt', 'quiz', 'name') ");
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'submit', 'quiz', 'name') ");
}
if ($oldversion < 2002102600) {
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
}
return true;
}

View file

@ -52,7 +52,7 @@ CREATE TABLE quiz_answers (
CREATE TABLE quiz_attempts (
id SERIAL PRIMARY KEY,
quiz integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
attempt integer NOT NULL default '0',
sumgrades varchar(10) NOT NULL default '0.0',
timestart integer NOT NULL default '0',
@ -81,7 +81,7 @@ CREATE TABLE quiz_categories (
CREATE TABLE quiz_grades (
id SERIAL PRIMARY KEY,
quiz integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
grade varchar(10) NOT NULL default '0.0',
timemodified integer NOT NULL default '0'
);

View file

@ -154,7 +154,7 @@ function quiz_user_outline($course, $user, $mod, $quiz) {
/// Used for user activity reports.
/// $return->time = the time they did it
/// $return->info = a short text description
if ($grade = get_record("quiz_grades", "user", $user->id, "quiz", $quiz->id)) {
if ($grade = get_record("quiz_grades", "userid", $user->id, "quiz", $quiz->id)) {
if ($grade->grade) {
$result->info = get_string("grade").": $grade->grade";
@ -198,7 +198,7 @@ function quiz_cron () {
function quiz_grades($quizid) {
/// Must return an array of grades, indexed by user, and a max grade.
$return->grades = get_records_menu("quiz_grades", "quiz", $quizid, "", "user,grade");
$return->grades = get_records_menu("quiz_grades", "quiz", $quizid, "", "userid,grade");
$return->maxgrade = get_field("quiz", "grade", "id", "$quizid");
return $return;
}
@ -232,7 +232,7 @@ function quiz_get_grade_records($quiz) {
FROM {$CFG->prefix}quiz_grades qg,
{$CFG->prefix}user u
WHERE qg.quiz = '$quiz->id'
AND qg.user = u.id");
AND qg.userid = u.id");
}
function quiz_get_answers($question) {
@ -794,7 +794,7 @@ function quiz_print_cat_question_list($categoryid) {
function quiz_start_attempt($quizid, $userid, $numattempt) {
$attempt->quiz = $quizid;
$attempt->user = $userid;
$attempt->userid = $userid;
$attempt->attempt = $numattempt;
$attempt->timestart = time();
$attempt->timefinish = 0;
@ -805,12 +805,12 @@ function quiz_start_attempt($quizid, $userid, $numattempt) {
function quiz_get_user_attempt_unfinished($quizid, $userid) {
// Returns an object containing an unfinished attempt (if there is one)
return get_record("quiz_attempts", "quiz", $quizid, "user", $userid, "timefinish", 0);
return get_record("quiz_attempts", "quiz", $quizid, "userid", $userid, "timefinish", 0);
}
function quiz_get_user_attempts($quizid, $userid) {
// Returns a list of all attempts by a user
return get_records_select("quiz_attempts", "quiz = '$quizid' AND user = '$userid' AND timefinish > 0",
return get_records_select("quiz_attempts", "quiz = '$quizid' AND userid = '$userid' AND timefinish > 0",
"attempt ASC");
}
@ -833,7 +833,7 @@ function quiz_get_user_attempts_string($quiz, $attempts, $bestgrade) {
function quiz_get_best_grade($quizid, $userid) {
/// Get the best current grade for a particular user in a quiz
if (!$grade = get_record("quiz_grades", "quiz", $quizid, "user", $userid)) {
if (!$grade = get_record("quiz_grades", "quiz", $quizid, "userid", $userid)) {
return 0;
}
@ -852,7 +852,7 @@ function quiz_save_best_grade($quiz, $userid) {
$bestgrade = quiz_calculate_best_grade($quiz, $attempts);
$bestgrade = (($bestgrade / $quiz->sumgrades) * $quiz->grade);
if ($grade = get_record("quiz_grades", "quiz", $quiz->id, "user", $userid)) {
if ($grade = get_record("quiz_grades", "quiz", $quiz->id, "userid", $userid)) {
$grade->grade = $bestgrade;
$grade->timemodified = time();
if (!update_record("quiz_grades", $grade)) {
@ -861,7 +861,7 @@ function quiz_save_best_grade($quiz, $userid) {
}
} else {
$grade->quiz = $quiz->id;
$grade->user = $userid;
$grade->userid = $userid;
$grade->grade = round($bestgrade, 2);
$grade->timemodified = time();
if (!insert_record("quiz_grades", $grade)) {

View file

@ -142,7 +142,7 @@
}
}
$users[$attempt->user] = $attempt->user;
$users[$attempt->userid] = $attempt->userid;
}
if ($users) {
@ -169,14 +169,14 @@
$table->width = array(10, "*", "*", 20);
foreach ($grades as $grade) {
$picture = print_user_picture($grade->user, $course->id, $grade->picture, false, true);
$picture = print_user_picture($grade->userid, $course->id, $grade->picture, false, true);
if ($attempts = quiz_get_user_attempts($quiz->id, $grade->user)) {
if ($attempts = quiz_get_user_attempts($quiz->id, $grade->userid)) {
$userattempts = quiz_get_user_attempts_string($quiz, $attempts, $grade->grade);
}
$table->data[] = array ($picture,
"<A HREF=\"$CFG->wwwroot/user/view.php?id=$grade->user&course=$course->id\">$grade->firstname $grade->lastname</A>",
"<A HREF=\"$CFG->wwwroot/user/view.php?id=$grade->userid&course=$course->id\">$grade->firstname $grade->lastname</A>",
"$userattempts", round($grade->grade,0));
}

View file

@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002102600; // The (date) version of this module
$module->version = 2002122300; // The (date) version of this module
$module->cron = 0; // How often should cron check this module (seconds)?
?>

View file

@ -51,10 +51,8 @@ function resource_list_all_resources($courseid=0, $sort="name ASC", $recent=0) {
function resource_user_outline($course, $user, $mod, $resource) {
if ($logs = get_records_sql("SELECT * FROM log
WHERE user='$user->id' AND module='resource'
AND action='view' AND info='$resource->id'
ORDER BY time ASC")) {
if ($logs = get_records_select("log", "userid='$user->id' AND module='resource'
AND action='view' AND info='$resource->id'", "time ASC")) {
$numviews = count($logs);
$lastlog = array_pop($logs);
@ -71,11 +69,8 @@ function resource_user_outline($course, $user, $mod, $resource) {
function resource_user_complete($course, $user, $mod, $resource) {
global $CFG, $THEME;
if ($logs = get_records_sql("SELECT * FROM log
WHERE user='$user->id' AND module='resource'
AND action='view' AND info='$resource->id'
ORDER BY time ASC")) {
if ($logs = get_records_select("log", "userid='$user->id' AND module='resource'
AND action='view' AND info='$resource->id'", "time ASC")) {
$numviews = count($logs);
$lastlog = array_pop($logs);

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002101700;
$module->version = 2002122300;
$module->cron = 0;
?>

View file

@ -151,6 +151,10 @@ function survey_upgrade($oldversion) {
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm2', `shorttext` = 'attlsm2', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Connected Learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm3', `shorttext` = 'attlsm3', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Separate Learning'");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `survey_analysis` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `survey_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -45,7 +45,7 @@ INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`,
CREATE TABLE prefix_survey_analysis (
id int(10) unsigned NOT NULL auto_increment,
survey int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
notes text NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id)
@ -63,7 +63,7 @@ CREATE TABLE prefix_survey_analysis (
CREATE TABLE prefix_survey_answers (
id int(10) unsigned NOT NULL auto_increment,
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
survey int(10) unsigned NOT NULL default '0',
question int(10) unsigned NOT NULL default '0',
time int(10) unsigned default NULL,

View file

@ -4,153 +4,7 @@ function survey_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
if ($oldversion < 2002081400) {
execute_sql(" ALTER TABLE `survey_questions` DROP `owner` ");
execute_sql(" ALTER TABLE `survey_questions` ADD `shorttext` VARCHAR(30) NOT NULL AFTER `text` ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'focus on interesting issues' WHERE id = 1 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'important to my practice' WHERE id = 2 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'improve my practice' WHERE id = 3 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'connects with my practice' WHERE id = 4 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of my learning' WHERE id = 5 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of my own ideas' WHERE id = 6 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of other students' WHERE id = 7 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of readings' WHERE id = 8 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I explain my ideas' WHERE id = 9 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I ask for explanations' WHERE id =10 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m asked to explain' WHERE id =11 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students respond to me' WHERE id =12 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor stimulates thinking' WHERE id =13 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor encourages me' WHERE id =14 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor models discourse' WHERE id =15 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor models self-reflection' WHERE id =16 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students encourage me' WHERE id =17 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students praise me' WHERE id =18 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students value me' WHERE id =19 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'student empathise' WHERE id =20 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I understand other students' WHERE id =21 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students understand me' WHERE id =22 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I understand the tutor' WHERE id =23 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor understands me' WHERE id =24 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Relevance' WHERE id =25 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Reflective Thinking' WHERE id =26 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Interactivity' WHERE id =27 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Tutor Support' WHERE id =28 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Peer Support' WHERE id =29 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Interpretation' WHERE id =30 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Relevance' WHERE id =31 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Reflective Thinking' WHERE id =32 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Interactivity' WHERE id =33 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Tutor Support' WHERE id =34 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =35 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =36 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =37 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =38 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =39 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =40 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =41 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =42 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =43 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =44 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'focus quality of argument' WHERE id =45 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'play devil\'s advocate' WHERE id =46 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'where people come from' WHERE id =47 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'understand different people' WHERE id =48 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'interact with variety' WHERE id =49 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'enjoy hearing opinions' WHERE id =50 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'strengthen by argue' WHERE id =51 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'know why people do' WHERE id =52 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'argue with authors' WHERE id =53 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'remain objective' WHERE id =54 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'think WITH people' WHERE id =55 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'use criteria to evaluate' WHERE id =56 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'try to understand' WHERE id =57 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'point out weaknesses' WHERE id =58 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'put myself in their shoes' WHERE id =59 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'putting on trial' WHERE id =60 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'i value logic most' WHERE id =61 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'insight from empathy' WHERE id =62 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'make effort to extend' WHERE id =63 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'what\'s wrong\?' WHERE id =64 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =65 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =66 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =67 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =68 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =69 ");
}
if ($oldversion < 2002110903) {
if (! execute_sql("ALTER TABLE `survey_questions` ADD `shorttext` VARCHAR(30) NOT NULL AFTER `text` ")) {
notify("If you get an error above, don't worry, just ignore it. Everything is OK.");
}
execute_sql("UPDATE `survey` SET `name` = 'collesaname', `intro` = 'collesaintro' WHERE name = 'COLLES (Actual)' AND template = 0 ");
execute_sql("UPDATE `survey` SET `name` = 'collespname', `intro` = 'collespintro' WHERE name = 'COLLES (Preferred)' AND template = 0");
execute_sql("UPDATE `survey` SET `name` = 'collesapname', `intro` = 'collesapintro' WHERE name = 'COLLES (Preferred and Actual)' AND template = 0");
execute_sql("UPDATE `survey` SET `name` = 'attlsname', `intro` = 'attlsintro' WHERE name = 'ATTLS (20 item version)' AND template = 0");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles1', `shorttext` = 'colles1short', `options` = 'scaletimes5' WHERE `shorttext` = 'focus on interesting issues'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles2', `shorttext` = 'colles2short', `options` = 'scaletimes5' WHERE `shorttext` = 'important to my practice'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles3', `shorttext` = 'colles3short', `options` = 'scaletimes5' WHERE `shorttext` = 'improve my practice'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles4', `shorttext` = 'colles4short', `options` = 'scaletimes5' WHERE `shorttext` = 'connects with my practice'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles5', `shorttext` = 'colles5short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of my learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles6', `shorttext` = 'colles6short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of my own ideas'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles7', `shorttext` = 'colles7short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of other students'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles8', `shorttext` = 'colles8short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of readings'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles9', `shorttext` = 'colles9short', `options` = 'scaletimes5' WHERE `shorttext` = 'I explain my ideas'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles10', `shorttext` = 'colles10short', `options` = 'scaletimes5' WHERE `shorttext` = 'I ask for explanations'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles11', `shorttext` = 'colles11short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m asked to explain'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles12', `shorttext` = 'colles12short', `options` = 'scaletimes5' WHERE `shorttext` = 'students respond to me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles13', `shorttext` = 'colles13short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor stimulates thinking'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles14', `shorttext` = 'colles14short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor encourages me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles15', `shorttext` = 'colles15short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor models discourse'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles16', `shorttext` = 'colles16short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor models self-reflection'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles17', `shorttext` = 'colles17short', `options` = 'scaletimes5' WHERE `shorttext` = 'students encourage me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles18', `shorttext` = 'colles18short', `options` = 'scaletimes5' WHERE `shorttext` = 'students praise me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles19', `shorttext` = 'colles19short', `options` = 'scaletimes5' WHERE `shorttext` = 'students value me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles20', `shorttext` = 'colles20short', `options` = 'scaletimes5' WHERE `shorttext` = 'student empathise'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles21', `shorttext` = 'colles21short', `options` = 'scaletimes5' WHERE `shorttext` = 'I understand other students'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles22', `shorttext` = 'colles22short', `options` = 'scaletimes5' WHERE `shorttext` = 'students understand me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles23', `shorttext` = 'colles23short', `options` = 'scaletimes5' WHERE `shorttext` = 'I understand the tutor'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles24', `shorttext` = 'colles24short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor understands me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm1', `shorttext` = 'collesm1short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Relevance'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm2', `shorttext` = 'collesm2short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Reflective Thinking'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm3', `shorttext` = 'collesm3short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Interactivity'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm4', `shorttext` = 'collesm4short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Tutor Support'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm5', `shorttext` = 'collesm5short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Peer Support'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm6', `shorttext` = 'collesm6short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Interpretation'");
execute_sql("UPDATE `survey_questions` SET `text` = 'howlong', `options` = 'howlongoptions' WHERE `text` = 'How long did this survey take you to complete\?'");
execute_sql("UPDATE `survey_questions` SET `text` = 'othercomments' WHERE `text` = 'Do you have any other comments\?'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls1', `shorttext` = 'attls1short', `options` = 'scaleagree5' WHERE `shorttext` = 'focus quality of argument'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls2', `shorttext` = 'attls2short', `options` = 'scaleagree5' WHERE `shorttext` = 'play devil\'s advocate'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls3', `shorttext` = 'attls3short', `options` = 'scaleagree5' WHERE `shorttext` = 'where people come from'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls4', `shorttext` = 'attls4short', `options` = 'scaleagree5' WHERE `shorttext` = 'understand different people'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls5', `shorttext` = 'attls5short', `options` = 'scaleagree5' WHERE `shorttext` = 'interact with variety'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls6', `shorttext` = 'attls6short', `options` = 'scaleagree5' WHERE `shorttext` = 'enjoy hearing opinions'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls7', `shorttext` = 'attls7short', `options` = 'scaleagree5' WHERE `shorttext` = 'strengthen by argue'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls8', `shorttext` = 'attls8short', `options` = 'scaleagree5' WHERE `shorttext` = 'know why people do'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls9', `shorttext` = 'attls9short', `options` = 'scaleagree5' WHERE `shorttext` = 'argue with authors'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls10', `shorttext` = 'attls10short', `options` = 'scaleagree5' WHERE `shorttext` = 'remain objective'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls11', `shorttext` = 'attls11short', `options` = 'scaleagree5' WHERE `shorttext` = 'think WITH people'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls12', `shorttext` = 'attls12short', `options` = 'scaleagree5' WHERE `shorttext` = 'use criteria to evaluate'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls13', `shorttext` = 'attls13short', `options` = 'scaleagree5' WHERE `shorttext` = 'try to understand'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls14', `shorttext` = 'attls14short', `options` = 'scaleagree5' WHERE `shorttext` = 'point out weaknesses'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls15', `shorttext` = 'attls15short', `options` = 'scaleagree5' WHERE `shorttext` = 'put myself in their shoes'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls16', `shorttext` = 'attls16short', `options` = 'scaleagree5' WHERE `shorttext` = 'putting on trial'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls17', `shorttext` = 'attls17short', `options` = 'scaleagree5' WHERE `shorttext` = 'i value logic most'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls18', `shorttext` = 'attls18short', `options` = 'scaleagree5' WHERE `shorttext` = 'insight from empathy'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls19', `shorttext` = 'attls19short', `options` = 'scaleagree5' WHERE `shorttext` = 'make effort to extend'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls20', `shorttext` = 'attls20short', `options` = 'scaleagree5' WHERE `shorttext` = 'what\'s wrong\?'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm1', `shorttext` = 'attlsm1', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Attitudes Towards Thinking and Learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm2', `shorttext` = 'attlsm2', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Connected Learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm3', `shorttext` = 'attlsm3', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Separate Learning'");
}
global $CFG;
return true;
}

View file

@ -44,7 +44,7 @@ INSERT INTO survey (id, course, template, days, timecreated, timemodified, name,
CREATE TABLE survey_analysis (
id SERIAL PRIMARY KEY,
survey integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
notes text NOT NULL default ''
);
@ -60,7 +60,7 @@ CREATE TABLE survey_analysis (
CREATE TABLE survey_answers (
id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
survey integer NOT NULL default '0',
question integer NOT NULL default '0',
time integer default NULL,

View file

@ -94,15 +94,15 @@
}
foreach ($aaa as $a) {
if (!$results["$a->user"]) { // init new array
$results["$a->user"]["time"] = $a->time;
if (!$results["$a->userid"]) { // init new array
$results["$a->userid"]["time"] = $a->time;
foreach ($order as $key => $qid) {
$results["$a->user"]["$qid"]["answer1"] = "";
$results["$a->user"]["$qid"]["answer2"] = "";
$results["$a->userid"]["$qid"]["answer1"] = "";
$results["$a->userid"]["$qid"]["answer2"] = "";
}
}
$results["$a->user"]["$a->question"]["answer1"] = $a->answer1;
$results["$a->user"]["$a->question"]["answer2"] = $a->answer2;
$results["$a->userid"]["$a->question"]["answer1"] = $a->answer1;
$results["$a->userid"]["$a->question"]["answer2"] = $a->answer2;
}
@ -136,7 +136,7 @@
if (! $u = get_record("user", "id", $user)) {
error("Error finding student # $user");
}
if ($n = get_record("survey_analysis", "survey", $survey->id, "user", $user)) {
if ($n = get_record("survey_analysis", "survey", $survey->id, "userid", $user)) {
$notes = $n->notes;
} else {
$notes = "No notes made";

View file

@ -402,7 +402,7 @@
if ($aaa) {
foreach ($aaa as $a) {
if ($a->user == $sid) {
if ($a->userid == $sid) {
if ($a->answer1) {
$studbuckets1[$i] += $a->answer1;
$studcount1[$i]++;
@ -548,7 +548,7 @@
if ($aaa) {
foreach ($aaa as $a) {
$index = $indexof[$a->question];
if ($a->user == $sid) {
if ($a->userid == $sid) {
if ($a->answer1) {
$studbuckets1[$index] += $a->answer1;
$studcount1[$index]++;

View file

@ -78,7 +78,7 @@ function survey_delete_instance($id) {
}
function survey_user_outline($course, $user, $mod, $survey) {
if ($answers = get_records_select("survey_answers", "survey='$survey->id' AND user='$user->id'")) {
if ($answers = get_records_select("survey_answers", "survey='$survey->id' AND userid='$user->id'")) {
$lastanswer = array_pop($answers);
@ -139,7 +139,7 @@ function survey_log_info($log) {
FROM {$CFG->prefix}survey s,
{$CFG->prefix}user u
WHERE s.id = '$log->info'
AND u.id = '$log->user'");
AND u.id = '$log->userid'");
}
function survey_get_responses($survey) {
@ -149,55 +149,56 @@ function survey_get_responses($survey) {
{$CFG->prefix}user AS u
WHERE a.answer1 <> '0' AND a.answer2 <> '0'
AND a.survey = $survey
AND a.user = u.id
GROUP BY a.user
AND a.userid = u.id
GROUP BY a.userid
ORDER BY a.time ASC");
}
function survey_get_analysis($survey, $user) {
global $db, $CFG;
global $CFG;
return get_record_sql("SELECT notes
FROM {$CFG->prefix}survey_analysis
WHERE survey='$survey'
AND user='$user'");
AND userid='$user'");
}
function survey_update_analysis($survey, $user, $notes) {
global $db, $CFG;
global $CFG;
return $db->Execute("UPDATE {$CFG->prefix}survey_analysis
return execute_sql("UPDATE {$CFG->prefix}survey_analysis
SET notes='$notes'
WHERE survey='$survey'
AND user='$user'");
AND userid='$user'");
}
function survey_add_analysis($survey, $user, $notes) {
global $db, $CFG;
return $db->Execute("INSERT INTO {$CFG->prefix}survey_analysis
SET notes='$notes',
survey='$survey',
user='$user'");
}
function survey_get_user_answers($surveyid, $questionid) {
global $CFG;
return get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
FROM survey_answers sa,
user u
FROM {$CFG->prefix}survey_answers sa,
{$CFG->prefix}user u
WHERE sa.survey = '$surveyid'
AND sa.question = $questionid
AND u.id = sa.user
AND u.id = sa.userid
ORDER BY sa.answer1,sa.answer2 ASC");
}
// MODULE FUNCTIONS ////////////////////////////////////////////////////////
function survey_add_analysis($survey, $user, $notes) {
global $CFG;
$record->survey = $survey;
$record->userid = $user;
$record->notes = $notes;
return insert_record("survey_analysis", $record, false);
}
function survey_already_done($survey, $user) {
return record_exists("survey_answers", "survey", $survey, "user", $user);
return record_exists("survey_answers", "survey", $survey, "userid", $user);
}
function survey_count_responses($survey) {

View file

@ -217,9 +217,9 @@
foreach ($aaa as $a) {
echo "<TR>";
echo "<TD WIDTH=35>";
print_user_picture($a->user, $course->id, $a->picture, false);
print_user_picture($a->userid, $course->id, $a->picture, false);
echo "</TD>";
echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->user\">$a->firstname $a->lastname</A></TD>";
echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->userid\">$a->firstname $a->lastname</A></TD>";
echo "<TD><P>".userdate($a->time, "%d %B %Y, %I:%M %p")."</TD>";
echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
if ($a->answer1) {
@ -261,7 +261,7 @@
error("Student doesn't exist");
}
print_header("$survey->name: $$user->firstname $user->lastname",
print_header("$survey->name: $user->firstname $user->lastname",
get_string("analysisof", "survey", "$user->firstname $user->lastname"));
if (isset($notes)) {

View file

@ -65,7 +65,7 @@
foreach ($answers as $key => $val) {
$newdata->time = $timenow;
$newdata->user = $USER->id;
$newdata->userid = $USER->id;
$newdata->survey = $survey->id;
$newdata->question = $key;
$newdata->answer1 = $val[0];

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002110903;
$module->version = 2002122300;
$module->cron = 0;
?>