original_string: public static function list_course_module_competencies($cmorid) {
          static::require_enabled();
          $cm = $cmorid;
          if (!is_object($cmorid)) {
              $cm = get_coursemodule_from_id('', $cmorid, 0, true, MUST_EXIST);
          }
  
          // Check the user have access to the course module.
          self::validate_course_module($cm);
          $context = context_module::instance($cm->id);
  
          $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage');
          if (!has_any_capability($capabilities, $context)) {
              throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', '');
          }
  
          $result = array();
  
          // TODO We could improve the performance of this into one single query.
          $coursemodulecompetencies = course_competency::list_course_module_competencies($cm->id);
          $competencies = course_module_competency::list_competencies($cm->id);
  
          // Build the return values.
          foreach ($coursemodulecompetencies as $key => $coursemodulecompetency) {
              $result[] = array(
                  'competency' => $competencies[$coursemodulecompetency->get('competencyid')],
                  'coursemodulecompetency' => $coursemodulecompetency
              );
          }
  
          return $result;
      }
code: public static function list_course_module_competencies($cmorid) {
          static::require_enabled();
          $cm = $cmorid;
          if (!is_object($cmorid)) {
              $cm = get_coursemodule_from_id('', $cmorid, 0, true, MUST_EXIST);
          }
  
          // Check the user have access to the course module.
          self::validate_course_module($cm);
          $context = context_module::instance($cm->id);
  
          $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage');
          if (!has_any_capability($capabilities, $context)) {
              throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', '');
          }
  
          $result = array();
  
          // TODO We could improve the performance of this into one single query.
          $coursemodulecompetencies = course_competency::list_course_module_competencies($cm->id);
          $competencies = course_module_competency::list_competencies($cm->id);
  
          // Build the return values.
          foreach ($coursemodulecompetencies as $key => $coursemodulecompetency) {
              $result[] = array(
                  'competency' => $competencies[$coursemodulecompetency->get('competencyid')],
                  'coursemodulecompetency' => $coursemodulecompetency
              );
          }
  
          return $result;
      }
code_tokens: public static function list_course_module_competencies ( $ cmorid ) { static :: require_enabled ( ) ; $ cm = $ cmorid ; if ( ! is_object ( $ cmorid ) ) { $ cm = get_coursemodule_from_id ( '' , $ cmorid , 0 , true , MUST_EXIST ) ; } // Check the user have access to the course module. self :: validate_course_module ( $ cm ) ; $ context = context_module :: instance ( $ cm -> id ) ; $ capabilities = array ( 'moodle/competency:coursecompetencyview' , 'moodle/competency:coursecompetencymanage' ) ; if ( ! has_any_capability ( $ capabilities , $ context ) ) { throw new required_capability_exception ( $ context , 'moodle/competency:coursecompetencyview' , 'nopermissions' , '' ) ; } $ result = array ( ) ; // TODO We could improve the performance of this into one single query. $ coursemodulecompetencies = course_competency :: list_course_module_competencies ( $ cm -> id ) ; $ competencies = course_module_competency :: list_competencies ( $ cm -> id ) ; // Build the return values. foreach ( $ coursemodulecompetencies as $ key => $ coursemodulecompetency ) { $ result [ ] = array ( 'competency' => $ competencies [ $ coursemodulecompetency -> get ( 'competencyid' ) ] , 'coursemodulecompetency' => $ coursemodulecompetency ) ; } return $ result ; }
docstring: List the competencies associated to a course module.
  
  @param mixed $cmorid The course module, or its ID.
  @return array( array(
  'competency' => \core_competency\competency,
  'coursemodulecompetency' => \core_competency\course_module_competency
  ))
docstring_tokens: List the competencies associated to a course module .