Changes throughout Moodle to remove any reserved words from the

Moodle tables.

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

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

Note that this version should pretty much be able to bootstrap itself
using PostgreSQL now ... but this is untested
This commit is contained in:
moodler 2002-12-23 09:39:26 +00:00
parent 1f48942e7d
commit ebc3bd2b24
68 changed files with 277 additions and 461 deletions

View file

@ -67,7 +67,7 @@
} }
} }
$admin->user = $user->id; $admin->userid = $user->id;
$admin->id = insert_record("user_admins", $admin); $admin->id = insert_record("user_admins", $admin);
$admins[] = $user; $admins[] = $user;
} }

View file

@ -28,7 +28,7 @@
error("SERIOUS ERROR: Could not create admin user record !!!"); error("SERIOUS ERROR: Could not create admin user record !!!");
} }
$admin->user = $user->id; $admin->userid = $user->id;
if (! insert_record("user_admins", $admin)) { if (! insert_record("user_admins", $admin)) {
error("Could not make user $user->id an admin !!!"); error("Could not make user $user->id an admin !!!");
@ -42,7 +42,7 @@
error("Could not find site-level course"); error("Could not find site-level course");
} }
$teacher->user = $user->id; $teacher->userid = $user->id;
$teacher->course = $site->id; $teacher->course = $site->id;
$teacher->authority = 1; $teacher->authority = 1;
if (! insert_record("user_teachers", $teacher)) { if (! insert_record("user_teachers", $teacher)) {

View 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. // and so the next 86400 seconds worth of logs are printed.
if ($course->category) { 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 { } else {
$selector = "WHERE l.user = u.id"; // Show all courses $selector = "WHERE l.userid = u.id"; // Show all courses
if ($ccc = get_courses(-1)) { if ($ccc = get_courses(-1)) {
foreach ($ccc as $cc) { foreach ($ccc as $cc) {
$courses[$cc->id] = "$cc->shortname"; $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) { if ($user) {
$selector .= " AND l.user = '$user'"; $selector .= " AND l.userid = '$user'";
} }
if ($date) { 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 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>".userdate($log->time, "%d %B %Y, %I:%M %p")."</TD>";
echo "<TD NOWRAP><FONT SIZE=2>"; 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>";
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>"; echo "<TD NOWRAP><FONT SIZE=2>";
link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600); link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600);
echo "</TD>"; echo "</TD>";

View file

@ -79,7 +79,7 @@
} }
} }
$teacher->user = $user->id; $teacher->userid = $user->id;
$teacher->course = $course->id; $teacher->course = $course->id;
if ($teachers) { if ($teachers) {
$teacher->authority = 2; $teacher->authority = 2;

View file

@ -33,7 +33,7 @@
} }
foreach ($rank as $num => $vals) { 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"); error("No such teacher in course $course->shortname with user id $num");
} }
$teacher->role = $vals[r]; $teacher->role = $vals[r];

View file

@ -433,6 +433,8 @@ function insert_record($table, $dataobject, $returnid=true) {
function update_record($table, $dataobject) { function update_record($table, $dataobject) {
/// Update a record in a table /// Update a record in a table
/// $dataobject is an object containing needed data /// $dataobject is an object containing needed data
/// Relies on $dataobject having a variable "id" to
/// specify the record to update
global $db, $CFG; global $db, $CFG;
@ -505,21 +507,21 @@ function get_user_info_from_db($field, $value) {
if ( $result->RecordCount() == 1 ) { if ( $result->RecordCount() == 1 ) {
$user = (object)$result->fields; $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) { while (!$rs->EOF) {
$course = $rs->fields["course"]; $course = $rs->fields["course"];
$user->student["$course"] = true; $user->student["$course"] = true;
$rs->MoveNext(); $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) { while (!$rs->EOF) {
$course = $rs->fields["course"]; $course = $rs->fields["course"];
$user->teacher["$course"] = true; $user->teacher["$course"] = true;
$rs->MoveNext(); $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) { while (!$rs->EOF) {
$user->admin = true; $user->admin = true;
$rs->MoveNext(); $rs->MoveNext();
@ -563,7 +565,7 @@ function adminlogin($username, $md5password) {
return record_exists_sql("SELECT u.id return record_exists_sql("SELECT u.id
FROM {$CFG->prefix}user u, FROM {$CFG->prefix}user u,
{$CFG->prefix}user_admins a {$CFG->prefix}user_admins a
WHERE u.id = a.user WHERE u.id = a.userid
AND u.username = '$username' AND u.username = '$username'
AND u.password = '$md5password'"); AND u.password = '$md5password'");
} }
@ -623,8 +625,10 @@ function get_admins() {
global $CFG; global $CFG;
return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_admins a return get_records_sql("SELECT u.*
WHERE a.user = u.id FROM {$CFG->prefix}user u,
{$CFG->prefix}user_admins a
WHERE a.userid = u.id
ORDER BY u.id ASC"); ORDER BY u.id ASC");
} }
@ -651,7 +655,7 @@ function get_course_students($courseid, $sort="u.lastaccess DESC") {
global $CFG; global $CFG;
return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s 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"); ORDER BY $sort");
} }
@ -661,7 +665,7 @@ function get_course_teachers($courseid, $sort="t.authority ASC") {
global $CFG; global $CFG;
return get_records_sql("SELECT u.*,t.authority,t.role FROM {$CFG->prefix}user u, {$CFG->prefix}user_teachers t 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"); 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 /// 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 /// WHERE (s.course = '$courseid' AND s.userid = u.id) OR
/// (t.course = '$courseid' AND t.user = u.id) /// (t.course = '$courseid' AND t.userid = u.id)
/// ORDER BY $sort"); /// ORDER BY $sort");
} }
@ -743,7 +747,7 @@ function get_users_longtimenosee($cutofftime) {
{$CFG->prefix}user_students s {$CFG->prefix}user_students s
WHERE lastaccess > '0' WHERE lastaccess > '0'
AND lastaccess < '$cutofftime' AND lastaccess < '$cutofftime'
AND u.id = s.user AND u.id = s.userid
GROUP BY u.id"); GROUP BY u.id");
} }
@ -821,15 +825,23 @@ function add_to_log($course, $module, $action, $url="", $info="") {
$timenow = time(); $timenow = time();
$info = addslashes($info); $info = addslashes($info);
$result = $db->Execute("INSERT INTO log $result = $db->Execute("INSERT INTO log (time,
SET time = '$timenow', userid,
user = '$USER->id', course,
course = '$course', ip,
ip = '$REMOTE_ADDR', module,
module = '$module', action,
action = '$action', url,
url = '$url', info)
info = '$info'"); VALUES ('$timenow',
'$USER->id',
'$course',
'$REMOTE_ADDR',
'$module',
'$action',
'$url',
'$info')");
if (!$result) { if (!$result) {
echo "<P>Error: Could not insert a new entry to the Moodle log</P>"; // Don't throw an error 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 return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num
FROM {$CFG->prefix}log FROM {$CFG->prefix}log
WHERE user = '$userid' WHERE userid = '$userid'
AND course = '$courseid' AND course = '$courseid'
AND `time` > '$coursestart' AND `time` > '$coursestart'
GROUP BY day "); 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 return get_records_sql("SELECT floor((`time` - $daystart)/3600) as hour, count(*) as num
FROM {$CFG->prefix}log FROM {$CFG->prefix}log
WHERE user = '$userid' WHERE userid = '$userid'
AND course = '$courseid' AND course = '$courseid'
AND `time` > '$daystart' AND `time` > '$daystart'
GROUP BY hour "); GROUP BY hour ");

View file

@ -216,6 +216,15 @@ function main_upgrade($oldversion=0) {
set_config("guestloginbutton", 1); 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; return true;
} }

View file

@ -103,7 +103,7 @@ CREATE TABLE `prefix_course_sections` (
CREATE TABLE `prefix_log` ( CREATE TABLE `prefix_log` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`time` int(10) unsigned NOT NULL default '0', `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 '', `ip` varchar(15) NOT NULL default '',
`course` int(10) unsigned NOT NULL default '0', `course` int(10) unsigned NOT NULL default '0',
`module` varchar(10) NOT NULL default '', `module` varchar(10) NOT NULL default '',
@ -191,7 +191,7 @@ CREATE TABLE `prefix_user` (
CREATE TABLE `prefix_user_admins` ( CREATE TABLE `prefix_user_admins` (
`id` int(10) unsigned NOT NULL auto_increment, `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`), PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`) UNIQUE KEY `id` (`id`)
) TYPE=MyISAM COMMENT='One record per administrator user'; ) TYPE=MyISAM COMMENT='One record per administrator user';
@ -203,10 +203,10 @@ CREATE TABLE `prefix_user_admins` (
CREATE TABLE `prefix_user_students` ( CREATE TABLE `prefix_user_students` (
`id` int(10) unsigned NOT NULL auto_increment, `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', `course` int(10) unsigned NOT NULL default '0',
`start` int(10) unsigned NOT NULL default '0', `timestart` int(10) unsigned NOT NULL default '0',
`end` int(10) unsigned NOT NULL default '0', `timeend` int(10) unsigned NOT NULL default '0',
`time` int(10) unsigned NOT NULL default '0', `time` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`) UNIQUE KEY `id` (`id`)
@ -219,7 +219,7 @@ CREATE TABLE `prefix_user_students` (
CREATE TABLE `prefix_user_teachers` ( CREATE TABLE `prefix_user_teachers` (
`id` int(10) unsigned NOT NULL auto_increment, `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', `course` int(10) unsigned NOT NULL default '0',
`authority` int(10) NOT NULL default '3', `authority` int(10) NOT NULL default '3',
`role` varchar(40) NOT NULL default '', `role` varchar(40) NOT NULL default '',

View file

@ -54,7 +54,7 @@ CREATE TABLE course_sections (
CREATE TABLE log ( CREATE TABLE log (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
time integer NOT NULL default '0', time integer NOT NULL default '0',
"user" integer NOT NULL default '0', userid integer NOT NULL default '0',
ip varchar(15) NOT NULL default '', ip varchar(15) NOT NULL default '',
course integer NOT NULL default '0', course integer NOT NULL default '0',
module varchar(10) NOT NULL default '', module varchar(10) NOT NULL default '',
@ -115,21 +115,21 @@ CREATE TABLE "user" (
CREATE TABLE user_admins ( CREATE TABLE user_admins (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0' userid integer NOT NULL default '0'
); );
CREATE TABLE user_students ( CREATE TABLE user_students (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0', userid integer NOT NULL default '0',
course integer NOT NULL default '0', course integer NOT NULL default '0',
"start" integer NOT NULL default '0', timestart integer NOT NULL default '0',
"end" integer NOT NULL default '0', timeend integer NOT NULL default '0',
time integer NOT NULL default '0' time integer NOT NULL default '0'
); );
CREATE TABLE user_teachers ( CREATE TABLE user_teachers (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0', userid integer NOT NULL default '0',
course integer NOT NULL default '0', course integer NOT NULL default '0',
authority integer NOT NULL default '3', authority integer NOT NULL default '3',
role varchar(40) NOT NULL default '' role varchar(40) NOT NULL default ''

View file

@ -358,10 +358,10 @@ function isadmin($userid=0) {
global $USER; global $USER;
if (!$userid) { 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 $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]; 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) { function isguest($userid=0) {
@ -519,13 +519,13 @@ function enrol_student($user, $course) {
/// Enrols a student in a given course /// Enrols a student in a given course
global $db; global $db;
$record->user = $user; $record->userid = $user;
$record->course = $course; $record->course = $course;
$record->start = 0; $record->start = 0;
$record->end = 0; $record->end = 0;
$record->time = time(); $record->time = time();
return insert_record("user", $record); return insert_record("user_students", $record);
} }
function unenrol_student($user, $course=0) { 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 /// First delete any crucial stuff that might still send mail
if ($forums = get_records("forum", "course", $course)) { if ($forums = get_records("forum", "course", $course)) {
foreach ($forums as $forum) { 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 { } else {
delete_records("forum_subscriptions", "user", $user); delete_records("forum_subscriptions", "userid", $user);
return delete_records("user_students", "user", $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 /// First delete any crucial stuff that might still send mail
if ($forums = get_records("forum", "course", $course)) { if ($forums = get_records("forum", "course", $course)) {
foreach ($forums as $forum) { 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 { } else {
delete_records("forum_subscriptions", "user", $user); delete_records("forum_subscriptions", "userid", $user);
return delete_records("user_teachers", "user", $user); return delete_records("user_teachers", "userid", $user);
} }
} }
@ -570,7 +570,7 @@ function remove_admin($user) {
/// Removes an admin from a site /// Removes an admin from a site
global $db; global $db;
return delete_records("user_admins", "user", $user); return delete_records("user_admins", "userid", $user);
} }

View file

@ -88,6 +88,9 @@ function assignment_upgrade($oldversion) {
if ($oldversion < 2002111500) { if ($oldversion < 2002111500) {
execute_sql(" ALTER TABLE `assignment` ADD `resubmit` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `format` "); 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; return true;
} }

View file

@ -25,7 +25,7 @@ CREATE TABLE `prefix_assignment` (
CREATE TABLE `prefix_assignment_submissions` ( CREATE TABLE `prefix_assignment_submissions` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`assignment` int(10) unsigned NOT NULL default '0', `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', `timecreated` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0', `timemodified` int(10) unsigned NOT NULL default '0',
`numfiles` int(10) unsigned NOT NULL default '0', `numfiles` int(10) unsigned NOT NULL default '0',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,6 +14,9 @@ function choice_upgrade($oldversion) {
execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`"); execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`");
execute_sql(" ALTER TABLE `choice` ADD `answer6` varchar(255) NOT NULL AFTER `answer5`"); 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; return true;
} }

View file

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

View file

@ -4,16 +4,6 @@ function choice_upgrade($oldversion) {
// This function does anything necessary to upgrade // This function does anything necessary to upgrade
// older versions to match current functionality // 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; return true;
} }

View file

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

View file

@ -28,7 +28,7 @@
notice("There are no choices", "../../course/view.php?id=$course->id"); 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) { foreach ($allanswers as $aa) {
$answers[$aa->choice] = $aa; $answers[$aa->choice] = $aa;
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -50,6 +50,12 @@ function forum_upgrade($oldversion) {
execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` "); 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; return true;
} }

View file

@ -41,7 +41,7 @@ CREATE TABLE prefix_forum_posts (
id int(10) unsigned NOT NULL auto_increment, id int(10) unsigned NOT NULL auto_increment,
discussion int(10) unsigned NOT NULL default '0', discussion int(10) unsigned NOT NULL default '0',
parent 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', created int(10) unsigned NOT NULL default '0',
modified int(10) unsigned NOT NULL default '0', modified int(10) unsigned NOT NULL default '0',
mailed tinyint(1) 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 ( CREATE TABLE prefix_forum_ratings (
id int(10) unsigned NOT NULL auto_increment, 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', post int(10) unsigned NOT NULL default '0',
time int(10) unsigned NOT NULL default '0', time int(10) unsigned NOT NULL default '0',
rating tinyint(4) 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 ( CREATE TABLE prefix_forum_subscriptions (
id int(10) unsigned NOT NULL auto_increment, 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', forum int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE KEY id (id) UNIQUE KEY id (id)

View file

@ -4,51 +4,7 @@ function forum_upgrade($oldversion) {
// This function does anything necessary to upgrade // This function does anything necessary to upgrade
// older versions to match current functionality // older versions to match current functionality
if ($oldversion < 2002073008) { global $CFG;
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` ");
}
return true; return true;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,7 +23,7 @@
error("Course ID was incorrect"); 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"); error("You can only look at results for posts you own");
} }

View file

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

View file

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

View file

@ -14,6 +14,10 @@ function journal_upgrade($oldversion) {
if ($oldversion < 2002101200) { if ($oldversion < 2002101200) {
execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` "); 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; return $result;
} }

View file

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

View file

@ -6,14 +6,5 @@ function journal_upgrade($oldversion) {
$result = true; $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; return $result;
} }

View file

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

View file

@ -22,7 +22,7 @@
error("Course module is incorrect"); 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. /// 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"); add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id");
} else { } else {
$newentry->user = $USER->id; $newentry->userid = $USER->id;
$newentry->journal = $journal->id; $newentry->journal = $journal->id;
$newentry->modified = $timenow; $newentry->modified = $timenow;
$newentry->text = $text; $newentry->text = $text;

View file

@ -49,7 +49,7 @@
foreach ($journals as $journal) { 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); $journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
if ($journal->daysopen) { if ($journal->daysopen) {

View file

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

View file

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

View file

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

View file

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

View file

@ -24,6 +24,11 @@ function quiz_upgrade($oldversion) {
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL "); 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; return true;
} }

View file

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

View file

@ -6,24 +6,6 @@ function quiz_upgrade($oldversion) {
global $CFG; 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; return true;
} }

View file

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

View file

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

View file

@ -142,7 +142,7 @@
} }
} }
$users[$attempt->user] = $attempt->user; $users[$attempt->userid] = $attempt->userid;
} }
if ($users) { if ($users) {
@ -169,14 +169,14 @@
$table->width = array(10, "*", "*", 20); $table->width = array(10, "*", "*", 20);
foreach ($grades as $grade) { 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); $userattempts = quiz_get_user_attempts_string($quiz, $attempts, $grade->grade);
} }
$table->data[] = array ($picture, $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)); "$userattempts", round($grade->grade,0));
} }

View file

@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php // 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)? $module->cron = 0; // How often should cron check this module (seconds)?
?> ?>

View file

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

View file

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

View file

@ -151,6 +151,10 @@ function survey_upgrade($oldversion) {
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm2', `shorttext` = 'attlsm2', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Connected Learning'"); execute_sql("UPDATE `survey_questions` SET `text` = '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'"); 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; return true;
} }

View file

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

View file

@ -4,153 +4,7 @@ function survey_upgrade($oldversion) {
// This function does anything necessary to upgrade // This function does anything necessary to upgrade
// older versions to match current functionality // older versions to match current functionality
if ($oldversion < 2002081400) { global $CFG;
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'");
}
return true; return true;
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -217,9 +217,9 @@
foreach ($aaa as $a) { foreach ($aaa as $a) {
echo "<TR>"; echo "<TR>";
echo "<TD WIDTH=35>"; 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>";
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><P>".userdate($a->time, "%d %B %Y, %I:%M %p")."</TD>";
echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>"; echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
if ($a->answer1) { if ($a->answer1) {
@ -261,7 +261,7 @@
error("Student doesn't exist"); 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")); get_string("analysisof", "survey", "$user->firstname $user->lastname"));
if (isset($notes)) { if (isset($notes)) {

View file

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

View file

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

View file

@ -140,8 +140,9 @@
echo "</FORM></P></TD>"; echo "</FORM></P></TD>";
} }
} }
if ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or if ($course->category and
(isteacher($course->id) and isstudent($course->id, $user->id)) ) { ((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 "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
echo "<INPUT type=hidden name=id value=\"$course->id\">"; echo "<INPUT type=hidden name=id value=\"$course->id\">";
echo "<INPUT type=hidden name=user value=\"$user->id\">"; echo "<INPUT type=hidden name=user value=\"$user->id\">";

View file

@ -5,7 +5,7 @@
// database to determine whether upgrades should // database to determine whether upgrades should
// be performed (see lib/db/*.php) // 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 $release = "1.0.8 dev"; // User-friendly version number