예제 #1
0
 /**
  * Link a user evidence with a competency.
  *
  * @param  user_evidence|int $userevidenceorid User evidence or its ID.
  * @param  int $competencyid Competency ID.
  * @return user_evidence_competency
  */
 public static function create_user_evidence_competency($userevidenceorid, $competencyid)
 {
     global $USER;
     static::require_enabled();
     $userevidence = $userevidenceorid;
     if (!is_object($userevidence)) {
         $userevidence = self::read_user_evidence($userevidence);
     }
     // Perform user evidence capability checks.
     if (!$userevidence->can_manage()) {
         $context = $userevidence->get_context();
         throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', '');
     }
     // Perform competency capability checks.
     $competency = self::read_competency($competencyid);
     // Get (and create) the relation.
     $relation = user_evidence_competency::get_relation($userevidence->get_id(), $competency->get_id());
     if (!$relation->get_id()) {
         $relation->create();
         $link = url::user_evidence($userevidence->get_id());
         self::add_evidence($userevidence->get_userid(), $competency, $userevidence->get_context(), evidence::ACTION_LOG, 'evidence_evidenceofpriorlearninglinked', 'core_competency', $userevidence->get_name(), false, $link->out(false), null, $USER->id);
     }
     return $relation;
 }
 /**
  * Returns relevant URL.
  *
  * @return \moodle_url
  */
 public function get_url()
 {
     return \core_competency\url::user_evidence($this->objectid);
 }