MDL-85036 completion: Properly initialize cm_info for user completion

This commit is contained in:
James C
2025-11-04 21:02:17 +13:00
parent 543bf96cb7
commit 92b2ccc7aa
2 changed files with 3 additions and 3 deletions
@@ -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);
}
+2 -2
View File
@@ -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.