/** * Count the plans in the template, filtered by status. * * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @param int $status One of the plan status constants (or 0 for all plans). * @return int */ public static function count_plans_for_template($templateorid, $status = 0) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return plan::count_records_for_template($template->get_id(), $status); }