# Using \InsertChunk on examdesign class to create testbank

I've using the examdesign class to create exams and it can do almost everything I want. But I find that I've been repeating myself as I reuse old exams as practice exams and quiz problems. I'd like to create a bank of test problems and it seems that this can almost be accomplished using the \InsertChunk function provided by the examdesign class, but there seems to be a small bug.

I can almost accomplish my goal if I put the following in the main LaTeX file:

\documentclass{examdesign}

\IncludeFromFile{foo.tex}

\begin{examtop}
Exam Instructions
\end{examtop}

\begin{document}

\begin{multiplechoice}

\begin{question}
Question text goes here.
\choice[!]{0.31}
\end{question}

\InsertChunk{chunk name}

\end{multiplechoice}

\end{document}


And the following in a file named foo.tex:

\begin{chunk}{chunk name}
\begin{question}
Question 2 text goes here.
\choice[!]{0.31}
\end{question}
\end{chunk}


However, this setup breaks if I remove the first question.

I was wondering if anybody knew enough about the examdesign class to propose a modification or a workaround so that I could keep all my questions in foo.tex.

-
Your code will produce errors as it is now (apparently you need to provide some value for \class in the preamble). –  Gonzalo Medina Apr 19 '12 at 4:00
I am getting ! LaTeX Error: There's no line here to end. as of now. –  Harish Kumar Apr 19 '12 at 4:06
I've edited the code to define the examtop environment which I believe fixes the compilation errors. –  Guillermo Garza Apr 19 '12 at 4:21

examdesign uses an odd (to me) method of finding the "stuff before the questions". It literally gathers up everything before the first \begin and marks that as the instructions.

% \begin{macro}{\get@instructions}
% This macro collects everything between it and the next |\begin| token.  It then
% calls the |\find@instructions@end| macro to check whether the |\begin| token
% belongs to the \textsf{question} environment or some other environment.
%    \begin{macrocode}
\long\def\get@instructions#1\begin{\@toklist=\expandafter{\the\@toklist#1}%
\find@instructions@end}
%    \end{macrocode}
% \end{macro}


I think one could rewrite this to define an instructions environment, but maybe that makes the questions unnecessarily wordy.

The \find@instructions@end is pretty particular, and will only stop gobbling when it finds \begin{question} or \begin{block}. The \begin{block} just delays the problem, as it uses a similar method to find the instructions for the block.

In other words, I don't see a simple way to do this without changing the syntax expected by the package. Certainly, to me this looks like a question for the package author.

-