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); } }