Skip to content
Browse files

SQL fix:Much better performance in listing and counting all users of …

…courses with groups, plus warnings cleanup

 Patchsets
   arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-374 (partial)
   arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-375
  • Loading branch information...
1 parent 778f416 commit 6f454ff99a280487c395a9c7d4692bf73664acd1 martinlanghoff committed Nov 24, 2004
Showing with 13 additions and 6 deletions.
  1. +13 −6 course/lib.php
View
19 course/lib.php
@@ -255,11 +255,18 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
/// If using a group, only get users in that group.
if ($selectedgroup) {
$sql = 'SELECT u.id as id, u.firstname, u.lastname, u.lastaccess '.
- 'FROM '.$CFG->prefix.'user u,'.$CFG->prefix.'user_students us,'.$CFG->prefix.'groups_members gm, '.
- $CFG->prefix.'user_teachers ut '.
- 'WHERE us.course='.$course->id.' AND gm.groupid='.$selectedgroup.
- ' AND (gm.userid=us.userid OR gm.userid=ut.userid) AND gm.userid=u.id';
- $courseusers = get_records_sql($sql);
+ 'FROM '.$CFG->prefix.'user u '.
+ ' JOIN '.$CFG->prefix.'groups_members gm ON gm.userid=u.id '.
+ ' JOIN '.$CFG->prefix.'user_teachers ut ON gm.userid=ut.userid '.
+ 'WHERE ut.course='.$course->id.' AND gm.groupid='.$selectedgroup;
+ $courseusers = get_records_sql($sql);
+ // students
+ $sql = 'SELECT u.id as id, u.firstname, u.lastname, u.lastaccess '.
+ 'FROM '.$CFG->prefix.'user u '.
+ ' JOIN '.$CFG->prefix.'groups_members gm ON gm.userid=u.id '.
+ ' JOIN '.$CFG->prefix.'user_students us ON gm.userid=us.userid '.
+ 'WHERE us.course='.$course->id.' AND gm.groupid='.$selectedgroup;
+ $courseusers = array_merge($couseusers, get_records_sql($sql));
} else {
$courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname');
}
@@ -279,7 +286,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
if (isadmin()) {
if ($ccc = get_records("course", "", "", "fullname","id,fullname,category")) {
foreach ($ccc as $cc) {
- if ($cc->category) {
+ if (!empty($cc->category)) {
$courses["$cc->id"] = "$cc->fullname";
} else {
$courses["$cc->id"] = " $cc->fullname (Site)";

0 comments on commit 6f454ff

Please sign in to comment.
Something went wrong with that request. Please try again.