public function can_manage_rule() {
        $courseid = $this->rulecourseid;
        $context = empty($courseid) ? \context_system::instance() : \context_course::instance($courseid);
        return has_capability('tool/monitor:managerules', $context);
    }