%
% D. P. Story  dpstory@uakron.edu
% The University of Akron
%
\documentclass{article}
\usepackage{amsmath}
\usepackage[dvipsone,designii,tight,nodirectory]{web}
\usepackage{exerquiz}%,preview,proofing,,noquizsolutions,nocorrections
\usepackage[setSupport]{dljslib}
\usepackage{array,pifont}

\title{\texorpdfstring{Acro\!\TeX}{AcroTeX} Bundle\texorpdfstring{\\}{: }Set Responses}
\author{D. P. Story}
\subject{File to test web and exerquiz packages}
\keywords{LaTeX,hyperref, PDF, exercises, quizzes}

\university{THE UNIVERSITY OF AKRON\\
   Theoretical and Applied Mathematics}
\email{dpstory@uakron.edu} \version{2.0}
\copyrightyears{\the\year} \makeatletter
\let\web@copyright=\@gobble
\makeatother

\def\AcroT{Acro\!\TeX}\def\cAcroT{{\textcolor{blue}{\AcroT}}}
\def\AcroEB{\AcroT{} eDucation Bundle}\def\cAcroEB{\textcolor{blue}{\AcroEB}}
\def\AcroB{\AcroT{} Bundle}\def\cAcroB{\textcolor{blue}{\AcroB}}
\def\bUrl{http://www.math.uakron.edu/~dpstory}

\makeatletter
\let\bslash=\@backslashchar
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{0pt}{6pt}{-3pt}{\bfseries}}

\makeatother

\hypersetup{linktocpage}

