Get longtimenosee students according to their course access (not site access)

This commit is contained in:
moodler
2003-10-27 14:01:29 +00:00
parent 29b25b0498
commit 937ae59c8e
2 changed files with 8 additions and 12 deletions
+4 -4
View File
@@ -54,10 +54,10 @@
if ($CFG->longtimenosee) { // value in days
$longtime = $timenow - ($CFG->longtimenosee * 3600 * 24);
if ($users = get_users_longtimenosee($longtime)) {
foreach ($users as $user) {
if (unenrol_student($user->id)) {
echo "Deleted student enrolment for $user->firstname $user->lastname ($user->id)\n";
if ($students = get_users_longtimenosee($longtime)) {
foreach ($students as $student) {
if (unenrol_student($student->userid, $student->course)) {
echo "Deleted student enrolment for user $student->userid from course $student->course\n";
}
}
}
+4 -8
View File
@@ -1364,14 +1364,10 @@ function get_users_unconfirmed($cutofftime=2000000000) {
*/
function get_users_longtimenosee($cutofftime) {
global $CFG;
$db->debug = true;
return get_records_sql("SELECT DISTINCT u.*
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_students s
WHERE u.lastaccess > '0'
AND u.lastaccess < '$cutofftime'
AND u.id = s.userid ");
return get_records_sql("SELECT DISTINCT *
FROM {$CFG->prefix}user_students
WHERE timeaccess > '0'
AND timeaccess < '$cutofftime' ");
}