MDL-42495 lesson Prevent coding error for invalid user
authorMichael Aherne <michael.aherne@strath.ac.uk>
Mon, 2 Dec 2013 10:36:39 +0000 (10:36 +0000)
committerMichael Aherne <michael.aherne@strath.ac.uk>
Mon, 2 Dec 2013 10:36:39 +0000 (10:36 +0000)
mod/lesson/essay.php

index c824a63..d829ad3 100644 (file)
@@ -268,23 +268,12 @@ switch ($mode) {
                 $ufields = user_picture::fields('u');
                 list($sort, $sortparams) = users_order_by_sql('u');
                 $params = array_merge($params, $sortparams);
-                if (!empty($cm->groupingid)) {
-                    $params["groupingid"] = $cm->groupingid;
-                    $sql = "SELECT DISTINCT $ufields
-                            FROM {lesson_attempts} a
-                                INNER JOIN {user} u ON u.id = a.userid
-                                INNER JOIN {groups_members} gm ON gm.userid = u.id
-                                INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid AND gg.groupingid = :groupingid
-                            WHERE a.lessonid = :lessonid
-                            ORDER BY $sort";
-                } else {
-                    $sql = "SELECT DISTINCT $ufields
-                            FROM {user} u,
-                                 {lesson_attempts} a
-                            WHERE a.lessonid = :lessonid and
-                                  u.id = a.userid
-                            ORDER BY $sort";
-                }
+                $sql = "SELECT DISTINCT $ufields
+                        FROM {user} u,
+                             {lesson_attempts} a
+                        WHERE a.lessonid = :lessonid and
+                              u.id = a.userid
+                        ORDER BY $sort";
                 if (!$users = $DB->get_records_sql($sql, $params)) {
                     $mode = 'none'; // not displaying anything
                     $lesson->add_message(get_string('noonehasanswered', 'lesson'));