Permalink
Browse files

Merge branch 'MDL-26371_distinct_text_m19' of git://github.com/stronk…

…7/moodle into MOODLE_19_STABLE
  • Loading branch information...
2 parents d7ef29d + 185f71c commit 05d38f44cc618480368c1f99c19d972a15abe11c @skodak skodak committed Feb 14, 2011
Showing with 24 additions and 18 deletions.
  1. +4 −4 admin/report/security/lib.php
  2. +10 −7 mod/lesson/essay.php
  3. +10 −7 mod/lesson/report.php
@@ -1050,8 +1050,7 @@ function report_security_check_riskadmin($detailed=false) {
AND (sc.path = c.path OR sc.path LIKE ".sql_concat('c.path', "'/%'")." OR c.path LIKE ".sql_concat('sc.path', "'/%'").")
AND u.id = ra.userid AND u.deleted = 0
AND ra.contextid = sc.id AND ra.roleid = rc.roleid AND ra.contextid <> ".SYSCONTEXTID."
- GROUP BY u.id, u.firstname, u.lastname, u.picture, u.imagealt, u.email, ra.contextid, ra.roleid
- ORDER BY u.lastname, u.firstname";
+ GROUP BY u.id, u.firstname, u.lastname, u.picture, u.imagealt, u.email, ra.contextid, ra.roleid";
$unsupcount = count_records_sql("SELECT COUNT('x') FROM ($sqlunsup) unsup");
@@ -1077,6 +1076,7 @@ function report_security_check_riskadmin($detailed=false) {
$result->info = get_string('check_riskadmin_warning', 'report_security', $a);
if ($detailed) {
+ $sqlunsup .= " ORDER BY u.lastname, u.firstname";
$rs = get_recordset_sql($sqlunsup);
$users = array();
while ($user = rs_fetch_next_record($rs)) {
@@ -1113,13 +1113,13 @@ function report_security_check_riskbackup($detailed=false) {
$syscontext = get_context_instance(CONTEXT_SYSTEM);
$systemroles = get_records_sql(
- "SELECT DISTINCT r.*
+ "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder
FROM {$CFG->prefix}role r
JOIN {$CFG->prefix}role_capabilities rc ON rc.roleid = r.id
WHERE rc.capability = 'moodle/backup:userinfo' AND rc.contextid = $syscontext->id AND rc.permission = ".CAP_ALLOW."");
$overriddenroles = get_records_sql(
- "SELECT DISTINCT r.*, rc.contextid
+ "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder, rc.contextid
FROM {$CFG->prefix}role r
JOIN {$CFG->prefix}role_capabilities rc ON rc.roleid = r.id
WHERE rc.capability = 'moodle/backup:userinfo' AND rc.contextid <> $syscontext->id AND rc.permission = ".CAP_ALLOW."");
View
@@ -31,12 +31,15 @@
if ($essayattempts = get_records_select('lesson_attempts', 'pageid IN('.implode(',', array_keys($pages)).')')) {
// Get all the users who have taken this lesson, order by their last name
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
- $sql = "SELECT DISTINCT u.*
- FROM {$CFG->prefix}lesson_attempts a
- INNER JOIN {$CFG->prefix}user u ON u.id = a.userid
- INNER JOIN {$CFG->prefix}groups_members gm ON gm.userid = u.id
- INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = {$cm->groupingid}
- WHERE a.lessonid = '$lesson->id'
+ $sql = "SELECT u.*
+ FROM {$CFG->prefix}user u
+ JOIN (
+ SELECT DISTINCT u.id
+ FROM {$CFG->prefix}lesson_attempts a
+ JOIN {$CFG->prefix}user u ON u.id = a.userid
+ JOIN {$CFG->prefix}groups_members gm ON gm.userid = u.id
+ JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = {$cm->groupingid}
+ WHERE a.lessonid = '$lesson->id') ui ON u.id = ui.id
ORDER BY u.lastname";
} else {
$sql = "SELECT u.*
@@ -367,4 +370,4 @@
}
print_footer($course);
-?>
+?>
View
@@ -17,14 +17,17 @@
$nothingtodisplay = false;
list($cm, $course, $lesson) = lesson_get_basics($id);
-
+
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
- $sql = "SELECT DISTINCT u.*
- FROM {$CFG->prefix}lesson_attempts a
- INNER JOIN {$CFG->prefix}user u ON u.id = a.userid
- INNER JOIN {$CFG->prefix}groups_members gm ON gm.userid = u.id
- INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = {$cm->groupingid}
- WHERE a.lessonid = '$lesson->id'
+ $sql = "SELECT u.*
+ FROM {$CFG->prefix}user u
+ JOIN (
+ SELECT DISTINCT u.id
+ FROM {$CFG->prefix}lesson_attempts a
+ JOIN {$CFG->prefix}user u ON u.id = a.userid
+ JOIN {$CFG->prefix}groups_members gm ON gm.userid = u.id
+ JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = {$cm->groupingid}
+ WHERE a.lessonid = '$lesson->id') ui ON u.id = ui.id
ORDER BY u.lastname";
} else {
$sql = "SELECT u.*

0 comments on commit 05d38f4

Please sign in to comment.