Skip to content

Commit

Permalink
Merge branch 'MDL-75208' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jul 21, 2022
2 parents ad3ba9d + ca7890f commit c5e19c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2470,9 +2470,7 @@ function update_course($data, $editoroptions = NULL) {
function average_number_of_participants(bool $onlyactive = false, int $lastloginsince = null): float {
global $DB;

$params = [
'siteid' => SITEID,
];
$params = [];

$sql = "SELECT DISTINCT ue.userid, e.courseid
FROM {user_enrolments} ue
Expand All @@ -2483,8 +2481,7 @@ function average_number_of_participants(bool $onlyactive = false, int $lastlogin
$sql .= "JOIN {user} u ON u.id = ue.userid ";
}

$sql .= "WHERE e.courseid <> :siteid
AND c.visible = 1 ";
$sql .= "WHERE e.courseid <> " . SITEID . " AND c.visible = 1 ";

if ($onlyactive) {
$sql .= "AND ue.status = :active
Expand Down
8 changes: 4 additions & 4 deletions lib/enrollib.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ function enrol_get_my_courses($fields = null, $sort = null, $limit = 0, $coursei
$orderby = "ORDER BY $sort";
}

$wheres = array("c.id <> :siteid");
$params = array('siteid'=>SITEID);
$wheres = ['c.id <> ' . SITEID];
$params = [];

if (isset($USER->loginascontext) and $USER->loginascontext->contextlevel == CONTEXT_COURSE) {
// list _only_ this course - anything else is asking for trouble...
Expand Down Expand Up @@ -1093,7 +1093,7 @@ function enrol_get_all_users_courses($userid, $onlyactive = false, $fields = nul
$orderby = "ORDER BY $sort";
}

$params = array('siteid'=>SITEID);
$params = [];

if ($onlyactive) {
$subwhere = "WHERE ue.status = :active AND e.status = :enabled AND ue.timestart < :now1 AND (ue.timeend = 0 OR ue.timeend > :now2)";
Expand All @@ -1119,7 +1119,7 @@ function enrol_get_all_users_courses($userid, $onlyactive = false, $fields = nul
$subwhere
) en ON (en.courseid = c.id)
$ccjoin
WHERE c.id <> :siteid
WHERE c.id <> " . SITEID . "
$orderby";
$params['userid'] = $userid;

Expand Down

0 comments on commit c5e19c2

Please sign in to comment.