Skip to content

Commit

Permalink
Showing 10 changed files with 93 additions and 101 deletions.
14 changes: 9 additions & 5 deletions grade/import/lib.php
Original file line number Diff line number Diff line change
@@ -161,12 +161,16 @@ function grade_import_commit($courseid, $importcode, $importfeedback=true, $verb
*/
function get_unenrolled_users_in_import($importcode, $courseid) {
global $CFG, $DB;
$relatedctxcondition = get_related_contexts_string(context_course::instance($courseid));

//users with a gradeable role
$coursecontext = context_course::instance($courseid);

// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

// Users with a gradeable role.
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');

//enrolled users
// Enrolled users.
$context = context_course::instance($courseid);
list($enrolledsql, $enrolledparams) = get_enrolled_sql($context);
list($sort, $sortparams) = users_order_by_sql('u');
@@ -183,11 +187,11 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
LEFT JOIN ($enrolledsql) je
ON je.id = u.id
LEFT JOIN {role_assignments} ra
ON (giv.userid = ra.userid AND ra.roleid $gradebookrolessql AND ra.contextid $relatedctxcondition)
ON (giv.userid = ra.userid AND ra.roleid $gradebookrolessql AND ra.contextid $relatedctxsql)
WHERE giv.importcode = :importcode
AND (ra.id IS NULL OR je.id IS NULL)
ORDER BY gradeidnumber, $sort";
$params = array_merge($gradebookrolesparams, $enrolledparams, $sortparams);
$params = array_merge($gradebookrolesparams, $enrolledparams, $sortparams, $relatedctxparams);
$params['importcode'] = $importcode;

return $DB->get_records_sql($sql, $params);
23 changes: 10 additions & 13 deletions grade/lib.php
Original file line number Diff line number Diff line change
@@ -138,18 +138,17 @@ public function init() {
export_verify_grades($this->course->id);
$course_item = grade_item::fetch_course_item($this->course->id);
if ($course_item->needsupdate) {
// can not calculate all final grades - sorry
// Can not calculate all final grades - sorry.
return false;
}

$coursecontext = context_course::instance($this->course->id);
$relatedcontexts = get_related_contexts_string($coursecontext);

list($gradebookroles_sql, $params) =
$DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');
list($gradebookroles_sql, $params) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext, '', 0, $this->onlyactive);

$params = array_merge($params, $enrolledparams);
$params = array_merge($params, $enrolledparams, $relatedctxparams);

if ($this->groupid) {
$groupsql = "INNER JOIN {groups_members} gm ON gm.userid = u.id";
@@ -162,7 +161,7 @@ public function init() {
}

if (empty($this->sortfield1)) {
// we must do some sorting even if not specified
// We must do some sorting even if not specified.
$ofields = ", u.id AS usrt";
$order = "usrt ASC";

@@ -174,8 +173,8 @@ public function init() {
$order .= ", usrt2 $this->sortorder2";
}
if ($this->sortfield1 != 'id' and $this->sortfield2 != 'id') {
// user order MUST be the same in both queries,
// must include the only unique user->id if not already present
// User order MUST be the same in both queries,
// must include the only unique user->id if not already present.
$ofields .= ", u.id AS usrt";
$order .= ", usrt ASC";
}
@@ -199,7 +198,6 @@ public function init() {
}
}

// $params contents: gradebookroles and groupid (for $groupwheresql)
$users_sql = "SELECT $userfields $ofields
FROM {user} u
JOIN ($enrolledsql) je ON je.id = u.id
@@ -208,7 +206,7 @@ public function init() {
SELECT DISTINCT ra.userid
FROM {role_assignments} ra
WHERE ra.roleid $gradebookroles_sql
AND ra.contextid $relatedcontexts
AND ra.contextid $relatedctxsql
) rainner ON rainner.userid = u.id
WHERE u.deleted = 0
$groupwheresql
@@ -226,7 +224,6 @@ public function init() {
$itemids = array_keys($this->grade_items);
list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items');
$params = array_merge($params, $grades_params);
// $params contents: gradebookroles, enrolledparams, groupid (for $groupwheresql) and itemids

$grades_sql = "SELECT g.* $ofields
FROM {grade_grades} g
@@ -237,7 +234,7 @@ public function init() {
SELECT DISTINCT ra.userid
FROM {role_assignments} ra
WHERE ra.roleid $gradebookroles_sql
AND ra.contextid $relatedcontexts
AND ra.contextid $relatedctxsql
) rainner ON rainner.userid = u.id
WHERE u.deleted = 0
AND g.itemid $itemidsql
@@ -418,7 +415,7 @@ function print_graded_users_selector($course, $actionpage, $userid=0, $groupid=0
}

function grade_get_graded_users_select($report, $course, $userid, $groupid, $includeall) {
global $USER;
global $USER, $CFG;

if (is_null($userid)) {
$userid = $USER->id;
62 changes: 25 additions & 37 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
@@ -394,24 +394,25 @@ public function load_users() {
return;
}

//limit to users with a gradeable role
// Limit to users with a gradeable role.
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');

//limit to users with an active enrollment
// Limit to users with an active enrollment.
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context);

//fields we need from the user table
// Fields we need from the user table.
$userfields = user_picture::fields('u', get_extra_user_fields($this->context));

$sortjoin = $sort = $params = null;
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

//if the user has clicked one of the sort asc/desc arrows
// If the user has clicked one of the sort asc/desc arrows.
if (is_numeric($this->sortitemid)) {
$params = array_merge(array('gitemid'=>$this->sortitemid), $gradebookrolesparams, $this->groupwheresql_params, $enrolledparams);
$params = array_merge(array('gitemid' => $this->sortitemid), $gradebookrolesparams, $this->groupwheresql_params, $enrolledparams,
$relatedctxparams);

$sortjoin = "LEFT JOIN {grade_grades} g ON g.userid = u.id AND g.itemid = $this->sortitemid";
$sort = "g.finalgrade $this->sortorder";

} else {
$sortjoin = '';
switch($this->sortitemid) {
@@ -430,7 +431,7 @@ public function load_users() {
break;
}

$params = array_merge($gradebookrolesparams, $this->groupwheresql_params, $enrolledparams);
$params = array_merge($gradebookrolesparams, $this->groupwheresql_params, $enrolledparams, $relatedctxparams);
}

$sql = "SELECT $userfields
@@ -442,12 +443,11 @@ public function load_users() {
SELECT DISTINCT ra.userid
FROM {role_assignments} ra
WHERE ra.roleid IN ($this->gradebookroles)
AND ra.contextid " . get_related_contexts_string($this->context) . "
AND ra.contextid $relatedctxsql
) rainner ON rainner.userid = u.id
AND u.deleted = 0
$this->groupwheresql
ORDER BY $sort";

$studentsperpage = $this->get_students_per_page();
$this->users = $DB->get_records_sql($sql, $params, $studentsperpage * $this->page, $studentsperpage);

@@ -1273,56 +1273,46 @@ public function get_right_range_row($rows=array()) {
* @return array Array of rows for the right part of the report
*/
public function get_right_avg_row($rows=array(), $grouponly=false) {
global $CFG, $USER, $DB, $OUTPUT;
global $USER, $DB, $OUTPUT;

if (!$this->canviewhidden) {
// totals might be affected by hiding, if user can not see hidden grades the aggregations might be altered
// better not show them at all if user can not see all hidden grades
// Totals might be affected by hiding, if user can not see hidden grades the aggregations might be altered
// better not show them at all if user can not see all hidden grades.
return $rows;
}

$showaverages = $this->get_pref('showaverages');
$showaveragesgroup = $this->currentgroup && $showaverages;

$averagesdisplaytype = $this->get_pref('averagesdisplaytype');
$averagesdecimalpoints = $this->get_pref('averagesdecimalpoints');
$meanselection = $this->get_pref('meanselection');
$shownumberofgrades = $this->get_pref('shownumberofgrades');

$avghtml = '';
$avgcssclass = 'avg';

if ($grouponly) {
$straverage = get_string('groupavg', 'grades');
$showaverages = $this->currentgroup && $this->get_pref('showaverages');
$groupsql = $this->groupsql;
$groupwheresql = $this->groupwheresql;
$groupwheresqlparams = $this->groupwheresql_params;
$avgcssclass = 'groupavg';
} else {
$straverage = get_string('overallaverage', 'grades');
$showaverages = $this->get_pref('showaverages');
$groupsql = "";
$groupwheresql = "";
$groupwheresqlparams = array();
}

if ($shownumberofgrades) {
$straverage .= ' (' . get_string('submissions', 'grades') . ') ';
}
if ($showaverages) {
$totalcount = $this->get_numusers($grouponly);

$totalcount = $this->get_numusers($grouponly);
// Limit to users with a gradeable role.
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');

//limit to users with a gradeable role
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
// Limit to users with an active enrollment.
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context);

//limit to users with an active enrollment
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context);
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

if ($showaverages) {
$params = array_merge(array('courseid'=>$this->courseid), $gradebookrolesparams, $enrolledparams, $groupwheresqlparams);
$params = array_merge(array('courseid' => $this->courseid), $gradebookrolesparams, $enrolledparams, $groupwheresqlparams, $relatedctxparams);

// find sums of all grade items in course
// Find sums of all grade items in course.
$sql = "SELECT g.itemid, SUM(g.finalgrade) AS sum
FROM {grade_items} gi
JOIN {grade_grades} g ON g.itemid = gi.id
@@ -1332,7 +1322,7 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
SELECT DISTINCT ra.userid
FROM {role_assignments} ra
WHERE ra.roleid $gradebookrolessql
AND ra.contextid " . get_related_contexts_string($this->context) . "
AND ra.contextid $relatedctxsql
) rainner ON rainner.userid = u.id
$groupsql
WHERE gi.courseid = :courseid
@@ -1361,7 +1351,7 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
$groupsql
WHERE gi.courseid = :courseid
AND ra.roleid $gradebookrolessql
AND ra.contextid ".get_related_contexts_string($this->context)."
AND ra.contextid $relatedctxsql
AND u.deleted = 0
AND g.id IS NULL
$groupwheresql
@@ -1399,8 +1389,6 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
$meancount = $totalcount;
}

$decimalpoints = $item->get_decimals();

// Determine which display type to use for this average
if ($USER->gradeediting[$this->courseid]) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
13 changes: 8 additions & 5 deletions grade/report/lib.php
Original file line number Diff line number Diff line change
@@ -271,18 +271,21 @@ public function get_lang_string($strcode, $section=null) {
* @return int Count of users
*/
public function get_numusers($groups=true) {
global $CFG, $DB;
global $DB;

$groupsql = "";
$groupwheresql = "";

//limit to users with a gradeable role
// Limit to users with a gradeable role.
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');

//limit to users with an active enrollment
// Limit to users with an active enrollment.
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context);

$params = array_merge($gradebookrolesparams, $enrolledparams);
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

$params = array_merge($gradebookrolesparams, $enrolledparams, $relatedctxparams);

if ($groups) {
$groupsql = $this->groupsql;
@@ -300,7 +303,7 @@ public function get_numusers($groups=true) {
WHERE ra.roleid $gradebookrolessql
AND u.deleted = 0
$groupwheresql
AND ra.contextid ".get_related_contexts_string($this->context);
AND ra.contextid $relatedctxsql";
return $DB->count_records_sql($countsql, $params);
}

31 changes: 10 additions & 21 deletions grade/report/user/lib.php
Original file line number Diff line number Diff line change
@@ -611,42 +611,34 @@ function process_action($target, $action) {

/**
* Builds the grade item averages.
*
*/
function calculate_averages() {
global $USER, $DB;

if ($this->showaverage) {
// this settings are actually grader report settings (not user report)
// This settings are actually grader report settings (not user report)
// however we're using them as having two separate but identical settings the
// user would have to keep in sync would be annoying
// user would have to keep in sync would be annoying.
$averagesdisplaytype = $this->get_pref('averagesdisplaytype');
$averagesdecimalpoints = $this->get_pref('averagesdecimalpoints');
$meanselection = $this->get_pref('meanselection');
$shownumberofgrades = $this->get_pref('shownumberofgrades');

$avghtml = '';
$avgcssclass = 'avg';

$straverage = get_string('overallaverage', 'grades');

$groupsql = $this->groupsql;
$groupwheresql = $this->groupwheresql;
//$groupwheresqlparams = ;

if ($shownumberofgrades) {
$straverage .= ' (' . get_string('submissions', 'grades') . ') ';
}

$totalcount = $this->get_numusers(false);

//limit to users with a gradeable role ie students
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

// Limit to users with a gradeable role ie students.
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');

//limit to users with an active enrolment
// Limit to users with an active enrolment.
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context);

$params = array_merge($this->groupwheresql_params, $gradebookrolesparams, $enrolledparams);
$params = array_merge($this->groupwheresql_params, $gradebookrolesparams, $enrolledparams, $relatedctxparams);
$params['courseid'] = $this->courseid;

// find sums of all grade items in course
@@ -659,7 +651,7 @@ function calculate_averages() {
SELECT DISTINCT ra.userid
FROM {role_assignments} ra
WHERE ra.roleid $gradebookrolessql
AND ra.contextid " . get_related_contexts_string($this->context) . "
AND ra.contextid $relatedctxsql
) rainner ON rainner.userid = u.id
$groupsql
WHERE gi.courseid = :courseid
@@ -690,7 +682,7 @@ function calculate_averages() {
SELECT DISTINCT ra.userid
FROM {role_assignments} ra
WHERE ra.roleid $gradebookrolessql
AND ra.contextid " . get_related_contexts_string($this->context) . "
AND ra.contextid $relatedctxsql
) rainner ON rainner.userid = u.id
LEFT JOIN {grade_grades} gg
ON (gg.itemid = gi.id AND gg.userid = u.id AND gg.finalgrade IS NOT NULL AND gg.hidden = 0)
@@ -731,8 +723,6 @@ function calculate_averages() {
$mean_count = $totalcount;
}

$decimalpoints = $item->get_decimals();

// Determine which display type to use for this average
if (!empty($USER->gradeediting) && $USER->gradeediting[$this->courseid]) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
@@ -747,7 +737,6 @@ function calculate_averages() {
// Override grade_item setting if a display preference (not inherit) was set for the averages
if ($averagesdecimalpoints == GRADE_REPORT_PREFERENCE_INHERIT) {
$decimalpoints = $item->get_decimals();

} else {
$decimalpoints = $averagesdecimalpoints;
}
19 changes: 11 additions & 8 deletions group/lib.php
Original file line number Diff line number Diff line change
@@ -684,16 +684,16 @@ function groups_get_potential_members($courseid, $roleid = null, $cohortid = nul

$context = context_course::instance($courseid);

// we are looking for all users with this role assigned in this context or higher
$listofcontexts = get_related_contexts_string($context);

list($esql, $params) = get_enrolled_sql($context);

if ($roleid) {
$params['roleid'] = $roleid;
// We are looking for all users with this role assigned in this context or higher.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

$params = array_merge($params, $relatedctxparams, array('roleid' => $roleid));
$where = "WHERE u.id IN (SELECT userid
FROM {role_assignments}
WHERE roleid = :roleid AND contextid $listofcontexts)";
WHERE roleid = :roleid AND contextid $relatedctxsql)";
} else {
$where = "";
}
@@ -812,12 +812,15 @@ function groups_unassign_grouping($groupingid, $groupid, $invalidatecache = true
*/
function groups_get_members_by_role($groupid, $courseid, $fields='u.*',
$sort=null, $extrawheretest='', $whereorsortparams=array()) {
global $CFG, $DB;
global $DB;

// Retrieve information about all users and their roles on the course or
// parent ('related') contexts
$context = context_course::instance($courseid);

// We are looking for all users with this role assigned in this context or higher.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

if ($extrawheretest) {
$extrawheretest = ' AND ' . $extrawheretest;
}
@@ -830,12 +833,12 @@ function groups_get_members_by_role($groupid, $courseid, $fields='u.*',
$sql = "SELECT r.id AS roleid, u.id AS userid, $fields
FROM {groups_members} gm
JOIN {user} u ON u.id = gm.userid
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid ".get_related_contexts_string($context).")
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid $relatedctxsql)
LEFT JOIN {role} r ON r.id = ra.roleid
WHERE gm.groupid=:mgroupid
".$extrawheretest."
ORDER BY r.sortorder, $sort";
$whereorsortparams['mgroupid'] = $groupid;
$whereorsortparams = array_merge($whereorsortparams, $relatedctxparams, array('mgroupid' => $groupid));
$rs = $DB->get_recordset_sql($sql, $whereorsortparams);

return groups_calculate_role_people($rs, $context);
7 changes: 5 additions & 2 deletions lib/datalib.php
Original file line number Diff line number Diff line change
@@ -177,14 +177,17 @@ function search_users($courseid, $groupid, $searchtext, $sort='', array $excepti

} else {
$context = context_course::instance($courseid);
$contextlists = get_related_contexts_string($context);

// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

$sql = "SELECT u.id, u.firstname, u.lastname, u.email
FROM {user} u
JOIN {role_assignments} ra ON ra.userid = u.id
WHERE $select AND ra.contextid $contextlists
WHERE $select AND ra.contextid $relatedctxsql
$except
$order";
$params = array_merge($params, $relatedctxparams);
return $DB->get_records_sql($sql, $params);
}
}
8 changes: 5 additions & 3 deletions report/participation/index.php
Original file line number Diff line number Diff line change
@@ -214,14 +214,16 @@
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action');
$actionsql = "action $actionsql";

$relatedcontexts = get_related_contexts_string($context);
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

$sql = "SELECT ra.userid, u.firstname, u.lastname, u.idnumber, l.actioncount AS count
FROM (SELECT * FROM {role_assignments} WHERE contextid $relatedcontexts AND roleid = :roleid ) ra
FROM (SELECT * FROM {role_assignments} WHERE contextid $relatedctxsql AND roleid = :roleid ) ra
JOIN {user} u ON u.id = ra.userid
LEFT JOIN (
SELECT userid, COUNT(action) AS actioncount FROM {log} WHERE cmid = :instanceid AND time > :timefrom AND $actionsql GROUP BY userid
) l ON (l.userid = ra.userid)";
$params = array_merge($params, $relatedctxparams);
$params['roleid'] = $roleid;
$params['instanceid'] = $instanceid;
$params['timefrom'] = $timefrom;
@@ -239,7 +241,7 @@
$countsql = "SELECT COUNT(DISTINCT(ra.userid))
FROM {role_assignments} ra
JOIN {user} u ON u.id = ra.userid
WHERE ra.contextid $relatedcontexts AND ra.roleid = :roleid";
WHERE ra.contextid $relatedctxsql AND ra.roleid = :roleid";

$totalcount = $DB->count_records_sql($countsql, $params);

10 changes: 5 additions & 5 deletions user/index.php
Original file line number Diff line number Diff line change
@@ -370,9 +370,6 @@
));
$table->setup();

// we are looking for all users with this role assigned in this context or higher
$contextlist = get_related_contexts_string($context);

list($esql, $params) = get_enrolled_sql($context, NULL, $currentgroup, true);
$joins = array("FROM {user} u");
$wheres = array();
@@ -410,8 +407,11 @@

// limit list to users with some role only
if ($roleid) {
$wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $contextlist)";
$params['roleid'] = $roleid;
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

$wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
$params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
}

$from = implode("\n", $joins);
7 changes: 5 additions & 2 deletions user/selector/lib.php
Original file line number Diff line number Diff line change
@@ -781,6 +781,9 @@ public function find_users($search) {
$roleparams = array();
}

// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');

// Get the search condition.
list($searchcondition, $searchparams) = $this->search_sql($search, 'u');

@@ -794,7 +797,7 @@ public function find_users($search) {
WHERE igm.userid = u.id AND ig.courseid = :courseid) AS numgroups";
$sql = " FROM {user} u
JOIN ($enrolsql) e ON e.id = u.id
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid " . get_related_contexts_string($context) . " AND ra.roleid $roleids)
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid $relatedctxsql AND ra.roleid $roleids)
LEFT JOIN {role} r ON r.id = ra.roleid
LEFT JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)
WHERE u.deleted = 0
@@ -804,7 +807,7 @@ public function find_users($search) {
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
$orderby = ' ORDER BY ' . $sort;

$params = array_merge($searchparams, $roleparams, $enrolparams);
$params = array_merge($searchparams, $roleparams, $enrolparams, $relatedctxparams);
$params['courseid'] = $this->courseid;
$params['groupid'] = $this->groupid;

0 comments on commit 4e829d4

Please sign in to comment.