/** * Update the details for a competency. * * Requires moodle/competency:competencymanage capability at the system context. * * @param stdClass $record The new details for the competency. * Note - must contain an id that points to the competency to update. * * @return boolean */ public static function update_competency($record) { static::require_enabled(); $competency = new competency($record->id); // First we do a permissions check. require_capability('moodle/competency:competencymanage', $competency->get_context()); // Some things should not be changed in an update - they should use a more specific method. $record->sortorder = $competency->get_sortorder(); $record->parentid = $competency->get_parentid(); $record->competencyframeworkid = $competency->get_competencyframeworkid(); $competency->from_record($record); require_capability('moodle/competency:competencymanage', $competency->get_context()); // OK - all set. $result = $competency->update(); // Trigger the update event. \core\event\competency_updated::create_from_competency($competency)->trigger(); return $result; }