\documentclass{article}
\usepackage[designiv,forcolorpaper]{web}
\usepackage{exerquiz}
\usepackage{mi-solns}

\def\cs#1{\texttt{\char`\\#1}}
\let\pkg\textsf
\let\env\texttt

%\copySolnsOff
%\readSolnsOff

\noSolnOpt

\declCQSolStr{\textit{Solution}}\declCQQuesStr{\textit{Question}}

\begin{document}

\section{Introduction}

\noindent
\textbf{The Problem.} For a document that uses \pkg{exerquiz} or \pkg{eqexam}, can a solution
that is marked in some way be reproduced in another part of the
document?\medskip

\noindent\textbf{The Solution.} We require copies of \cs{jobname.sol} and
\cs{jobname.qsl} be made; these are named \cs{jobname-cpy.sol} and
\cs{jobname-cpy.qsl} (default names), and they are created at the end of each
compile. This file is closed when you compile again and hence can be input.
The switch for the compiler must be \texttt{--shell-escape} for those using
MiK\TeX. When a copy of a solution is needed, one of these two files are
input with the appropriate redefinitions. The solution has been formalized
into a new package \pkg{ci-solns}.

\section{Exercises}

Below are two extracted solutions from the exercises in this section.
\begin{itemize}

  \item The solution to Exercise~2 is\\[6pt]\textsl{\insExSoln{dps}} True this!

  \item The question of Exercise~2 is enclosed in the \env{cq} environment.
  The question to the solution is typeset automatically, as above. The solution to
  Exercise~2 again, this time without the question, we pass the special command
  \cs{ignoreterminex}: \textsl{\insExSoln[\ignoreterminex]{dps}}

  \item J\"{u}rgen's solution is \textsl{\insExSoln{j-mon}}

\end{itemize}

\begin{exercise}\label{ex:one}
Solve this tricky one
\begin{solution}
1) That was a tricky one, can't do it.
\end{solution}
\end{exercise}

\begin{exercise}\label{ex:two}\begin{cq}
Solve this tricky one.\end{cq}

\mrkForIns{dps}
\begin{solution}
\ifwithinsoldoc
2) That was a tricky one, can't do it. \else whatever!\fi

Pass some verbatim content as a test: \verb~$&%$^^%&~.
\end{solution}
\end{exercise}

\begin{exercise}\label{ex:three}
Solve this tricky one
\begin{solution}
3) That was a tricky one, can't do it.
\end{solution}
\end{exercise}

\begin{exercise*}
\begin{parts}
    \item This is the part (a) question.
\begin{solution}
This is the part (a) solution.
\end{solution}

    \item (J\"{u}rgen's little q) This is the part (b) question.
\mrkForIns{j-mon}
\begin{solution}
This is the part (b) solution.
\end{solution}

    \item This is the part (b) question.
\begin{solution}
This is the part (b) solution.
\end{solution}

\end{parts}
\end{exercise*}

\newpage

\section{Quizzes}

In this section are two quizzes, generated by the \env{shortquiz} and \env{quiz} environments.

\begin{itemize}

\item Alex's solution is \textsl{\insSqSoln{aps}} Check for spurious spaces.

\item Topi's solution is \textsl{\insQzSoln{topi}} Check for spurious spaces.
\end{itemize}

\begin{shortquiz}
Solve each
\begin{questions}
\item \begin{answers}*{4}
\Ans0 False &\Ans1 True
\end{answers}
\begin{solution}
The answer is True
\end{solution}

\mrkForIns{aps}
\item (Alex's question) $\cos(\pi) = \RespBoxMath{-1}*{1}{.0001}{[2,4]}\cgBdry\kern1bp\CorrAnsButton{-1}$
\begin{solution}
Of course, everyone knows that $\cos(\pi) = -1 $.
\end{solution}
\end{questions}
\end{shortquiz}

\useBeginQuizButton
\useEndQuizButton

\begin{quiz*}{mathquiz} Answer each of the following. Passing
is 100\%.

\begin{questions}

\mrkForIns{topi}
\item (Topi's question) If $\lim_{x\to a} f(x) = f(a)$, then we say that $f$ is\dots
\begin{answers}*{3}
\Ans0 differentiable &\Ans1 continuous &\Ans0 integrable
\end{answers}

\begin{solution}
A function $f$ is said to be continuous at $x=a$ if $x\in\mbox{Dom}(f)$,
$\lim_{x\to a} f(x) $ exists and $\lim_{x\to a} f(x) = f(a)$.
\end{solution}

\item $\cos(\pi) = \RespBoxMath{-1}*{1}{.0001}{[2,4]}\cgBdry\kern1bp\CorrAnsButton{-1}$
\begin{solution}
Of course, everyone knows that $\cos(\pi) = -1 $.
\end{solution}

\end{questions}
\end{quiz*}\quad\ScoreField\currQuiz\olBdry\eqButton\currQuiz

\noindent
Answers: \AnswerField\currQuiz

\end{document}
