multiversionquiz

preamble

defines everything

\documentclass[14pt, oneside]{memoir}

%% Three packages needed to generate pdf file
\usepackage{ifthen}
\usepackage{intcalc}
\usepackage{forloop}
%% Two packages for background
\usepackage[absolute,overlay]{textpos}
\usepackage{pdfpages}

\usepackage{mathtools}
\usepackage{amssymb, amsthm}
\usepackage{tikz}\usepackage{enumitem}

\textheight=9.5in
\voffset=-20pt
\parindent=0pt

\theoremstyle{definition}
\newtheorem{problem}{Problem}

\newcounter{bookletnumber}
\setcounter{bookletnumber}{1}

\pagestyle{empty}

\newcommand{\lec}{LEC 0101}

\newcommand{\problemversion}{\intcalcMod{\thebookletnumber}{5}}

\newcommand{\problemOneA}{\begin{problem}
Calculate $1+1$
\end{problem}}

\newcommand{\problemOneB}{\begin{problem}
Calculate $2+1$
\end{problem}}

\newcommand{\problemOneC}{\begin{problem}[1.5pt]
Calculate $3+1$
\end{problem}}

\newcommand{\problemOneD}{\begin{problem}[1.5pt]
Calculate $3+2$
\end{problem}}

\newcommand{\problemOneE}{\begin{problem}[1.5pt]
Calculate $3+3$
\end{problem}}

\newcommand{\problemTwoA}{\begin{problem}[1.5pt]
Calculate $1-1$
\end{problem}}

\newcommand{\problemTwoB}{\begin{problem}[1.5pt]
Calculate $2-1$
\end{problem}}

\newcommand{\problemTwoC}{\begin{problem}[1.5pt]
Calculate $3-1$
\end{problem}}

\newcommand{\problemTwoD}{\begin{problem}[1.5pt]
Calculate $3-2$
\end{problem}}

\newcommand{\problemTwoE}{\begin{problem}[1.5pt]
Calculate $3-3$
\end{problem}}

\newcommand\problemOne[1]{\ifthenelse{\equal{#1}{1}}%
{\problemOneA}{\ifthenelse{\equal{#1}{2}}{\problemOneB}{\ifthenelse{\equal{#1}{3}}{\problemOneC}{\ifthenelse{\equal{#1}{4}}{\problemOneD}{\ifthenelse{\equal{#1}{0}}{\problemOneE}{Rats! An error!}}}}}}

\newcommand\problemTwo[1]{\ifthenelse{\equal{#1}{1}}%
{\problemTwoA}{\ifthenelse{\equal{#1}{2}}{\problemTwoB}{\ifthenelse{\equal{#1}{3}}{\problemTwoC}{\ifthenelse{\equal{#1}{4}}{\problemTwoD}{\ifthenelse{\equal{#1}{0}}{\problemTwoE}{Rats! An error!}}}}}}

\newcommand{\booklet}{%
\begin{textblock}{2}(2,1)
\Huge{\textbf{\thebookletnumber}}
\end{textblock}
\begin{textblock}{2}(0,0)
\includepdf[pages=\thepage ]{dummy.pdf}\end{textblock}
{\ }
\vskip20pt

\begin{center}
{\textbf{APM 346: \lec}}
\vskip 10pt
{\textbf{Quiz 1 (Week 3)}}

\vskip295pt

\end{center}

\newpage

\begin{textblock}{2}(0,0)
\includepdf[pages=\thepage]{dummy.pdf}\end{textblock}

\hrule

\problemOne{\problemversion}

\newpage

\hrule

\problemTwo{\problemversion}

\begin{textblock}{2}(0,0)
\includepdf[pages=\thepage]{dummy.pdf}\end{textblock}

\newpage
\begin{textblock}{2}(0,0)
\includepdf[pages=\thepage]{dummy.pdf}\end{textblock}

\hrule
{\ }

\newpage

\setcounter{problem}{0}}
body

defines the number of booklets needed and their booklet-number range

\begin{document}


\forloop{bookletnumber}{1}{\value{bookletnumber} < 201}{\booklet}

\end{document}

If we have more than one sitting we need to generate pdf for the second one (etc); we need to redefined problems and the sitting indicator; we prefer to start booklet from 201 (and thus we need to set a proper page counter for the first page of this sitting)

body
\begin{document}


\forloop{bookletnumber}{1}{\value{bookletnumber} < 151}

{\booklet}



\renewcommand{\lec}{LEC 0201}

\renewcommand{\problemOneA}{\begin{problem}
Calculate $10+1$
\end{problem}}

\renewcommand{\problemOneB}{\begin{problem}
Calculate $20+1$
\end{problem}}

\renewcommand{\problemOneC}{\begin{problem}
Calculate $30+1$
\end{problem}}

\renewcommand{\problemOneD}{\begin{problem}
Calculate $30+2$
\end{problem}}

\renewcommand{\problemOneE}{\begin{problem}
Calculate $30+3$
\end{problem}}


\renewcommand{\problemTwoA}{\begin{problem}
Calculate $10-1$
\end{problem}}

\renewcommand{\problemTwoB}{\begin{problem}
Calculate $20-1$
\end{problem}}

\renewcommand{\problemTwoC}{\begin{problem}
Calculate $30-1$
\end{problem}}

\renewcommand{\problemTwoD}{\begin{problem}
Calculate $30-2$
\end{problem}}

\renewcommand{\problemTwoE}{\begin{problem}
Calculate $30-3$
\end{problem}}

\setcounter{page}{801}
\forloop{bookletnumber}{201}{\value{bookletnumber} < 351}{\booklet}


\end{document}