\newenvironment{eqComments}[1][\strut]
{\par\medskip\leftskip-\labelwidth \rightskip0pt
\noindent\textbf{\textcolor{blue}{#1}}}{\par\vspace{\medskipamount}}

\newenvironment{sverbatim}
{\par\footnotesize\verbatim}{\endverbatim\noindent}

\newcommand\redpoint{\par\ifdim\lastskip>0pt\relax\vskip-\lastskip\fi
\vskip\medskipamount\noindent
  \makebox[\parindent][l]{\large\color{red}$\blacktriangleright$}}
\newcommand\handpoint{\par\ifdim\lastskip>0pt\relax\vskip-\lastskip\fi
\vskip\medskipamount\noindent
  \makebox[\parindent][l]{\large\color{blue}\ding{042}}}

\newcommand{\cs}[1]{\texttt{\char`\\#1}}

\everymath{\displaystyle}

\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{defineJS}{\formatAsSet}
if (event.value.replace(/\\s/g,"") != "") event.value =  "{ " + event.value + " }";
\end{defineJS}

\begin{document}

\maketitle
\tableofcontents

\section{Introduction}

The \texttt{setSupport} option of the \textsf{dljslib} supplies
basic support for math fill-in questions that require a set, or a
comma delimited answer, of numbers or symbols. Currently, you
cannot mix numbers with symbols. The answers can be listed in any order.

Numerical sets or comma delimited numerical list is useful for the
student to describe the solution set of an equation, or to list
the solutions of an equation. The evaluation of the student's
answer obviously keys off of the document author's answers. For
repeated roots, for example, the document author should make it
clear whether to list the repeated roots such as $\{1,1,1,2,3\}$
or to just list the roots without multiplicities, $\{1,2,3\}$; in
the latter case, additional questions can be asked about the
multiplicities of each root.

A simple algorithm is implemented to support comma delimited lists
of symbols or sets of symbols. The symbols must be a primitive
type: \texttt{a}, \texttt{b}, \texttt{A}, \texttt{B}, \dots,
\texttt{x}, etc. No multiple character symbols, such as
\texttt{AA} or \texttt{XY}. Subscripts are obviously not
supported.


\section{\texttt{ProcRespSetNum} and \texttt{ProcRespSetSym}}

In this section we look at two new JavaScript function that process
set and comma delimited answers.  These are available from the \textsf{dljslib}
with the \texttt{setSupport} option.

\subsection{Using \texttt{ProcRespSetNum}}

The JavaScript function \texttt{ProcRespSetNum} replaces \texttt{ProcResp}, the default
function that processes a math fill-in question. This function can process comma delimited
lists of numerical values.

\begin{quiz}*{setQuiz1} List the elements (comma-delimited) of the solution set, $S$,
to each of the equations below. Do \emph{not} list repeated roots
to the equation.

\begin{questions}

%\item\PTs{2} $x^2 - 3x + 2 = 0$, $S = \RespBoxMath[\AddAAFormat{\formatAsSet}
%    \rectW{.75in}\textSize{0}]{1,2}{1}{.0001}{[0,1]}*{ProcRespSetNum}\CorrAnsButton{{ 1, 2 }}$

\item\PTs{2} $(x+1)^2 (x+3) = 0$, $S = \RespBoxMath[\AddAAFormat{\formatAsSet}
    \rectW{.75in}\textSize{0}]{-1,-3}{1}{.0001}{[0,1]}*{ProcRespSetNum}\CorrAnsButton{{ -1, -3 }}$

\begin{eqComments}
In the problem that follows, solve for $x$. If there are repeated roots, list each of the
repeated roots separately.
\end{eqComments}

\item\PTs{2} $(x+1)(2x-1)(x-2)^3 = 0$, $x = \RespBoxMath[
    \rectW{.75in}\textSize{0}]{-1, 1/2, 2, 2, 2}{1}{.0001}{[0,1]}*{ProcRespSetNum}\CorrAnsButton{ -1, 1/2, 2, 2, 2 }$

\begin{eqComments}
Answer the following set-theoretic question.
\end{eqComments}
\item\PTs{2} If $ A = \{\, 1, 2, 3, 4 \,\} $ and $ B = \{\, 3, 4, 5, 6 \,\} $ then\\[1ex]
$A \cap B = \RespBoxMath[\AddAAFormat{\formatAsSet}
    \rectW{.75in}\textSize{0}]{3,4}{1}{.0001}{[0,1]}*{ProcRespSetNum}\CorrAnsButton{{3, 4}}$

\end{questions}

\bigskip

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

\ifeqforpaper\medskip\else\vfill\fi

\noindent Answers: \AnswerField\currQuiz\hfill

\NewPage

\redpoint \textbf{Notes}:
\begin{enumerate}
\item We process this type of question with
\texttt{ProcRespSetNum}. \item There is a new command that can go
in the optional parameter list of \cs{RespBoxMath}. This command
is used to formatting the answer. In questions 1 and 3 above, you
can see \verb+\AddAAFormat{\formatAsSet}+, there \cs{formatAsSet}
is defined in the preamble. Note: All \textsf{exerquiz} quiz
commands are protected against overwriting all the carefully
written JavaScript, so, to add formatting script, you need to use
the \cs{AddAAFormat}, as illustrated above and below.

\item The basic idea for evaluating this type of problem is to
sort the author's and user's answers from least to greatest, then
comparing the corresponding answers. If all comparisons are within
the prescribed tolerance, the user's answer is judged correct.

\end{enumerate}

\NewPage

\subsection{Using \texttt{ProcRespSetSym}}

The JavaScript function \texttt{ProcRespSetSym} replaces \texttt{ProcResp}, the default
function that processes a math fill-in question. This function can process comma delimited
lists of symbolic values.

\begin{quiz}*{setQuiz2}
Answer each of the set-theoretic questions.
In the problems that follow, $ A = \{\, a, b, c, d \,\} $, $ B =
\{\, c, d, e, f \,\} $, and $ U = \{\,a,b,c,d,e,f,g\,\}$ is the
universal set. Also, the complement of a set $S$ is denoted by
$\bar{S}$.

\begin{questions}

% put the universal set into a macro for convenience.
\def\U{a,b,c,d,e,f,g}

\item\PTs{2} $A \cap B = \RespBoxMath[\AddAAFormat{\formatAsSet}
    \rectW{.75in}\textSize{0}]{c,d}(\U){1}{.0001}{[0,1]}*{ProcRespSetSym}\CorrAnsButton{{ c, d }}$

\item\PTs{2} $\bar{A} = \RespBoxMath[\AddAAFormat{\formatAsSet}
    \rectW{.75in}\textSize{0}]{e,f,g}(\U){1}{.0001}{[0,1]}*{ProcRespSetSym}\CorrAnsButton{{ e,f,g }}$

\item\PTs{2} $A \cap  \bar{B}= \RespBoxMath[\AddAAFormat{\formatAsSet}
    \rectW{.75in}\textSize{0}]{a,b}(\U){1}{.0001}{[0,1]}*{ProcRespSetSym}\CorrAnsButton{{ a, b }}$

\end{questions}

\bigskip

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

\ifeqforpaper\medskip\else\vfill\fi

\noindent Answers: \AnswerField\currQuiz\hfill


\NewPage

\redpoint \textbf{Notes}:
\begin{enumerate}
\item We process this type of question with
\texttt{ProcRespSetSym}.

\item The universal set should be passed to {ProcRespSetSym} as
the list of variables. Each of the symbols is assigned an integer
value, the answers provided by both the document author and the
user are sorted from least to greatest after the symbols are
replaced by their numerical assignments. The corresponding answers of the
document author and the user are then compared.

\item It is possible to write a JavaScript function that will process a general
comma delimited list such as $ x^2, 3x^3, \sin(x) $. Such a function will be writting
and published at a later time.

\end{enumerate}


\end{document}
