/** * Remove a relation between a template and a cohort. * * @param template|int $templateorid The template or its ID. * @param stdClass|int $cohortorid The cohort ot its ID. * @return boolean True on success or when the relation did not exist. */ public static function delete_template_cohort($templateorid, $cohortorid) { global $DB; static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } require_capability('moodle/competency:templatemanage', $template->get_context()); $cohort = $cohortorid; if (!is_object($cohort)) { $cohort = $DB->get_record('cohort', array('id' => $cohort), '*', MUST_EXIST); } $tplcohort = template_cohort::get_relation($template->get_id(), $cohort->id); if (!$tplcohort->get_id()) { return true; } return $tplcohort->delete(); }