From ecc8e0a9ef05a147a30fa885c5c73342f7969c5e Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Tue, 16 Jun 2020 19:23:24 +1200 Subject: [PATCH] Fix #473 - add cmid to structure class. --- classes/structure.php | 6 ++++++ tests/generator/lib.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/structure.php b/classes/structure.php index 022bda6..d45b58f 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -42,6 +42,9 @@ class mod_attendance_structure { /** @var stdclass course module record */ public $cm; + /** @var int cmid - needed for calendar internal tests (see Issue #473) */ + public $cmid; + /** @var stdclass course record */ public $course; @@ -125,6 +128,9 @@ class mod_attendance_structure { } } $this->cm = $cm; + if (empty($this->cmid)) { + $this->cmid = $cm->id; + } $this->course = $course; if (is_null($context)) { $this->context = context_module::instance($this->cm->id); diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 858759e..674753d 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -65,7 +65,7 @@ class mod_attendance_generator extends testing_module_generator { $att = parent::create_instance($record, (array)$options); $cm = $DB->get_record('course_modules', array('id' => $att->cmid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); - unset($att->cmid); + return new mod_attendance_structure($att, $cm, $course); } }