%
% D. P. Story  dpstory@uakron.edu
% The University of Akron
%
% Demo of using web/exerquiz to create a quiz, then process the
% user's responses using the Adobe FDF Toolkit.
%
\documentclass{article}
\usepackage{amsmath}
\usepackage[dvipsone,designi,nodirectory]{web}
\usepackage[execJS,online]{exerquiz} %
\usepackage[ImplMulti,equations]{dljslib}

\title{Math Fill-Ins\texorpdfstring{\\}{: }Progressive-style Questions}
\author{D. P. Story}
\subject{Sample file}
\keywords{LaTeX, PDF, derivative, calculus, JavaScript}

\university{THE UNIVERSITY OF AKRON\\
Theoretical and Applied Mathematics}
\email{dpstory@uakron.edu}
\version{1.0}
\copyrightyears{1999-\the\year}



\makeatletter
% Define a customized \@PromptButton, this one will overlay the \CorrAnsButton
\def\PromptButton{\makebox[0pt][r]
    {\@PromptButton[\CA{Ans}\textColor{1 0 0 rg}]{\CorrectAns}}}

% When we initialize the quiz, make sure the prompt buttons are visible
\def\priorInitQuiz{this.getField("promptButton.\currQuiz").display=display.visible;\jsR}

% When we click the \eqButton (which corrects the quiz), the correctQuiz() method makes the
% the \CorrAnsButtons visible, and makes any prompt button hidden.
\makeatother

%\useBeginQuizButton[\textColor{0 0 1 rg}\CA{Start}\AC{}\RC{}\rectW{}]
%\useEndQuizButton[\textColor{0 0 1 rg}\CA{End}\AC{}\RC{}\rectW{}]
\PTsHook{($\eqPTs^{\text{pts}}$)}


\begin{document}
\maketitle

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

\begin{questions}

\everymath{\displaystyle}

\item \PTs{10} Let $ f(x) = x^3 - 4x^2 + x - 1 $. Determine the equation of the
line tangent to the graph of $f$ at $x=1$.

    \begin{questions}

    \item\PTs*{3} Compute the derivative\\[1ex]
    $
        f'(x) = \RespBox{3x^2-8x+1}*{3}{.0001}{[0,1]}\kern1bp\CorrAnsButton{3x^2-8x+1}\PromptButton
    $

    \begin{solution}
    We apply the Power Rule:
    $$
        f'(x) = 3x^2-8x+1
    $$
    \end{solution}

    \item\PTs*{2}\label{deriva} Compute
    $
        f'(1) = \RespBoxMath[\rectW{.5in}]{-4}*{1}{.0001}{[2,4]}\kern1bp\CorrAnsButton{-4}\PromptButton
    $
    \begin{solution}
    We have $ m_{\text{tan}} = f'(1) = -4 $.
    \end{solution}

    \item\PTs*{2}\label{y0} Compute
    $
        f(1) = \RespBox[\rectW{.5in}]{-3}*{1}{.0001}24\kern1bp\CorrAnsButton{-3}\PromptButton
    $
    \begin{solution}
    A simple calculation shows $ y_0 = f(1) = -3 $.
    \end{solution}

    \item\PTs*{3} Finally, using the information above, enter the equation of the
    line tangent to the graph of $f$ at $ x = 1 $.\\[1ex]
     $
         \text{Tangent line: } \RespBoxMath[\rectW{1.5in}]{y = 1 - 4x}(xy)*{3}{.0001}{[0,1]x[0,1]}*{ProcRespEq}\kern1bp\CorrAnsButton{y = 1 - 4x}
     $
     \begin{solution}
        To compute the equation of the tangent line, we use the point-slope form of the equation
        of a line:
        \begin{alignat*}{2}
            y - y_0 &= m ( x - x_0 ) &&\quad\text{point-slope form}\\
            y - (-3) &= -4 ( x - 1 ) &&\quad\text{from parts~\hyperref[deriva]{(\ref*{deriva})} and~\hyperref[y0]{(\ref*{y0})}}\\
            y &= 1 - 4x &&\quad\text{simplify}
        \end{alignat*}
        Enter \texttt{y = 1 - 4x}.
     \end{solution}
    \end{questions}
\end{questions}

\end{quiz}\quad\PointsField\currQuiz\eqButton\currQuiz

\vfill \noindent\strut Answers: \AnswerField\currQuiz
\end{document}
