original_string: public static function get_entries_by_category($id, $categoryid, $from, $limit, $options) {
          global $DB;
  
          $params = self::validate_parameters(self::get_entries_by_category_parameters(), array(
              'id' => $id,
              'categoryid' => $categoryid,
              'from' => $from,
              'limit' => $limit,
              'options' => $options,
          ));
          $id = $params['id'];
          $categoryid = $params['categoryid'];
          $from = $params['from'];
          $limit = $params['limit'];
          $options = $params['options'];
          $warnings = array();
  
          // Get and validate the glossary.
          list($glossary, $context) = self::validate_glossary($id);
  
          // Validate the mode.
          $modes = self::get_browse_modes_from_display_format($glossary->displayformat);
          if (!in_array('cat', $modes)) {
              throw new invalid_parameter_exception('invalidbrowsemode');
          }
  
          // Validate the category.
          if (in_array($categoryid, array(GLOSSARY_SHOW_ALL_CATEGORIES, GLOSSARY_SHOW_NOT_CATEGORISED))) {
              // All good.
          } else if (!$DB->record_exists('glossary_categories', array('id' => $categoryid, 'glossaryid' => $id))) {
              throw new invalid_parameter_exception('invalidcategory');
          }
  
          // Fetching the entries.
          $entries = array();
          list($records, $count) = glossary_get_entries_by_category($glossary, $context, $categoryid, $from, $limit, $options);
          foreach ($records as $key => $record) {
              self::fill_entry_details($record, $context);
              if ($record->categoryid === null) {
                  $record->categoryid = GLOSSARY_SHOW_NOT_CATEGORISED;
              }
              if (isset($record->categoryname)) {
                  $record->categoryname = external_format_string($record->categoryname, $context->id);
              }
              $entries[] = $record;
          }
  
          return array(
              'count' => $count,
              'entries' => $entries,
              'ratinginfo' => \core_rating\external\util::get_rating_info($glossary, $context, 'mod_glossary', 'entry', $entries),
              'warnings' => $warnings
          );
      }
code: public static function get_entries_by_category($id, $categoryid, $from, $limit, $options) {
          global $DB;
  
          $params = self::validate_parameters(self::get_entries_by_category_parameters(), array(
              'id' => $id,
              'categoryid' => $categoryid,
              'from' => $from,
              'limit' => $limit,
              'options' => $options,
          ));
          $id = $params['id'];
          $categoryid = $params['categoryid'];
          $from = $params['from'];
          $limit = $params['limit'];
          $options = $params['options'];
          $warnings = array();
  
          // Get and validate the glossary.
          list($glossary, $context) = self::validate_glossary($id);
  
          // Validate the mode.
          $modes = self::get_browse_modes_from_display_format($glossary->displayformat);
          if (!in_array('cat', $modes)) {
              throw new invalid_parameter_exception('invalidbrowsemode');
          }
  
          // Validate the category.
          if (in_array($categoryid, array(GLOSSARY_SHOW_ALL_CATEGORIES, GLOSSARY_SHOW_NOT_CATEGORISED))) {
              // All good.
          } else if (!$DB->record_exists('glossary_categories', array('id' => $categoryid, 'glossaryid' => $id))) {
              throw new invalid_parameter_exception('invalidcategory');
          }
  
          // Fetching the entries.
          $entries = array();
          list($records, $count) = glossary_get_entries_by_category($glossary, $context, $categoryid, $from, $limit, $options);
          foreach ($records as $key => $record) {
              self::fill_entry_details($record, $context);
              if ($record->categoryid === null) {
                  $record->categoryid = GLOSSARY_SHOW_NOT_CATEGORISED;
              }
              if (isset($record->categoryname)) {
                  $record->categoryname = external_format_string($record->categoryname, $context->id);
              }
              $entries[] = $record;
          }
  
          return array(
              'count' => $count,
              'entries' => $entries,
              'ratinginfo' => \core_rating\external\util::get_rating_info($glossary, $context, 'mod_glossary', 'entry', $entries),
              'warnings' => $warnings
          );
      }
code_tokens: public static function get_entries_by_category ( $ id , $ categoryid , $ from , $ limit , $ options ) { global $ DB ; $ params = self :: validate_parameters ( self :: get_entries_by_category_parameters ( ) , array ( 'id' => $ id , 'categoryid' => $ categoryid , 'from' => $ from , 'limit' => $ limit , 'options' => $ options , ) ) ; $ id = $ params [ 'id' ] ; $ categoryid = $ params [ 'categoryid' ] ; $ from = $ params [ 'from' ] ; $ limit = $ params [ 'limit' ] ; $ options = $ params [ 'options' ] ; $ warnings = array ( ) ; // Get and validate the glossary. list ( $ glossary , $ context ) = self :: validate_glossary ( $ id ) ; // Validate the mode. $ modes = self :: get_browse_modes_from_display_format ( $ glossary -> displayformat ) ; if ( ! in_array ( 'cat' , $ modes ) ) { throw new invalid_parameter_exception ( 'invalidbrowsemode' ) ; } // Validate the category. if ( in_array ( $ categoryid , array ( GLOSSARY_SHOW_ALL_CATEGORIES , GLOSSARY_SHOW_NOT_CATEGORISED ) ) ) { // All good. } else if ( ! $ DB -> record_exists ( 'glossary_categories' , array ( 'id' => $ categoryid , 'glossaryid' => $ id ) ) ) { throw new invalid_parameter_exception ( 'invalidcategory' ) ; } // Fetching the entries. $ entries = array ( ) ; list ( $ records , $ count ) = glossary_get_entries_by_category ( $ glossary , $ context , $ categoryid , $ from , $ limit , $ options ) ; foreach ( $ records as $ key => $ record ) { self :: fill_entry_details ( $ record , $ context ) ; if ( $ record -> categoryid === null ) { $ record -> categoryid = GLOSSARY_SHOW_NOT_CATEGORISED ; } if ( isset ( $ record -> categoryname ) ) { $ record -> categoryname = external_format_string ( $ record -> categoryname , $ context -> id ) ; } $ entries [ ] = $ record ; } return array ( 'count' => $ count , 'entries' => $ entries , 'ratinginfo' => \ core_rating \ external \ util :: get_rating_info ( $ glossary , $ context , 'mod_glossary' , 'entry' , $ entries ) , 'warnings' => $ warnings ) ; }
docstring: Browse a glossary entries by category.
  
  @param int $id The glossary ID.
  @param int $categoryid The category ID.
  @param int $from Start returning records from here.
  @param int $limit Number of records to return.
  @param array $options Array of options.
  @return array Containing count, entries and warnings.
  @since Moodle 3.1
  @throws moodle_exception
  @throws invalid_parameter_exception
docstring_tokens: Browse a glossary entries by category .