original_string: public static function list_evidence($userid = 0, $competencyid = 0, $planid = 0, $sort = 'timecreated',
                                           $order = 'DESC', $skip = 0, $limit = 0) {
          static::require_enabled();
  
          if (!user_competency::can_read_user($userid)) {
              $context = context_user::instance($userid);
              throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', '');
          }
  
          $usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
          if (!$usercompetency) {
              return array();
          }
  
          $plancompleted = false;
          if ($planid != 0) {
              $plan = new plan($planid);
              if ($plan->get('status') == plan::STATUS_COMPLETE) {
                  $plancompleted = true;
              }
          }
  
          $select = 'usercompetencyid = :usercompetencyid';
          $params = array('usercompetencyid' => $usercompetency->get('id'));
          if ($plancompleted) {
              $select .= ' AND timecreated <= :timecompleted';
              $params['timecompleted'] = $plan->get('timemodified');
          }
  
          $orderby = $sort . ' ' . $order;
          $orderby .= !empty($orderby) ? ', id DESC' : 'id DESC'; // Prevent random ordering.
  
          $evidence = evidence::get_records_select($select, $params, $orderby, '*', $skip, $limit);
          return $evidence;
      }
code: public static function list_evidence($userid = 0, $competencyid = 0, $planid = 0, $sort = 'timecreated',
                                           $order = 'DESC', $skip = 0, $limit = 0) {
          static::require_enabled();
  
          if (!user_competency::can_read_user($userid)) {
              $context = context_user::instance($userid);
              throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', '');
          }
  
          $usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
          if (!$usercompetency) {
              return array();
          }
  
          $plancompleted = false;
          if ($planid != 0) {
              $plan = new plan($planid);
              if ($plan->get('status') == plan::STATUS_COMPLETE) {
                  $plancompleted = true;
              }
          }
  
          $select = 'usercompetencyid = :usercompetencyid';
          $params = array('usercompetencyid' => $usercompetency->get('id'));
          if ($plancompleted) {
              $select .= ' AND timecreated <= :timecompleted';
              $params['timecompleted'] = $plan->get('timemodified');
          }
  
          $orderby = $sort . ' ' . $order;
          $orderby .= !empty($orderby) ? ', id DESC' : 'id DESC'; // Prevent random ordering.
  
          $evidence = evidence::get_records_select($select, $params, $orderby, '*', $skip, $limit);
          return $evidence;
      }
code_tokens: public static function list_evidence ( $ userid = 0 , $ competencyid = 0 , $ planid = 0 , $ sort = 'timecreated' , $ order = 'DESC' , $ skip = 0 , $ limit = 0 ) { static :: require_enabled ( ) ; if ( ! user_competency :: can_read_user ( $ userid ) ) { $ context = context_user :: instance ( $ userid ) ; throw new required_capability_exception ( $ context , 'moodle/competency:usercompetencyview' , 'nopermissions' , '' ) ; } $ usercompetency = user_competency :: get_record ( array ( 'userid' => $ userid , 'competencyid' => $ competencyid ) ) ; if ( ! $ usercompetency ) { return array ( ) ; } $ plancompleted = false ; if ( $ planid != 0 ) { $ plan = new plan ( $ planid ) ; if ( $ plan -> get ( 'status' ) == plan :: STATUS_COMPLETE ) { $ plancompleted = true ; } } $ select = 'usercompetencyid = :usercompetencyid' ; $ params = array ( 'usercompetencyid' => $ usercompetency -> get ( 'id' ) ) ; if ( $ plancompleted ) { $ select .= ' AND timecreated <= :timecompleted' ; $ params [ 'timecompleted' ] = $ plan -> get ( 'timemodified' ) ; } $ orderby = $ sort . ' ' . $ order ; $ orderby .= ! empty ( $ orderby ) ? ', id DESC' : 'id DESC' ; // Prevent random ordering. $ evidence = evidence :: get_records_select ( $ select , $ params , $ orderby , '*' , $ skip , $ limit ) ; return $ evidence ; }
docstring: List all the evidence for a user competency.
  
  @param int $userid The user id - only used if usercompetencyid is 0.
  @param int $competencyid The competency id - only used it usercompetencyid is 0.
  @param int $planid The plan id - not used yet - but can be used to only list archived evidence if a plan is completed.
  @param string $sort The field to sort the evidence by.
  @param string $order The ordering of the sorting.
  @param int $skip Number of records to skip.
  @param int $limit Number of records to return.
  @return \core_competency\evidence[]
  @return array of \core_competency\evidence
docstring_tokens: List all the evidence for a user competency .