public function get_questions(
        $categoryid,
        $includesubcategories,
        $tagids = [],
        $limit = 100,
        $offset = 0,
        $fields = []
    ) {
        global $DB;

        $questionids = $this->get_question_ids($categoryid, $includesubcategories, $tagids);
        if (empty($questionids)) {
            return [];
        }

        if (empty($fields)) {
            // Return all fields.
            $fieldsstring = '*';
        } else {
            $fieldsstring = implode(',', $fields);
        }

        return $DB->get_records_list(
            'question',
            'id',
            $questionids,
            'id',
            $fieldsstring,
            $offset,
            $limit
        );
    }
public function get_questions(
        $categoryid,
        $includesubcategories,
        $tagids = [],
        $limit = 100,
        $offset = 0,
        $fields = []
    ) {
        global $DB;

        $questionids = $this->get_question_ids($categoryid, $includesubcategories, $tagids);
        if (empty($questionids)) {
            return [];
        }

        if (empty($fields)) {
            // Return all fields.
            $fieldsstring = '*';
        } else {
            $fieldsstring = implode(',', $fields);
        }

        return $DB->get_records_list(
            'question',
            'id',
            $questionids,
            'id',
            $fieldsstring,
            $offset,
            $limit
        );
    }
public function get_questions ( $ categoryid , $ includesubcategories , $ tagids = [ ] , $ limit = 100 , $ offset = 0 , $ fields = [ ] ) { global $ DB ; $ questionids = $ this -> get_question_ids ( $ categoryid , $ includesubcategories , $ tagids ) ; if ( empty ( $ questionids ) ) { return [ ] ; } if ( empty ( $ fields ) ) { // Return all fields. $ fieldsstring = '*' ; } else { $ fieldsstring = implode ( ',' , $ fields ) ; } return $ DB -> get_records_list ( 'question' , 'id' , $ questionids , 'id' , $ fieldsstring , $ offset , $ limit ) ; }
Get the list of available questions for the given criteria.

@param int $categoryid The id of a category in the question bank.
@param bool $includesubcategories Whether to pick a question from exactly
that category, or that category and subcategories.
@param array $tagids An array of tag ids. If an array is provided, then
only the questions that are tagged with ALL the provided tagids will be loaded.
@param int $limit Maximum number of results to return.
@param int $offset Number of items to skip from the begging of the result set.
@param string[] $fields The fields to return for each question.
@return \stdClass[] The list of question records
Get the list of available questions for the given criteria .