Browse Source

Fix #473 - add cmid to structure class.

nwp90-nwp90-allsessionsreport
Dan Marsden 5 years ago
parent
commit
ecc8e0a9ef
  1. 6
      classes/structure.php
  2. 2
      tests/generator/lib.php

6
classes/structure.php

@ -42,6 +42,9 @@ class mod_attendance_structure {
/** @var stdclass course module record */ /** @var stdclass course module record */
public $cm; public $cm;
/** @var int cmid - needed for calendar internal tests (see Issue #473) */
public $cmid;
/** @var stdclass course record */ /** @var stdclass course record */
public $course; public $course;
@ -125,6 +128,9 @@ class mod_attendance_structure {
} }
} }
$this->cm = $cm; $this->cm = $cm;
if (empty($this->cmid)) {
$this->cmid = $cm->id;
}
$this->course = $course; $this->course = $course;
if (is_null($context)) { if (is_null($context)) {
$this->context = context_module::instance($this->cm->id); $this->context = context_module::instance($this->cm->id);

2
tests/generator/lib.php

@ -65,7 +65,7 @@ class mod_attendance_generator extends testing_module_generator {
$att = parent::create_instance($record, (array)$options); $att = parent::create_instance($record, (array)$options);
$cm = $DB->get_record('course_modules', array('id' => $att->cmid), '*', MUST_EXIST); $cm = $DB->get_record('course_modules', array('id' => $att->cmid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
unset($att->cmid);
return new mod_attendance_structure($att, $cm, $course); return new mod_attendance_structure($att, $cm, $course);
} }
} }

Loading…
Cancel
Save