/**
  * Convenience method to instantiate the event.
  *
  * @param user_competency $usercompetency The user competency.
  * @return self
  */
 public static function create_from_user_competency(user_competency $usercompetency)
 {
     if (!$usercompetency->get_id()) {
         throw new \coding_exception('The user competency ID must be set.');
     }
     $params = array('contextid' => $usercompetency->get_context()->id, 'objectid' => $usercompetency->get_id(), 'relateduserid' => $usercompetency->get_userid());
     $event = static::create($params);
     $event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
     return $event;
 }
Пример #2
0
 /**
  * Delete an evidence.
  *
  * @param evidence|int $evidenceorid The evidence, or its ID.
  * @return bool
  */
 public static function delete_evidence($evidenceorid)
 {
     $evidence = $evidenceorid;
     if (!is_object($evidence)) {
         $evidence = new evidence($evidenceorid);
     }
     $uc = new user_competency($evidence->get_usercompetencyid());
     if (!evidence::can_delete_user($uc->get_userid())) {
         throw new required_capability_exception($uc->get_context(), 'moodle/competency:evidencedelete', 'nopermissions', '');
     }
     return $evidence->delete();
 }