Exemple #1
0
 /**
  * Remove a related competency.
  *
  * @param int $competencyid The id of the competency.
  * @param int $relatedcompetencyid The id of the related competency.
  * @return bool True when it was deleted, false when it wasn't or the relation doesn't exist.
  */
 public static function remove_related_competency($competencyid, $relatedcompetencyid)
 {
     static::require_enabled();
     $competency = new competency($competencyid);
     // This only check if we have the permission in either competency because both competencies
     // should belong to the same framework.
     require_capability('moodle/competency:competencymanage', $competency->get_context());
     $relatedcompetency = related_competency::get_relation($competencyid, $relatedcompetencyid);
     if ($relatedcompetency->get_id()) {
         return $relatedcompetency->delete();
     }
     return false;
 }
Exemple #2
0
 /**
  * Create a related competency.
  *
  * @param array|stdClass $record
  * @return related_competency
  */
 public function create_related_competency($record = null)
 {
     $record = (object) $record;
     if (!isset($record->competencyid)) {
         throw new coding_exception('Property competencyid is required.');
     }
     if (!isset($record->relatedcompetencyid)) {
         throw new coding_exception('Property relatedcompetencyid is required.');
     }
     $relation = related_competency::get_relation($record->competencyid, $record->relatedcompetencyid);
     if ($relation->get_id()) {
         throw new coding_exception('Relation already exists');
     }
     $relation->create();
     return $relation;
 }