protected function load_courses() {
        global $DB;

        $courseids = [];
        foreach ($this->events as $event) {
            if ($course = $event->get_course()) {
                $id = $course->get('id');
                $courseids[$id] = true;
            }
        }

        if (empty($courseids)) {
            $this->courses = [];
            return;
        }

        list($idsql, $params) = $DB->get_in_or_equal(array_keys($courseids));
        $sql = "SELECT * FROM {course} WHERE id {$idsql}";

        $this->courses = $DB->get_records_sql($sql, $params);
    }