Since you do not provide any code snippets it is not exactly clear how you want this to work, but here is how I would do this.
Topic Directories:
I would create directories for each topic. For instance AlgebraQuestions/, and
TrigQuestions/ to contain all the files which are all the possible questions from these topics. This would be defined as follows:
\newcommand*{\ListOfTopics}{%
AlgebraQuestions,% MUST have trailing % here
TrigQuestions%
}%
This list of topics determines how many questions will be in the quiz
since it appears that you want one question per topic in a quiz.
If you organized all your topic directories to be sub-directories then this \ListOfTopics could be auto generated based on the names of the sub-directories.
List of Questions for each Topic:
For each topic directory I would define a pgfmathdeclarerandomlist. So, for instance if the topic AlgebraQuestions/ had three files named file, file2, and file3, I would define:
\pgfmathdeclarerandomlist{AlgebraQuestions}{{file1}{file2}{file3}}
In the MWE below I have hard coded this list, but it certainly could be auto generated on the fly based on the existing files in a directory.
Number of Quizzes:
The only variable that would need to be manually set (or specified on the command line), would be the number of quizzes you desire to generate:
\newcommand*{\NumberOfQuizes}{4}%
Output:
So assuming that directory
AlgebraQuestions/ contains files named AlgebraQ1,...,AlgebraQ6, and the
TrigQuestions/ directory contains files named TrigQ1,...,TrigQ9 we get:

But instead of printing the files names as I have done below with \item, you would import the file name defined in \RandomQuestion.
Notes:
Since questions are selected at random there is a possibility that some quizzes will have the same question (as is the case with Quiz 3 and 4 below). However this probability reduces as the number of questions grow. If this is not desired this could be prevented with additional coding to ensure that a previously picked random number for each list is not reused.
If the questions for each topic are in one file, one could adapt the solution from Automating quoting across LaTeX documents, which picks out specific named environment from a file. The usage of this will depend on exactly how the problems are defined, and require that each problem be given a name with which to address it by.
However, I would highly recommend that each question be in a separate file, (perhaps using the standalone package) as this
- greatly simplifies the management of this process (especially as the number of questions grows),
- allows one to easily add new problems without worrying about providing a unique name for it, as the file system will take ensure that the names of each problem are unique,
- allows each file to be compiled and proofed by itself, and
- if desired, one can easily create a document with all the problems. See the References section for some options on this.
References:
Code:
\documentclass{article}
%\usepackage[paperheight=3.0cm, paperwidth=12.0cm, margin=0.1cm]{geometry}% Simplify image capture
\usepackage{enumitem}
\usepackage{tikz}% Easy way to get all the pgf functions
% The list of topics determines how many questions will be in the quiz
% since it appears that you want one question per topic in a quiz.
% This could be auto generated.
\newcommand*{\ListOfTopics}{%
AlgebraQuestions,% MUST have trailing % here
TrigQuestions%
}%
% These list of files names from each question can be auto generated
% but for example purposes I am just using the file names as the
% content in the file. The number of questions in each topic do not
% need to be the same. I would create directories with the topic
% names and auto generate this based on the directory and file names.
\pgfmathdeclarerandomlist{AlgebraQuestions}{%
{AlgebraQ1}%
{AlgebraQ1}%
{AlgebraQ3}%
{AlgebraQ4}%
{AlgebraQ5}%
{AlgebraQ6}%
}%
\pgfmathdeclarerandomlist{TrigQuestions}{%
{TrigQ1}%
{TrigQ2}%
{TrigQ3}%
{TrigQ4}%
{TrigQ5}%
{TrigQ6}%
{TrigQ7}%
{TrigQ8}%
{TrigQ9}%
}%
\newcommand*{\NumberOfQuizes}{4}%
\begin{document}
\foreach \QuizNumber in {1,...,\NumberOfQuizes} {%
\clearpage% Start each quiz on a new page
\noindent\textbf{\Large Quiz Number \QuizNumber}%
\begin{enumerate}
\foreach \Topic in \ListOfTopics {%
% Determine random question to use form list
\pgfmathrandomitem{\RandomQuestion}{\Topic}
% The following should import the file named in \RandomQuestion
\item Random Question from Topic='\Topic':
\textbf{\Large\RandomQuestion}%
}%
\end{enumerate}
}%
\end{document}