]> git.mjollnir.org Git - moodle.git/commitdiff
Changes throughout Moodle to remove any reserved words from the
authormoodler <moodler>
Mon, 23 Dec 2002 09:39:26 +0000 (09:39 +0000)
committermoodler <moodler>
Mon, 23 Dec 2002 09:39:26 +0000 (09:39 +0000)
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

68 files changed:
admin/admin.php
admin/user.php
course/lib.php
course/teacher.php
course/teachers.php
lib/datalib.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.sql
lib/moodlelib.php
mod/assignment/db/mysql.php
mod/assignment/db/mysql.sql
mod/assignment/db/postgres7.sql
mod/assignment/lib.php
mod/assignment/submissions.php
mod/assignment/upload.php
mod/assignment/version.php
mod/choice/db/mysql.php
mod/choice/db/mysql.sql
mod/choice/db/postgres7.php
mod/choice/db/postgres7.sql
mod/choice/index.php
mod/choice/lib.php
mod/choice/report.php
mod/choice/version.php
mod/choice/view.php
mod/forum/db/mysql.php
mod/forum/db/mysql.sql
mod/forum/db/postgres7.php
mod/forum/db/postgres7.sql
mod/forum/lib.php
mod/forum/post.html
mod/forum/post.php
mod/forum/rate.php
mod/forum/report.php
mod/forum/search.php
mod/forum/version.php
mod/journal/db/mysql.php
mod/journal/db/mysql.sql
mod/journal/db/postgres7.php
mod/journal/db/postgres7.sql
mod/journal/edit.php
mod/journal/index.php
mod/journal/lib.php
mod/journal/report.php
mod/journal/version.php
mod/journal/view.php
mod/quiz/db/mysql.php
mod/quiz/db/mysql.sql
mod/quiz/db/postgres7.php
mod/quiz/db/postgres7.sql
mod/quiz/lib.php
mod/quiz/report.php
mod/quiz/version.php
mod/resource/lib.php
mod/resource/version.php
mod/survey/db/mysql.php
mod/survey/db/mysql.sql
mod/survey/db/postgres7.php
mod/survey/db/postgres7.sql
mod/survey/download.php
mod/survey/graph.php
mod/survey/lib.php
mod/survey/report.php
mod/survey/save.php
mod/survey/version.php
user/view.php
version.php

index 84c2c5aab5d9b2c3bfd955cef8359808c2ce8a72..106ff89f9ff26cf9365fa81fc9cff389af8cd0d5 100644 (file)
@@ -67,7 +67,7 @@
             }
         }
 
-        $admin->user = $user->id;
+        $admin->userid = $user->id;
         $admin->id = insert_record("user_admins", $admin);
         $admins[] = $user;
     }
index e8f1fbe384f041378073cfc5ea9266f91275af27..4749cd64f59bf5b728327043d039c6e43ad5b481 100644 (file)
@@ -28,7 +28,7 @@
             error("SERIOUS ERROR: Could not create admin user record !!!");
         }
 
-        $admin->user = $user->id;
+        $admin->userid = $user->id;
 
         if (! insert_record("user_admins", $admin)) {
             error("Could not make user $user->id an admin !!!");
@@ -42,7 +42,7 @@
             error("Could not find site-level course");
         }
 
