diff --git a/mnet/service/enrol/locallib.php b/mnet/service/enrol/locallib.php index f5adbfc5342f7..b0c260a4c606a 100644 --- a/mnet/service/enrol/locallib.php +++ b/mnet/service/enrol/locallib.php @@ -334,11 +334,12 @@ public function req_course_enrolments($mnethostid, $remotecourseid) { // prune stale enrolment records if (empty($list)) { - $DB->delete_records('mnetservice_enrol_enrolments', array('hostid'=>$mnethostid)); + $DB->delete_records('mnetservice_enrol_enrolments', array('hostid'=>$mnethostid, 'remotecourseid'=>$remotecourseid)); } else { list($isql, $params) = $DB->get_in_or_equal(array_keys($list), SQL_PARAMS_NAMED, 'param0000', false); $params['hostid'] = $mnethostid; - $select = "hostid = :hostid AND id $isql"; + $params['remotecourseid'] = $remotecourseid; + $select = "hostid = :hostid AND remotecourseid = :remotecourseid AND id $isql"; $DB->delete_records_select('mnetservice_enrol_enrolments', $select, $params); }