How do I generate in LaTeX a list of random questions avoiding repetitions?
\documentclass{article}
\usepackage[pdftex]{exerquiz}
\usepackage{enumitem}
\usepackage{tikz}
\newcommand*{\ListOfTopics}{%
AlgebraQuestions,%
TrigQuestions%
}%
\pgfmathdeclarerandomlist{AlgebraQuestions}{%
{AlgebraQ1}%
{AlgebraQ2}%
{AlgebraQ3}%
}%
\pgfmathdeclarerandomlist{TrigQuestions}{%
{TrigQ1}%
{TrigQ2}%
{TrigQ3}%
}%
\newcommand*{\NumberOfQuizes}{3}%
\begin{document}
\foreach \QuizNumber in {1,...,\NumberOfQuizes} {%
\section{Вариант}
\noindent\textbf{\Large Quiz Number \QuizNumber}%
\begin{enumerate}
\foreach \Topic in \ListOfTopics {%
\pgfmathrandomitem{\RandomQuestion}{\Topic}
\item Random Question from Topic='\Topic':
\textbf{\Large\RandomQuestion}%
}%
\end{enumerate}
}%
\end{document}
I read that I can use that, but how to adapt it?
\def\prunelist#1{%
\expandafter\edef\csname pgfmath@randomlist@#1\endcsname
{\the\numexpr\csname pgfmath@randomlist@#1\endcsname-1\relax}
\count@\pgfmath@randomtemp
\loop
\expandafter\let
\csname pgfmath@randomlist@#1@\the\count@\expandafter\endcsname
\csname pgfmath@randomlist@#1@\the\numexpr\count@+1\relax\endcsname
\ifnum\count@<\csname pgfmath@randomlist@#1\endcsname\relax
\advance\count@\@ne
\repeat}
Best Answer
For a LaTeX/pgfmath solution I'd go with something like the code shown below. The code is somewhat impenetrable, but it is unfortunately unavoidable. As random list stuff is all assigned globally, it is necessary to also introduce a command to copy random lists. Possibly with LuaLaTeX and tables it would be easier.
And to give a more graphical demonstration, consider following code (with
\usepackage{tikz}
in the preamble):