original_string: public static function list_plan_competencies($planorid) {
          static::require_enabled();
          $plan = $planorid;
          if (!is_object($planorid)) {
              $plan = new plan($planorid);
          }
  
          if (!$plan->can_read()) {
              $context = context_user::instance($plan->get('userid'));
              throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', '');
          }
  
          $result = array();
          $competencies = $plan->get_competencies();
  
          // Get user competencies from user_competency_plan if the plan status is set to complete.
          $iscompletedplan = $plan->get('status') == plan::STATUS_COMPLETE;
          if ($iscompletedplan) {
              $usercompetencies = user_competency_plan::get_multiple($plan->get('userid'), $plan->get('id'), $competencies);
              $ucresultkey = 'usercompetencyplan';
          } else {
              $usercompetencies = user_competency::get_multiple($plan->get('userid'), $competencies);
              $ucresultkey = 'usercompetency';
          }
  
          // Build the return values.
          foreach ($competencies as $key => $competency) {
              $found = false;
  
              foreach ($usercompetencies as $uckey => $uc) {
                  if ($uc->get('competencyid') == $competency->get('id')) {
                      $found = true;
                      unset($usercompetencies[$uckey]);
                      break;
                  }
              }
  
              if (!$found) {
                  if ($iscompletedplan) {
                      throw new coding_exception('A user competency plan is missing');
                  } else {
                      $uc = user_competency::create_relation($plan->get('userid'), $competency->get('id'));
                  }
              }
  
              $plancompetency = (object) array(
                  'competency' => $competency,
                  'usercompetency' => null,
                  'usercompetencyplan' => null
              );
              $plancompetency->$ucresultkey = $uc;
              $result[] = $plancompetency;
          }
  
          return $result;
      }
code: public static function list_plan_competencies($planorid) {
          static::require_enabled();
          $plan = $planorid;
          if (!is_object($planorid)) {
              $plan = new plan($planorid);
          }
  
          if (!$plan->can_read()) {
              $context = context_user::instance($plan->get('userid'));
              throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', '');
          }
  
          $result = array();
          $competencies = $plan->get_competencies();
  
          // Get user competencies from user_competency_plan if the plan status is set to complete.
          $iscompletedplan = $plan->get('status') == plan::STATUS_COMPLETE;
          if ($iscompletedplan) {
              $usercompetencies = user_competency_plan::get_multiple($plan->get('userid'), $plan->get('id'), $competencies);
              $ucresultkey = 'usercompetencyplan';
          } else {
              $usercompetencies = user_competency::get_multiple($plan->get('userid'), $competencies);
              $ucresultkey = 'usercompetency';
          }
  
          // Build the return values.
          foreach ($competencies as $key => $competency) {
              $found = false;
  
              foreach ($usercompetencies as $uckey => $uc) {
                  if ($uc->get('competencyid') == $competency->get('id')) {
                      $found = true;
                      unset($usercompetencies[$uckey]);
                      break;
                  }
              }
  
              if (!$found) {
                  if ($iscompletedplan) {
                      throw new coding_exception('A user competency plan is missing');
                  } else {
                      $uc = user_competency::create_relation($plan->get('userid'), $competency->get('id'));
                  }
              }
  
              $plancompetency = (object) array(
                  'competency' => $competency,
                  'usercompetency' => null,
                  'usercompetencyplan' => null
              );
              $plancompetency->$ucresultkey = $uc;
              $result[] = $plancompetency;
          }
  
          return $result;
      }
code_tokens: public static function list_plan_competencies ( $ planorid ) { static :: require_enabled ( ) ; $ plan = $ planorid ; if ( ! is_object ( $ planorid ) ) { $ plan = new plan ( $ planorid ) ; } if ( ! $ plan -> can_read ( ) ) { $ context = context_user :: instance ( $ plan -> get ( 'userid' ) ) ; throw new required_capability_exception ( $ context , 'moodle/competency:planview' , 'nopermissions' , '' ) ; } $ result = array ( ) ; $ competencies = $ plan -> get_competencies ( ) ; // Get user competencies from user_competency_plan if the plan status is set to complete. $ iscompletedplan = $ plan -> get ( 'status' ) == plan :: STATUS_COMPLETE ; if ( $ iscompletedplan ) { $ usercompetencies = user_competency_plan :: get_multiple ( $ plan -> get ( 'userid' ) , $ plan -> get ( 'id' ) , $ competencies ) ; $ ucresultkey = 'usercompetencyplan' ; } else { $ usercompetencies = user_competency :: get_multiple ( $ plan -> get ( 'userid' ) , $ competencies ) ; $ ucresultkey = 'usercompetency' ; } // Build the return values. foreach ( $ competencies as $ key => $ competency ) { $ found = false ; foreach ( $ usercompetencies as $ uckey => $ uc ) { if ( $ uc -> get ( 'competencyid' ) == $ competency -> get ( 'id' ) ) { $ found = true ; unset ( $ usercompetencies [ $ uckey ] ) ; break ; } } if ( ! $ found ) { if ( $ iscompletedplan ) { throw new coding_exception ( 'A user competency plan is missing' ) ; } else { $ uc = user_competency :: create_relation ( $ plan -> get ( 'userid' ) , $ competency -> get ( 'id' ) ) ; } } $ plancompetency = ( object ) array ( 'competency' => $ competency , 'usercompetency' => null , 'usercompetencyplan' => null ) ; $ plancompetency -> $ ucresultkey = $ uc ; $ result [ ] = $ plancompetency ; } return $ result ; }
docstring: List the competencies in a user plan.
  
  @param  int $planorid The plan, or its ID.
  @return array((object) array(
  'competency' => \core_competency\competency,
  'usercompetency' => \core_competency\user_competency
  'usercompetencyplan' => \core_competency\user_competency_plan
  ))
  The values of of keys usercompetency and usercompetencyplan cannot be defined at the same time.
docstring_tokens: List the competencies in a user plan .