-        $teacher->user = $user->id;
+        $teacher->userid = $user->id;
         $teacher->course = $site->id;
         $teacher->authority = 1;
         if (! insert_record("user_teachers", $teacher)) {
index 6611986f5966554b9c10246a262b4af2a05d36b2..c6c1035661071d9e3334dba26bc66ac71fbef275 100644 (file)
@@ -106,10 +106,10 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
 // and so the next 86400 seconds worth of logs are printed.
 
     if ($course->category) {
-        $selector = "WHERE l.course='$course->id' AND l.user = u.id";
+        $selector = "WHERE l.course='$course->id' AND l.userid = u.id";
 
     } else {
-        $selector = "WHERE l.user = u.id";  // Show all courses
+        $selector = "WHERE l.userid = u.id";  // Show all courses
         if ($ccc = get_courses(-1)) {
             foreach ($ccc as $cc) {
                 $courses[$cc->id] = "$cc->shortname";
@@ -118,7 +118,7 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
     }
 
     if ($user) {
-        $selector .= " AND l.user = '$user'";
+        $selector .= " AND l.userid = '$user'";
     }
 
     if ($date) {
@@ -152,9 +152,9 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
         echo "<TD NOWRAP ALIGN=right><FONT SIZE=2>".userdate($log->time, "%A")."</TD>";
         echo "<TD NOWRAP><FONT SIZE=2>".userdate($log->time, "%d %B %Y, %I:%M %p")."</TD>";
         echo "<TD NOWRAP><FONT SIZE=2>";
-        link_to_popup_window("$CFG->wwwroot/lib/ipatlas/plot.php?address=$log->ip&user=$log->user", "ipatlas","$log->ip", 400, 700);
+        link_to_popup_window("$CFG->wwwroot/lib/ipatlas/plot.php?address=$log->ip&user=$log->userid", "ipatlas","$log->ip", 400, 700);
         echo "</TD>";
-        echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"../user/view.php?id=$log->user&course=$log->course\"><B>$log->firstname $log->lastname</B></TD>";
+        echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"../user/view.php?id=$log->userid&course=$log->course\"><B>$log->firstname $log->lastname</B></TD>";
         echo "<TD NOWRAP><FONT SIZE=2>";
         link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600);
         echo "</TD>";
index 4764e965e56a4f66c4f8e2b8f691aeea045c3213..bfd220a551b04861f59b9c1e30802e1e7dfd20fb 100644 (file)
@@ -79,7 +79,7 @@
             }
         }
 
-        $teacher->user   = $user->id;
+        $teacher->userid   = $user->id;
         $teacher->course = $course->id;
         if ($teachers) {
             $teacher->authority = 2;
index fcf6275ba8e23bdcd7ab04a3eea83d2d3cb29110..b16b55d88c922be5251a2b7395c057b8a0f890b3 100644 (file)
@@ -33,7 +33,7 @@
         }
 
         foreach ($rank as $num => $vals) {
-            if (! $teacher = get_record("user_teachers", "course", "$course->id", "user", "$num")) {
+            if (! $teacher = get_record("user_teachers", "course", "$course->id", "userid", "$num")) {
                 error("No such teacher in course $course->shortname with user id $num");
             }
             $teacher->role = $vals[r];
index aed6ec1480d8b498d8d8f96a4f8be63b841646db..c92ea328d96cba4e9b38b75018951efa5baa378f 100644 (file)
@@ -433,6 +433,8 @@ function insert_record($table, $dataobject, $returnid=true) {
 function update_record($table, $dataobject) {
 /// Update a record in a table
 /// $dataobject is an object containing needed data
+/// Relies on $dataobject having a variable "id" to 
+/// specify the record to update
 
     global $db, $CFG;
 
@@ -505,21 +507,21 @@ function get_user_info_from_db($field, $value) {
     if ( $result->RecordCount() == 1 ) {
         $user = (object)$result->fields;
 
-        $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_students WHERE user = '$user->id' ");
+        $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_students WHERE userid = '$user->id' ");
         while (!$rs->EOF) {
             $course = $rs->fields["course"];
             $user->student["$course"] = true;
             $rs->MoveNext();
         }
 
-        $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_teachers WHERE user = '$user->id' ");
+        $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_teachers WHERE userid = '$user->id' ");
         while (!$rs->EOF) {
             $course = $rs->fields["course"];
             $user->teacher["$course"] = true;
             $rs->MoveNext();
         }
 
-        $rs = $db->Execute("SELECT * FROM {$CFG->prefix}user_admins WHERE user = '$user->id' ");
+        $rs = $db->Execute("SELECT * FROM {$CFG->prefix}user_admins WHERE userid = '$user->id' ");
         while (!$rs->EOF) {
             $user->admin = true;
             $rs->MoveNext();
@@ -563,7 +565,7 @@ function adminlogin($username, $md5password) {
     return record_exists_sql("SELECT u.id 
                                 FROM {$CFG->prefix}user u, 
                                      {$CFG->prefix}user_admins a 
-                              WHERE u.id = a.user 
+                              WHERE u.id = a.userid 
                                 AND u.username = '$username' 
                                 AND u.password = '$md5password'");
 }
@@ -623,9 +625,11 @@ function get_admins() {
 
     global $CFG;
 
-    return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_admins a
-                            WHERE a.user = u.id
-                            ORDER BY u.id ASC");
+    return get_records_sql("SELECT u.* 
+                              FROM {$CFG->prefix}user u, 
+                                   {$CFG->prefix}user_admins a
+                             WHERE a.userid = u.id
+                             ORDER BY u.id ASC");
 }
 
 
@@ -651,7 +655,7 @@ function get_course_students($courseid, $sort="u.lastaccess DESC") {
     global $CFG;
 
     return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s
-                            WHERE s.course = '$courseid' AND s.user = u.id AND u.deleted = '0'
+                            WHERE s.course = '$courseid' AND s.userid = u.id AND u.deleted = '0'
                             ORDER BY $sort");
 }
 
@@ -661,7 +665,7 @@ function get_course_teachers($courseid, $sort="t.authority ASC") {
     global $CFG;
 
     return get_records_sql("SELECT u.*,t.authority,t.role FROM {$CFG->prefix}user u, {$CFG->prefix}user_teachers t
-                            WHERE t.course = '$courseid' AND t.user = u.id AND u.deleted = '0'
+                            WHERE t.course = '$courseid' AND t.userid = u.id AND u.deleted = '0'
                             ORDER BY $sort");
 }
 
@@ -680,8 +684,8 @@ function get_course_users($courseid, $sort="u.lastaccess DESC") {
     }
 
 ///    return get_records_sql("SELECT u.* FROM user u, user_students s, user_teachers t
-///                            WHERE (s.course = '$courseid' AND s.user = u.id) OR 
-///                                  (t.course = '$courseid' AND t.user = u.id)
+///                            WHERE (s.course = '$courseid' AND s.userid = u.id) OR 
+///                                  (t.course = '$courseid' AND t.userid = u.id)
 ///                            ORDER BY $sort");
 }
 
@@ -743,7 +747,7 @@ function get_users_longtimenosee($cutofftime) {
                                    {$CFG->prefix}user_students s
                              WHERE lastaccess > '0' 
                                AND lastaccess < '$cutofftime' 
-                               AND u.id = s.user 
+                               AND u.id = s.userid 
                           GROUP BY u.id");
 }
 
@@ -821,15 +825,23 @@ function add_to_log($course, $module, $action, $url="", $info="") {
     $timenow = time();
     $info = addslashes($info);
 
-    $result = $db->Execute("INSERT INTO log
-                            SET time = '$timenow', 
-                                user = '$USER->id',
-                                course = '$course',
-                                ip = '$REMOTE_ADDR', 
-                                module = '$module',
-                                action = '$action',
-                                url = '$url',
-                                info = '$info'");
+    $result = $db->Execute("INSERT INTO log (time,
+                                        userid,
+                                        course,
+                                        ip,
+                                        module,
+                                        action,
+                                        url,
+                                        info)
+                             VALUES ('$timenow',
+                                        '$USER->id',
+                                        '$course',
+                                        '$REMOTE_ADDR',
+                                        '$module',
+                                        '$action',
+                                        '$url',
+                                        '$info')");
+
     if (!$result) {
         echo "<P>Error: Could not insert a new entry to the Moodle log</P>";  // Don't throw an error
     }    
@@ -850,7 +862,7 @@ function get_logs_usercourse($userid, $courseid, $coursestart) {
 
     return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num 
                             FROM {$CFG->prefix}log 
-                           WHERE user = '$userid' 
+                           WHERE userid = '$userid' 
                              AND course = '$courseid'
                              AND `time` > '$coursestart'
                         GROUP BY day ");
@@ -861,7 +873,7 @@ function get_logs_userday($userid, $courseid, $daystart) {
 
     return get_records_sql("SELECT floor((`time` - $daystart)/3600) as hour, count(*) as num
                             FROM {$CFG->prefix}log
-                           WHERE user = '$userid' 
+                           WHERE userid = '$userid' 
                              AND course = '$courseid'
                              AND `time` > '$daystart'
                         GROUP BY hour ");
index edfa29e8146ee2061750d68eae24ed7244818da9..da38bbf4144aea3c46a31ea0ce299addddbb7810 100644 (file)
@@ -216,6 +216,15 @@ function main_upgrade($oldversion=0) {
         set_config("guestloginbutton", 1);
     }
 
+    if ($oldversion < 2002122300) {
+        execute_sql("ALTER TABLE `log` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+        execute_sql("ALTER TABLE `user_admins` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+        execute_sql("ALTER TABLE `user_students` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+        execute_sql("ALTER TABLE `user_teachers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+        execute_sql("ALTER TABLE `user_students` CHANGE `start` `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+        execute_sql("ALTER TABLE `user_students` CHANGE `end` `timeend` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+    }
+
 
     return true;
 }
index f2e134fd5d6736c2fd642641b9d6187d269ee773..77cca11f5d0842204beabbb4acac22f84035f4a7 100644 (file)
@@ -103,7 +103,7 @@ CREATE TABLE `prefix_course_sections` (
 CREATE TABLE `prefix_log` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `time` int(10) unsigned NOT NULL default '0',
-  `user` int(10) unsigned NOT NULL default '0',
+  `userid` int(10) unsigned NOT NULL default '0',
   `ip` varchar(15) NOT NULL default '',
   `course` int(10) unsigned NOT NULL default '0',
   `module` varchar(10) NOT NULL default '',
@@ -191,7 +191,7 @@ CREATE TABLE `prefix_user` (
 
 CREATE TABLE `prefix_user_admins` (
   `id` int(10) unsigned NOT NULL auto_increment,
-  `user` int(10) unsigned NOT NULL default '0',
+  `userid` int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (`id`),
   UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM COMMENT='One record per administrator user';
@@ -203,10 +203,10 @@ CREATE TABLE `prefix_user_admins` (
 
 CREATE TABLE `prefix_user_students` (
   `id` int(10) unsigned NOT NULL auto_increment,
-  `user` int(10) unsigned NOT NULL default '0',
+  `userid` int(10) unsigned NOT NULL default '0',
   `course` int(10) unsigned NOT NULL default '0',
-  `start` int(10) unsigned NOT NULL default '0',
-  `end` int(10) unsigned NOT NULL default '0',
+  `timestart` int(10) unsigned NOT NULL default '0',
+  `timeend` int(10) unsigned NOT NULL default '0',
   `time` int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (`id`),
   UNIQUE KEY `id` (`id`)
@@ -219,7 +219,7 @@ CREATE TABLE `prefix_user_students` (
 
 CREATE TABLE `prefix_user_teachers` (
   `id` int(10) unsigned NOT NULL auto_increment,
-  `user` int(10) unsigned NOT NULL default '0',
+  `userid` int(10) unsigned NOT NULL default '0',
   `course` int(10) unsigned NOT NULL default '0',
   `authority` int(10) NOT NULL default '3',
   `role` varchar(40) NOT NULL default '',
index ccf458feb1b047bcf7c7752c0aab28a7e68881eb..39eb39fde0be9d4e6f61df58c835c1f76a1480a0 100644 (file)
@@ -54,7 +54,7 @@ CREATE TABLE course_sections (
 CREATE TABLE log (
    id SERIAL PRIMARY KEY,
    time integer NOT NULL default '0',
-   "user" integer NOT NULL default '0',
+   userid integer NOT NULL default '0',
    ip varchar(15) NOT NULL default '',
    course integer NOT NULL default '0',
    module varchar(10) NOT NULL default '',
@@ -115,21 +115,21 @@ CREATE TABLE "user" (
 
 CREATE TABLE user_admins (
    id SERIAL PRIMARY KEY,
-   "user" integer NOT NULL default '0'
+   userid integer NOT NULL default '0'
 );
 
 CREATE TABLE user_students (
    id SERIAL PRIMARY KEY,
-   "user" integer NOT NULL default '0',
+   userid integer NOT NULL default '0',
    course integer NOT NULL default '0',
-   "start" integer NOT NULL default '0',
-   "end" integer NOT NULL default '0',
+   timestart integer NOT NULL default '0',
+   timeend integer NOT NULL default '0',
    time integer NOT NULL default '0'
 );
 
 CREATE TABLE user_teachers (
    id SERIAL PRIMARY KEY,
-   "user" integer NOT NULL default '0',
+   userid integer NOT NULL default '0',
    course integer NOT NULL default '0',
    authority integer NOT NULL default '3',
    role varchar(40) NOT NULL default ''
index 462b694eb9f333b690f4cbd2b50dceaf0764dea3..ac56f575f3791c63d344f6d7e4a44f5c14e84683 100644 (file)
@@ -358,10 +358,10 @@ function isadmin($userid=0) {
     global $USER;
 
     if (!$userid) {
-        return record_exists("user_admins", "user", $USER->id);
+        return record_exists("user_admins", "userid", $USER->id);
     }
 
-    return record_exists("user_admins", "user", $userid);
+    return record_exists("user_admins", "userid", $userid);
 }
 
 
@@ -377,7 +377,7 @@ function isteacher($courseid, $userid=0) {
         return $USER->teacher[$courseid];
     }
 
-    return record_exists("user_teachers", "user", $userid, "course", $courseid);
+    return record_exists("user_teachers", "userid", $userid, "course", $courseid);
 }
 
 
@@ -389,9 +389,9 @@ function isstudent($courseid, $userid=0) {
         return $USER->student[$courseid];
     }
 
-    $timenow = time();   // todo:  add time check below
+  //  $timenow = time();   // todo:  add time check below
 
-    return record_exists("user_students", "user", $userid, "course", $courseid);
+    return record_exists("user_students", "userid", $userid, "course", $courseid);
 }
 
 function isguest($userid=0) {
@@ -519,13 +519,13 @@ function enrol_student($user, $course) {
 /// Enrols a student in a given course
     global $db;
 
-    $record->user = $user;
+    $record->userid = $user;
     $record->course = $course;
     $record->start = 0;
     $record->end = 0;
     $record->time = time();
 
-    return insert_record("user", $record);
+    return insert_record("user_students", $record);
 }
 
 function unenrol_student($user, $course=0) {
@@ -536,14 +536,14 @@ function unenrol_student($user, $course=0) {
         /// First delete any crucial stuff that might still send mail
         if ($forums = get_records("forum", "course", $course)) {
             foreach ($forums as $forum) {
-                delete_records("forum_subscriptions", "forum", $forum->id, "user", $user);
+                delete_records("forum_subscriptions", "forum", $forum->id, "userid", $user);
             }
         }
-        return delete_records("user_students", "user", $user, "course", $course);
+        return delete_records("user_students", "userid", $user, "course", $course);
 
     } else {
-        delete_records("forum_subscriptions", "user", $user);
-        return delete_records("user_students", "user", $user);
+        delete_records("forum_subscriptions", "userid", $user);
+        return delete_records("user_students", "userid", $user);
     }
 }
 
@@ -556,13 +556,13 @@ function remove_teacher($user, $course=0) {
         /// First delete any crucial stuff that might still send mail
         if ($forums = get_records("forum", "course", $course)) {
             foreach ($forums as $forum) {
-                delete_records("forum_subscriptions", "forum", $forum->id, "user", $user);
+                delete_records("forum_subscriptions", "forum", $forum->id, "userid", $user);
             }
         }
-        return delete_records("user_teachers", "user", $user, "course", $course);
+        return delete_records("user_teachers", "userid", $user, "course", $course);
     } else {
-        delete_records("forum_subscriptions", "user", $user);
-        return delete_records("user_teachers", "user", $user);
+        delete_records("forum_subscriptions", "userid", $user);
+        return delete_records("user_teachers", "userid", $user);
     }
 }
 
@@ -570,7 +570,7 @@ function remove_admin($user) {
 /// Removes an admin from a site
     global $db;
 
-    return delete_records("user_admins", "user", $user);
+    return delete_records("user_admins", "userid", $user);
 }
 
 
index 5a5a6bda55691a2e532c63dab24ead8550f981a4..222764950a54dc7e5ceef040746fc8e5d4c62c6d 100644 (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;
 }
index 3c6f06f2fb46d60bea8fd2eb318d51710037bbd1..c4f431cf613d8c248249dca095d8d399a5812758 100644 (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',
index 710caa71830a9dfc24b9e6253d4838c58de2a960..1348a7fe7dbb64c36b808403015e1f068a70aa2c 100644 (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',
index 4aac51e0949ae82dacf334c7cd77c48ddc5103da..ce1806278011b28d3943517bbcc923716d1a39d1 100644 (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) {
index faabd55505ef323425381035bf84a06113053367..42f0be30e8e2bcf95bdeef37b26f343fcef3aba4 100644 (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++;
                 }
     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);
     }
 
index b1dbc04a725f46546a44d5aa59252b14ed67be19..9b48d8e241cf939174003213249a8331bcbdd91b 100644 (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;
index 114d6377a826987f9374357b242d94555c9443ad..303c37261662b4ca44e26ff5c90745a0ef33ae28 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002111500;
+$module->version  = 2002122300;
 $module->cron     = 60;
 
 ?>
index 47c741f552fb6b1e9c43c51043784de14423f438..28c490b6c32278df63254d6477a8092a350915ee 100644 (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;
 }
 
index aad4042c015b13f077ae19cdfd65eee872877452..8184886ee7ac927ef5cf46b2a128606794784ca5 100755 (executable)
@@ -40,7 +40,7 @@ CREATE TABLE prefix_choice (
 CREATE TABLE prefix_choice_answers (\r
   id int(10) unsigned NOT NULL auto_increment,\r
   choice int(10) unsigned NOT NULL default '0',\r
-  user int(10) unsigned NOT NULL default '0',\r
+  userid int(10) unsigned NOT NULL default '0',\r
   answer tinyint(4) NOT NULL default '0',\r
   timemodified int(10) NOT NULL default '0',\r
   PRIMARY KEY  (id),\r
index 47c741f552fb6b1e9c43c51043784de14423f438..830a3b20a802867a361a2abe28406658a2512012 100644 (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;
 }
 
index e93c1e36e107754a01d7679c66bdc95394759c1b..e1dbe97ea1ee750162f0a8086122948d306f8b75 100755 (executable)
@@ -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'
 );
index cd80379622f4fc4871292816ab72971d5d7100b9..c28fe4709b8b04be48652341fc8b5421ae25e28a 100644 (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;
         }
index f0c35817acc7e330757675ca98fb4bef0f003789..eb8ce90e1fba2fc6465bbdf2c08671d7678d8a88 100644 (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);
index 39c4b7aa23503e2c47ebcaa81eb450f8f8be16d8..df27b580c609c414c8c351020795589d7a8b1633 100644 (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 () ;
index 1254eb5efcc10c756f6bf7924a5969ca0bd17933..a8433671888ced7f345edd002eef1bdb847a43ad 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002102400;
+$module->version  = 2002122300;
 $module->cron     = 0;
 
 ?>
index cb4fdb67000ae09b4d6e0d39c5c5635ca97c481b..22f7190dadc5e41110c3085a7df9c1ed065ca718 100644 (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)) {
index 58f758db217bcb1e63de621e6b2276b32da07215..4381eff1d661ba2d0cd875f4cf8d1f06daa1f8e8 100644 (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;
 
 }
index 04e4121a982c75d4853be24a9f0a9b5770f85a3f..9131f4e813530a3ae07d71f9dae0fda701e5f9ce 100644 (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)
index a5593235c61765b51303c9ae8c1efee2c898b8e4..eb40f2fa0e3da9648be404f7d36c3b49c10f953f 100644 (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;
 
index 92d85fc690a24cc56619eb0de92779a9e51f8fe6..44031854cb67544b2025ae0dcdbb76680518574d 100644 (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'
 );
 # --------------------------------------------------------
index dc9bf022c50e2ab4da6a36b13e972d27901169d2..40271e4449aa9954edee4a03215e4e1ff3641258 100644 (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);
index 4582363f168f05ed13359c7e6f7b7b17e15a027e..d3ccf63ffda5015beaaaf158a03b5a8360e3d54c 100644 (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>
index abdb5a0260d8015e83838f15d5111a30640dbe9b..3b2a7e350d7161c470f4d26338e3c83ba7c24c5a 100644 (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;
 
         $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;
 
         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) {
         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!");
         }
 
index c24213e1d94816bc4eae8ee166a1002ce70b4332..8f51c22aaa9491403e55bedd1141b83b54ecbb37 100644 (file)
                 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;
index 790a63df3baa9056ab7bea9ac96753e7327c2114..66fdc43dbdfbcbbb12f306e18dcf194d62252280 100644 (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");
     }
 
index 4122d7cef1de9e14d93803c6f6cf9347b002a187..ab0cf48acacf96a0b2381fdfa09186321105dbe2 100644 (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);
 
index b320fedd205f92186751710031f335b0746851ec..303c37261662b4ca44e26ff5c90745a0ef33ae28 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002101001;
+$module->version  = 2002122300;
 $module->cron     = 60;
 
 ?>
index 7a3e8887a0f1170ee0d2f2c5c9394c79938b70a5..f62e553e760b075df29431fe6af636a026e4f3fe 100644 (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;
 }
index 4bc1ed39f861021d18df008e80396799c3ab1380..ff1496a16643b97881f228f2873a9334ee625a93 100755 (executable)
@@ -33,7 +33,7 @@ CREATE TABLE prefix_journal (
 CREATE TABLE prefix_journal_entries (\r
   id int(10) unsigned NOT NULL auto_increment,\r
   journal int(10) unsigned NOT NULL default '0',\r
-  user int(10) unsigned NOT NULL default '0',\r
+  userid int(10) unsigned NOT NULL default '0',\r
   modified int(10) unsigned NOT NULL default '0',\r
   text text NOT NULL,\r
   format tinyint(2) NOT NULL default '0',\r
index 34c00b7fc01b96abf6da3062e47b27e396b7963f..7b8fad7f53eb837a494c432fdea6710e5c513d07 100644 (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;
 }
index 415410c91d379a4f26e127428e6053da63fbca69..71f301a03bc46b673e769ab23098505559fbaf4a 100755 (executable)
@@ -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',
index 3fff3842e926579860ee0af773991aaf58ae2014..f07189f6bad4d852b6012488b8f528d0d568fac3 100644 (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;
index 21938b3d7836a156817f24d05834ccbf67278087..0b7e1f264bd2fa778377928557f665bdb1534a64 100644 (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) {
index d9d95d348a46b0daca779301890925324df094a6..721609711c7693d8cacece78c4cd0234069ad618 100644 (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 ///////////////////////////////////////////////////////////////////
index fa66bf925f89b9dcb50c3f5c2a9e230fafc4eb62..808975461d2dee19eb8960f42a6b0d9829048836 100644 (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;
         }
         
                 $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");
index e66cd09b9fea95fc681e68b6f9e43833ee2b5d68..303c37261662b4ca44e26ff5c90745a0ef33ae28 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002101200;
+$module->version  = 2002122300;
 $module->cron     = 60;
 
 ?>
index cce12686be2a9c71a21b7193df058fbf861abd06..e800aec7c126800d35456c5719db519001f0c906 100644 (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>";
index 1fbcf8ae84bc0fe57d6668d848cf66db033b26db..e369d715bfc3a934894fd3cc21535103ae57b777 100644 (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;
 }
 
index 029cf3fbbdff4bf2dc91e7d88594c31b01928839..f8042432dbbe5ba644af4246ee2497e713e79d99 100644 (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`)
index 1fbcf8ae84bc0fe57d6668d848cf66db033b26db..1af9d80d021ced3b330bfbdb45efe8486f4d1780 100644 (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;
 }
 
index da2e58ffd32d1d28f02eb8b9ed4a99570e6b9a1d..e93189a68e14a69de7d6d112436601334763a9a3 100644 (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'
 );
index 32d6ba225ea7923d0cc8beb519deb2fa0228ab7d..a9b091a3edf35dab7f21c2c3e862b44fcdbea261 100644 (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)) {
index e6a0bffc82a41bf3031793026d55c146fd64ec38..e3f08233529808ce6974be8459b4ed3b6423cc8d 100644 (file)
                 }
             }
 
-            $users[$attempt->user] = $attempt->user;
+            $users[$attempt->userid] = $attempt->userid;
         }
 
         if ($users) {
     $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));
     }
 
index b6f03231b0f3d3f9d948bed97543b981ace5e786..24bfb42f241855ed14a9f7411a1dfb916f5f2865 100644 (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)?
 
 ?>
index a9446ba3d7f1d3d3e0d6298131ecf19597b21c31..c3f65ca52203f3ec038a75d77f29ed9fed4793c0 100644 (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);
 
index a2c41c20251746f0ea8aa24b56fddd5e10f0294f..a8433671888ced7f345edd002eef1bdb847a43ad 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002101700;
+$module->version  = 2002122300;
 $module->cron     = 0;
 
 ?>
index 1b0ead621cdd8c81895f88faff62d52ef66cbd0f..2486ba64ac3419446a3349cdf5c8435d7ad8577a 100644 (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;
 }
index cbae8ad76c4d2f4e3141c399d7ff80e5b7158f23..40df0fbc0a9457ab76ab1fecca3e364997017b46 100755 (executable)
@@ -45,7 +45,7 @@ INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`,
 CREATE TABLE prefix_survey_analysis (\r
   id int(10) unsigned NOT NULL auto_increment,\r
   survey int(10) unsigned NOT NULL default '0',\r
-  user int(10) unsigned NOT NULL default '0',\r
+  userid int(10) unsigned NOT NULL default '0',\r
   notes text NOT NULL,\r
   PRIMARY KEY  (id),\r
   UNIQUE KEY id (id)\r
@@ -63,7 +63,7 @@ CREATE TABLE prefix_survey_analysis (
 \r
 CREATE TABLE prefix_survey_answers (\r
   id int(10) unsigned NOT NULL auto_increment,\r
-  user int(10) unsigned NOT NULL default '0',\r
+  userid int(10) unsigned NOT NULL default '0',\r
   survey int(10) unsigned NOT NULL default '0',\r
   question int(10) unsigned NOT NULL default '0',\r
   time int(10) unsigned default NULL,\r
index 1b0ead621cdd8c81895f88faff62d52ef66cbd0f..91c00d001786d20182e4bfd42e194acaf624c475 100644 (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;
 }
index dfb70f6ede4c825270878adc755f51401910e4f6..16c46336f2264057347938060fd68ef70b87e64f 100755 (executable)
@@ -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,
index f7044c8325a88b228194522a23893314d1c4a670..68063f01af78b21acf8b02196f2843ff04d380ed 100644 (file)
     }
    
     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;
     }
 
 
             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";
index 8c9ee557cc23f0d670edc3111732576b563c8ad0..dabc0874bc98d138e7b2d05908cfadfe4c156149 100644 (file)
 
            if ($aaa) {
                foreach ($aaa as $a) {
-                   if ($a->user == $sid) {
+                   if ($a->userid == $sid) {
                        if ($a->answer1) {
                            $studbuckets1[$i] += $a->answer1;
                            $studcount1[$i]++;
        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]++;
index 931e99355f1a59e39105fd02bb15540ec1b368cd..2aeafbc43aa5bd8fd93b88e53d1c3dd5fa32b521 100644 (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) {
index a15e057fa11488401180566829882aae47a15da1..1c4df5d301d1a4b0b1afda17a215c9b732c05d88 100644 (file)
             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) {
              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)) {
index 5e56aef4e4399631819edcb1e7afe2dbd79a1e80..62ef15979ce7da312db1128b677103c668999c89 100644 (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];
index 9a764ed9f40bdc2d1ec40d557aa92668322e7c94..a8433671888ced7f345edd002eef1bdb847a43ad 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002110903;
+$module->version  = 2002122300;
 $module->cron     = 0;
 
 ?>
index 00dc1cd3fefc9f2468abde86d8105f6dc8e53691..f90da796db7f49c27db3b7b3d19768e3ec2c7b09 100644 (file)
             echo "</FORM></P></TD>";
         }
     }
-    if ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or 
-        (isteacher($course->id) and isstudent($course->id, $user->id)) ) {
+    if ($course->category and 
+        ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or 
+        (isteacher($course->id) and isstudent($course->id, $user->id))) ) {
         echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
         echo "<INPUT type=hidden name=id value=\"$course->id\">";
         echo "<INPUT type=hidden name=user value=\"$user->id\">";
index 96896df755d86a011785f09de79eb9b8b384fe50..8519838cd077a37e7b197bd4909acdf17a8f1623 100644 (file)
@@ -5,7 +5,7 @@
 // database to determine whether upgrades should
 // be performed (see lib/db/*.php)
 
-$version = 2002121200;   // The current version is a date (YYYYMMDDXX)
+$version = 2002122300;   // The current version is a date (YYYYMMDDXX)
 
 $release = "1.0.8 dev";  // User-friendly version number