Random selection with pgfmath.sty and probsoln.sty
\documentclass{article}
\usepackage{pgfmath}
\usepackage{probsoln}
% set random seed
\pgfmathsetseed{\year}
\begin{defproblem}{easy.diff}%
\ifundef\easydiffcoeff
{%
\pgfmathrandominteger{\easydiffcoeff}{2}{10}% generate random coefficient
\global\let\easydiffcoeff\easydiffcoeff % make it global
}
{}% already been defined
\begin{onlyproblem}
% question
Differentiate with respect to $x$:
\[
y = \sin(\easydiffcoeff x)
\]
\end{onlyproblem}
\begin{onlysolution}
% solution
$ y' = \easydiffcoeff\cos(\easydiffcoeff x) $
\end{onlysolution}
\end{defproblem}
\begin{document}
\section{Questions}
\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}
\showanswers
\section{Solutions}
\begin{enumerate}
\foreachsolution{\item\thisproblem}
\end{enumerate}
\end{document}
Download probsoln-rand.tex or probsoln-rand.pdf.
