mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-40468 libraries: removed usages of get_related_contexts_string() in core
Also tidied up the functions by removing unused parameters.
This commit is contained in:
parent
b645284403
commit
4e829d48d1
10 changed files with 96 additions and 104 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue