MDL-85036 completion: Properly initialize cm_info for user completion
This commit is contained in:
@@ -53,7 +53,7 @@ class completion_info_exporter extends \core\external\exporter {
|
||||
*/
|
||||
public function __construct(object $course, object $cm, int $userid, array $related = []) {
|
||||
$this->course = $course;
|
||||
$this->cminfo = \cm_info::create($cm);
|
||||
$this->cminfo = \cm_info::create($cm, $userid);
|
||||
$this->userid = $userid;
|
||||
parent::__construct([], $related);
|
||||
}
|
||||
|
||||
@@ -1412,8 +1412,8 @@ class cm_info implements IteratorAggregate {
|
||||
if (!$cm) {
|
||||
return null;
|
||||
}
|
||||
// If it is already a cm_info object, just return it.
|
||||
if ($cm instanceof cm_info) {
|
||||
// If it is already a cm_info object with the right user, just return it.
|
||||
if (($cm instanceof cm_info) && ($cm->get_modinfo()->userid == $userid)) {
|
||||
return $cm;
|
||||
}
|
||||
// Otherwise load modinfo.
|
||||
|
||||
Reference in New Issue
Block a user