Get longtimenosee students according to their course access (not site access)
This commit is contained in:
+4
-4
@@ -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
@@ -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' ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user