I have tried to create an exam with random questions selected from different files as shown here.
The code I used works but is only randomized on a random basis; i.e. for 1st round it gives a set of questions, no change in 2nd-4th rounds, new order 5th and 6th rounds, no change again for another few compilations.
There are no errors, just randomization fails upon compilation. Maybe, it is just a coincidence. I only use 9 files but they still should have at least 1 change (as per probability theory).
I am using TeXLive v1.17.
Below I have 3 folders named 'Photochem', 'Photophys' and 'Quenching'. In each of these folders I have 3 files named PC1.tex,PC2.tex,PC3.tex; PP1.tex,PP2.tex,PP3.tex; and Quench1.tex, Quench2.tex, Quench3.tex.
Each file just contains the filename as text (just like a Hello World example) so I can see what file is being selected.
Is anyone else able to replicate the scenario and if so, may I have any suggestion how to overcome it?
\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}{%
Photochem,% MUST have trailing % here
Photophys,%
Quenching%
}%
% 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{Photochem}{%
{PC1}%
{PC2}%
{PC3}%
}%
\pgfmathdeclarerandomlist{Photophys}{%
{PP1}%
{PP2}%
{PP3}%
}%
\pgfmathdeclarerandomlist{Quenching}{%
{Quench1}%
{Quench2}%
{Quench3}%
}%
\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}
pgfrandom...? I have written something similar quite a while, perhaps, it can be adapted to your needs? – Mar 13 '14 at 17:38