mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 16:13:28 +02:00
Site level block shows online teachers and students from all courses
bug 1683
This commit is contained in:
parent
4b544a3758
commit
2d90bdf022
1 changed files with 15 additions and 8 deletions
|
@ -45,6 +45,7 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||||
$this->content = '';
|
$this->content = '';
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->content = New object;
|
$this->content = New object;
|
||||||
$this->content->text = '';
|
$this->content->text = '';
|
||||||
|
@ -58,12 +59,18 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||||
$currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL;
|
$currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL;
|
||||||
|
|
||||||
$groupmembers = "";
|
$groupmembers = "";
|
||||||
$select = "";
|
$groupselect = "";
|
||||||
|
|
||||||
//Add this to the SQL to show only group users
|
//Add this to the SQL to show only group users
|
||||||
if ($currentgroup !== NULL) {
|
if ($currentgroup !== NULL) {
|
||||||
$groupmembers = ", {$CFG->prefix}groups_members gm ";
|
$groupmembers = ", {$CFG->prefix}groups_members gm ";
|
||||||
$select .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
$groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->course->category)) { // Site-level
|
||||||
|
$courseselect = '';
|
||||||
|
} else {
|
||||||
|
$courseselect = "AND s.course = '".$this->course->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$timefrom = time()-$timetoshowusers;
|
$timefrom = time()-$timetoshowusers;
|
||||||
|
@ -72,17 +79,17 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||||
FROM {$CFG->prefix}user u,
|
FROM {$CFG->prefix}user u,
|
||||||
{$CFG->prefix}user_students s
|
{$CFG->prefix}user_students s
|
||||||
$groupmembers
|
$groupmembers
|
||||||
WHERE u.id = s.userid and
|
WHERE u.id = s.userid $courseselect $groupselect
|
||||||
s.course = {$this->course->id} and
|
AND s.timeaccess > $timefrom
|
||||||
s.timeaccess > $timefrom $select ORDER BY s.timeaccess DESC");
|
ORDER BY s.timeaccess DESC");
|
||||||
|
|
||||||
$teachers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess
|
$teachers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess
|
||||||
FROM {$CFG->prefix}user u,
|
FROM {$CFG->prefix}user u,
|
||||||
{$CFG->prefix}user_teachers s
|
{$CFG->prefix}user_teachers s
|
||||||
$groupmembers
|
$groupmembers
|
||||||
WHERE u.id = s.userid and
|
WHERE u.id = s.userid $courseselect $groupselect
|
||||||
s.course = {$this->course->id} and
|
AND s.timeaccess > $timefrom
|
||||||
s.timeaccess > $timefrom $select ORDER BY s.timeaccess DESC");
|
ORDER BY s.timeaccess DESC");
|
||||||
|
|
||||||
if ($teachers || $students) {
|
if ($teachers || $students) {
|
||||||
if ($students) {
|
if ($students) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue