Added a new column to user_students and user_teachers called "timeaccess"

for recording the last access to the COURSE.

This is updated at the same time as add_to_log and is now used instead
of user->lastaccess when course user listings are required.

This means course listings now show what you expect and open up the way
for a "current users" listing and instant messaging etc ...
This commit is contained in:
moodler 2003-10-27 12:38:00 +00:00
parent ecd25101f5
commit 4d744a220a
8 changed files with 62 additions and 17 deletions

View file

@ -19,7 +19,7 @@
function main_upgrade($oldversion=0) {
global $CFG, $THEME;
global $CFG, $THEME, $db;
$result = true;
@ -509,6 +509,20 @@ function main_upgrade($oldversion=0) {
table_column("course", "", "maxbytes", "integer", "10", "unsigned", "0", "", "marker");
}
if ($oldversion < 2003102700) {
table_column("user_students", "", "timeaccess", "integer", "10", "unsigned", "0", "", "time");
table_column("user_teachers", "", "timeaccess", "integer", "10", "unsigned", "0", "", "timemodified");
$users = get_records_select("user", "id > 0", "", "id, lastaccess");
$db->debug = false;
foreach ($users as $user) {
execute_sql("UPDATE {$CFG->prefix}user_students SET timeaccess = '$user->lastaccess' WHERE userid = '$user->id'", false);
execute_sql("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$user->lastaccess' WHERE userid = '$user->id'", false);
}
$db->debug = true;
}
return $result;
}

View file

@ -262,6 +262,7 @@ CREATE TABLE `prefix_user_students` (
`timestart` int(10) unsigned NOT NULL default '0',
`timeend` int(10) unsigned NOT NULL default '0',
`time` int(10) unsigned NOT NULL default '0',
`timeaccess` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `courseuserid` (course,userid)
@ -280,6 +281,7 @@ CREATE TABLE `prefix_user_teachers` (
`role` varchar(40) NOT NULL default '',
`editall` int(1) unsigned NOT NULL default '1',
`timemodified` int(10) unsigned NOT NULL default '0',
`timeaccess` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `courseuserid` (course,userid)

View file

@ -19,7 +19,7 @@
function main_upgrade($oldversion=0) {
global $CFG, $THEME;
global $CFG, $THEME, $db;
$result = true;
@ -258,6 +258,21 @@ function main_upgrade($oldversion=0) {
table_column("course", "", "maxbytes", "integer", "10", "unsigned", "0", "", "marker");
}
if ($oldversion < 2003102700) {
table_column("user_students", "", "timeaccess", "integer", "10", "unsigned", "0", "", "time");
table_column("user_teachers", "", "timeaccess", "integer", "10", "unsigned", "0", "", "timemodified");
$users = get_records_select("user", "id > 0", "", "id, lastaccess");
$db->debug = false;
foreach ($users as $user) {
execute_sql("UPDATE {$CFG->prefix}user_students SET timeaccess = '$user->lastaccess' WHERE userid = '$user->id'", false);
execute_sql("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$user->lastaccess' WHERE userid = '$user->id'", false);
}
$db->debug = true;
}
return $result;
}
?>

View file

@ -167,7 +167,8 @@ CREATE TABLE prefix_user_students (
course integer NOT NULL default '0',
timestart integer NOT NULL default '0',
timeend integer NOT NULL default '0',
time integer NOT NULL default '0'
time integer NOT NULL default '0',
timeaccess integer NOT NULL default '0'
);
CREATE INDEX prefix_user_students_courseuserid_idx ON prefix_user_students (course,userid);
@ -179,7 +180,8 @@ CREATE TABLE prefix_user_teachers (
authority integer NOT NULL default '3',
role varchar(40) NOT NULL default '',
editall integer NOT NULL default '1',
timemodified integer NOT NULL default '0'
timemodified integer NOT NULL default '0',
timeaccess integer NOT NULL default '0'
);
CREATE INDEX prefix_user_teachers_courseuserid_idx ON prefix_user_teachers (course,userid);