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
        );
    }