public function get_instance_context(int $instanceid = 0) : \context {
        if ($instanceid > 0) {
            return \context_course::instance($instanceid);
        } else {
            return \context_system::instance();
        }
    }