General developer forum

 
 
Picture of Hittesh Ahuja
Re: Show online users in different color
 

A quick script I came up with to show this: 

I have taken a dummy course id here and this lists the users who are online or not on that course.

SELECT u.firstname,u.lastname,e.enrol,ue.userid,e.courseid,ue.enrolid, IF(FROM_UNIXTIME(u.lastaccess) > (sysdate() - INTERVAL 5 MINUTE) ,'online','offline') AS 'status', DATE_FORMAT(FROM_UNIXTIME(u.lastaccess),'%d-%m-%Y %H:%i:%s') as 'lastaccess', sysdate() - INTERVAL 5 MINUTE AS '5minearlier', u.lastaccess from mdl5_user u join mdl5_user_enrolments ue on ue.userid = u.id JOIN mdl5_enrol e ON e.id = ue.enrolid where e.courseid = 4554 and u.deleted = 0 ORDER BY u.lastaccess DESC

You can traverese through all the courses the user has and then amend the script to use 'where courseid IN (1,2,3.....) 

 

Hope this helps

 
Average of ratings: -
Picture of ashwath venk
Re: Show online users in different color
 

Sorry for late reply my confusion is in which php page this script goes

 
Average of ratings: -
Picture of Hittesh Ahuja
Re: Show online users in different color
 

you would have to make your own block for this ..

 

for more info : http://docs.moodle.org/dev/Blocks

 
Average of ratings: -