Example #1
0
 /**
  * Read an evidence.
  * @param int $evidenceid The evidence ID.
  * @return evidence
  */
 public static function read_evidence($evidenceid)
 {
     static::require_enabled();
     $evidence = new evidence($evidenceid);
     $uc = new user_competency($evidence->get_usercompetencyid());
     if (!$uc->can_read()) {
         throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
     }
     return $evidence;
 }
Example #2
0
/**
 * Return the permissions of for the comments.
 *
 * @param  stdClass $params The parameters.
 * @return array
 */
function core_competency_comment_permissions($params)
{
    if (!get_config('core_competency', 'enabled')) {
        return array('post' => false, 'view' => false);
    }
    if ($params->commentarea == 'user_competency') {
        $uc = new user_competency($params->itemid);
        if ($uc->can_read()) {
            return array('post' => $uc->can_comment(), 'view' => $uc->can_read_comments());
        }
    } else {
        if ($params->commentarea == 'plan') {
            $plan = new plan($params->itemid);
            if ($plan->can_read()) {
                return array('post' => $plan->can_comment(), 'view' => $plan->can_read_comments());
            }
        }
    }
    return array('post' => false, 'view' => false);
}