General developer forum

 
 
Picture of ashwath venk
Show online users in different color
 

Hi

I have created frontpage after login which shows course along with teachers and students below the courses. Is it possible to show if the teacher or student if online in different color so that it will be easy to check in one go.

Thanks in advance

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

Sorry if i didnt get your question right, but isnt CSS your answer. But also doesnt the 'online users' block show online users ONLY. So why apply color to it when you dont have a 'otherwise' ?

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

Thanks for your interest. Consider the situation you have 10 courses each with 5 students, online users block only gives list who are online but not according to the courses, you have to check for students enrolled in each course against online users block to find who is not attending. If the students list below the course itself shows who is online and who not it reduces error and save time.

How to insert online users block into the course list page?

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

Well there is no easy way to insert online users block on the page below all the courses. 

Like you said, to see who is online in each course, you would have to go to the relevant course and check their online users block. 

One way to achieve this is to create your own block plugin and add it below the course list .

the idea behind this would be to JOIN 2 tables here, the user_enrolments table and the user table and then search on either the lastaccess or lastlogin ( something like WHERE lastaccess < 5 min) .

Is that what you are after or am i heading in the wrong direction.

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

What you are explaining is perfect and exactly the same i am planning, but not getting which two tables or scripts to be merged.

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

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
Group Testers

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

 

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

 
Average of ratings: -