检查 Moodle 用户是否在线 [英] Check if a Moodle user is online

查看:59
本文介绍了检查 Moodle 用户是否在线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道用户是否在 Moodle 在线,有一个 Moodle 块 对于它,但实际上它只是检查用户在过去 X 分钟内是否在 Moodle 上进行了活动,但在我的情况下这没有用.反正有知道的吗?

I need to know if a user is on-line at Moodle, there is a Moodle block for it, but actually it just check if the user had an activity on Moodle in the last X minutes, but in my case that is not useful. There is anyway to know it?

推荐答案

正如其他回答者所说,无法查看用户当前是否在线.正如您提到的,在线用户块检查 mdl_user.lastaccess 的值.这可能是最好的选择,但即便如此,它也取决于用户访问或刷新页面.例如,他们可能正在阅读一个页面 10 分钟,因此从技术上讲,他们仍然在线,但不会显示他们在线.反之亦然,他们可以查看页面并立即关闭它,因此它会显示他们在线但技术上不在线.

As the other answerers say, it isn't possible to see if a user is currently online. As you mentioned, the online users block checks the value of mdl_user.lastaccess. It's probably the best option but even then it depends on the user accessing or refreshing a page. They could be reading a page for 10 minutes for example, so technically still online but it won't show that they are online. Or vice versa, they could have looked at a page and immediately closed it, so it will show they are online but technically not.

同样以我的经验,很多用户并没有退出 Moodle,他们只是关闭了页面.因此,这不是查看他们当前是否已登录的可靠方法.

Also in my experience, a lot of user's don't log out of Moodle, they just close the page. So its not a reliable way to see if they are currently logged in or not.

作为参考,mdl_user.lastaccess按以下顺序更新:

For reference, mdl_user.lastaccess is updated by the following sequence:

转到 index.php 或任何使用 require_login() 的页面,这几乎是 Moodle 中的大部分页面.

Going to index.php or any page that uses require_login() which is pretty much most of the pages in Moodle.

这将调用 user_accesstime_log()

如果 mdl_user.lastaccess 时间在过去 60 秒内没有更新(由 LASTACCESS_UPDATE_SECS 设置),则 mdl_user.lastaccess用当前的 time()

If the mdl_user.lastaccess time hasn't been updated within the last 60 seconds (set by LASTACCESS_UPDATE_SECS) then the mdl_user.lastaccess is updated with the current time()

这篇关于检查 Moodle 用户是否在线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