original_string: public function get_next_question_id($categoryid, $includesubcategories, $tagids = []) {
          $this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
  
          $categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
          if (empty($this->availablequestionscache[$categorykey])) {
              return null;
          }
  
          reset($this->availablequestionscache[$categorykey]);
          $lowestcount = key($this->availablequestionscache[$categorykey]);
          reset($this->availablequestionscache[$categorykey][$lowestcount]);
          $questionid = key($this->availablequestionscache[$categorykey][$lowestcount]);
          $this->use_question($questionid);
          return $questionid;
      }
code: public function get_next_question_id($categoryid, $includesubcategories, $tagids = []) {
          $this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
  
          $categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
          if (empty($this->availablequestionscache[$categorykey])) {
              return null;
          }
  
          reset($this->availablequestionscache[$categorykey]);
          $lowestcount = key($this->availablequestionscache[$categorykey]);
          reset($this->availablequestionscache[$categorykey][$lowestcount]);
          $questionid = key($this->availablequestionscache[$categorykey][$lowestcount]);
          $this->use_question($questionid);
          return $questionid;
      }
code_tokens: public function get_next_question_id ( $ categoryid , $ includesubcategories , $ tagids = [ ] ) { $ this -> ensure_questions_for_category_loaded ( $ categoryid , $ includesubcategories , $ tagids ) ; $ categorykey = $ this -> get_category_key ( $ categoryid , $ includesubcategories , $ tagids ) ; if ( empty ( $ this -> availablequestionscache [ $ categorykey ] ) ) { return null ; } reset ( $ this -> availablequestionscache [ $ categorykey ] ) ; $ lowestcount = key ( $ this -> availablequestionscache [ $ categorykey ] ) ; reset ( $ this -> availablequestionscache [ $ categorykey ] [ $ lowestcount ] ) ; $ questionid = key ( $ this -> availablequestionscache [ $ categorykey ] [ $ lowestcount ] ) ; $ this -> use_question ( $ questionid ) ; return $ questionid ; }
docstring: Pick a question at random from the given category, from among those with the fewest uses.
  If an array of tag ids are specified, then only the questions that are tagged with ALL those tags will be selected.
  
  It is up the the caller to verify that the cateogry exists. An unknown category
  behaves like an empty one.
  
  @param int $categoryid the id of a category in the question bank.
  @param bool $includesubcategories wether to pick a question from exactly
  that category, or that category and subcategories.
  @param array $tagids An array of tag ids. A question has to be tagged with all the provided tagids (if any)
  in order to be eligible for being picked.
  @return int|null the id of the question picked, or null if there aren't any.
docstring_tokens: Pick a question at random from the given category from among those with the fewest uses . If an array of tag ids are specified then only the questions that are tagged with ALL those tags will be selected .