% \iffalse
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exerquiz.sty package, 2000-8-16 %%
%% Copyright (C) 1999-2004 D. P. Story %%
%% dpstory@uakron.edu %%
%% %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License %%
%% Distributed from CTAN archives in directory %%
%% macros/latex/base/lppl.txt; either version 1 of the %%
%% License, or (at your option) any later version. %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%\NeedsTeXFormat{LaTeX2e}
%\ProvidesPackage{exerquiz}
% [2007/05/05 v6.08 Exerquiz Exercises and Quizzes for LaTeX/PDF package (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[dviwindo,colorlinks,hyperindex]{hyperref}
\pdfstringdefDisableCommands{\let\\\textbackslash}
\OnlyDescription % comment out for implementation details
\EnableCrossrefs
\CodelineIndex
\begin{document}
\GetFileInfo{exerquiz.sty}
\title{Exerquiz: Exercises and Quizzes for \LaTeX/PDF}
\author{D. P. Story\\
Email: \texttt{dpstory@uakron.edu}}
\date{processed \today}
\maketitle
\tableofcontents
\let\Email\texttt
\DocInput{exerquiz.dtx}
\PrintIndex
\end{document}
%
% \fi
%
% \MakeShortVerb{|}
%
% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let}
% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi}
% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup}
% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand}
% \DoNotIndex{\space,\@empty,\special}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
% \newpage
% \section{Change History}
% \makeatletter
% \renewenvironment{theglossary}{%
%
% \let\efill=\relax
% \begin{itemize}}%
% {\end{itemize}}
% \global\c@GlossaryColumns = 1
% \makeatother
% \PrintChanges
% \section{Package options and setup}\label{options}
%
% Introduce a number of useful options for \textsl{exerquiz}.
% \subsection{Options for paper, solutions, JavaScript and preview}
% \begin{macrocode}
\IfFileExists{xcolor.sty}%
{\def\eq@ColorPackage{xcolor}\PassOptionsToPackage{table,hyperref}{xcolor}}
{\def\eq@ColorPackage{color}}
\DeclareOption{noxcolor}{\def\eq@ColorPackage{color}}
% \end{macrocode}
% \begin{macro}{forpaper}
% \begin{macro}{forcolorpaper}
% Pass the |monochrome| option to the color package
%\changes{v6.06a}{2007/04/09}
%{
% Added the \texttt{forcolorpaper} option for those using \textsf{exerquiz} without \textsf{web}.
%}
% \begin{macrocode}
\DeclareOption{forpaper}{%
\eqforpapertrue\PassOptionsToPackage{monochrome}{\eq@ColorPackage}
\AtBeginDocument{\ifnum\eq@drivernum=4 \else\AllowPeeking\fi}
}
\DeclareOption{forcolorpaper}{\eqforpapertrue % for print
\AtBeginDocument{\ifnum\eq@drivernum=4 \else\AllowPeeking\fi}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{preview}
% With this option, the bounding boxes of all form fields appear in the
% dvi preview. Use this option of properly positioning your fields, then
% remove this option on the final build of the document. This option is no
% appropriate for the \texttt{pdftex} option which does not have a dvi preview.
% \begin{macrocode}
\DeclareOption{preview}{\PassOptionsToPackage{preview}{eforms}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{nosolutions}
% With the option, the solutions to the exercises are not
% included in the typeset document.
% \begin{macrocode}
\DeclareOption{nosolutions}{\eq@nosolutionstrue\eq@nolinktrue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{noquizolutions}
% No solutions for quizzes (shortquiz and quiz environments).
% \begin{macrocode}
\DeclareOption{noquizsolutions}{\eq@noquizsolutionstrue\eq@nolinktrue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{online}
% An \texttt{online} options.
% \begin{macrocode}
\DeclareOption{online}{\let\eq@online=y}
\let\eq@online=n
% \end{macrocode}
% \end{macro}
% \begin{macro}{nohiddensolutions}
% Overrides any hidden solutions specified with the \texttt{exercise}
% environment.
% \begin{macrocode}
\DeclareOption{nohiddensolutions}{\eq@globalshowsolutionstrue}
\DeclareOption{noHiddensolutions}%
{\eq@globalshowsolutionstrue\AtBeginDocument{\def\Hidesymbol{h}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{solutionsafter}
% Solutions will appear after the statement of the exercise.
% \begin{macrocode}
\DeclareOption{solutionsafter}{\eq@solutionsaftertrue\eq@nolinktrue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{nocorrections}
% The code for correcting the |quiz| environment is
% not written; this results in a smaller file.
% \begin{macrocode}
\DeclareOption{nocorrections}{\eq@nocorrectionstrue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{proofing}
% An option for marking the correct answers for shortquiz and quiz
% \begin{macrocode}
\DeclareOption{proofing}{\eq@proofingtrue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{showgrayletters}
% When this option is in effect, capital letters in gray appear under
% the multiple choice question boxes of quizzes.
% \begin{macrocode}
\newif\ifaebshowgrayletters\aebshowgraylettersfalse
\DeclareOption{showgrayletters}{\aebshowgrayletterstrue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{nodljs}
% An option for excluding all DLJS from the document. Useful with the
% \texttt{forpaper} option, or a document destined to be printed. Pass
% on to insdljs package.
% \begin{macrocode}
\DeclareOption{nodljs}{\PassOptionsToPackage{nodljs}{insdljs}%
\AtEndOfPackage{\let\importdljs=y}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{execAfter}
% Execute any JS defined within the \texttt{execJS} environment. Works only for
% authors using Acrobat 5.0 or Acrobat Approval.
% \begin{macrocode}
\DeclareOption{execJS}{\PassOptionsToPackage{execJS}{insdljs}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{exercisesonly}
% If the document author wants only to create a series of exercises, no quizzes, there is no
% need for the Document-level JavaScript. So, we have a couple of convenience options.
% \begin{macrocode}
\DeclareOption{exercisesonly}{\PassOptionsToPackage{nodljs}{insdljs}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{debug}
% An option for debugging JavaScript. Pass on to insdljs package.
% \begin{macrocode}
\DeclareOption{debug}{\PassOptionsToPackage{debug}{insdljs}}
% \end{macrocode}
% \end{macro}
% \subsection{Driver Options}
% The \textsf{web} package passes these driver options to \textsf{exerquiz}.
% These options are needed is \textsf{exerquiz} is used without
% \textsf{web}; in this case, the options below must explicitly included.
% \begin{macro}{dvipsone}
% Set the driver dependent code for the |quiz| environments.
% \begin{macrocode}
% \def\eq@drivernum{5} % 5 = no choice
\DeclareOption{dvipsone}{\def\eq@drivernum{0}%
\PassOptionsToPackage{dvipsone}{eforms}
% \PassOptionsToPackage{dvipsone}{insdljs}
}
\DeclareOption{dvips}{\def\eq@drivernum{0}%
\PassOptionsToPackage{dvips}{eforms}
\PassOptionsToPackage{dvips}{insdljs}}
\DeclareOption{pdftex}{\def\eq@drivernum{1}%
\def\eq@driver{pdftex}%
\PassOptionsToPackage{pdftex}{\eq@ColorPackage}
\PassOptionsToPackage{pdftex}{eforms}
\PassOptionsToPackage{pdftex}{insdljs}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{dvipdfm}
% Set the driver dependent code for the \texttt{quiz} and \texttt{quiz}
% environments.
% \begin{macrocode}
\DeclareOption{dvipdfm}{\def\eq@drivernum{2}%
\def\eq@driver{dvipdfm}%
\PassOptionsToPackage{dvipdfm}{\eq@ColorPackage}
\PassOptionsToPackage{dvipdfm}{eforms}
\PassOptionsToPackage{dvipdfm}{insdljs}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{textures}
% This option, and testing are due to Ross Moore 3/6/02
% \begin{macrocode}
\DeclareOption{textures}{\def\eq@drivernum{3}%
\def\eq@driver{textures}%
\PassOptionsToPackage{textures}{\eq@ColorPackage}%
\PassOptionsToPackage{textures}{eforms}
\PassOptionsToPackage{textures}{insdljs}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{dviwindo}
% Set \cmd{\eq@noformstrue}, this inserts an \cmd{\endinput} just after
% the end of the |exercise| environment. No quizzes for
% \texttt{dviwindo}.
% \begin{macrocode}
\DeclareOption{dviwindo}{\def\eq@drivernum{4}\def\eq@driver{dviwindo}%
\eq@noformstrue\PassOptionsToPackage{nodljs}{insdljs}}
% \end{macrocode}
% \end{macro}
% If no driver is passed to \textsf{exerquiz}, assume it is
% dvipsone or dvips---\textsf{hyperref} defines the specials.
% Default driver dvipsone/dvips
% \begin{macrocode}
% \def\eq@drivernum{5}
% \def\eq@driver{dvipsone/dvips}
% \def\eq@driver{no driver specified}
% \end{macrocode}
% \subsection{Language Options}
% \textsf{exerquiz} uses many language dependent typeset labels
% and JavaScript messages. These messages are defined in the
% English language in Section~\ref{ss:ldm}. The language options
% defines the macro \cmd{\LangRedefinition} to input language
% dependent redefinitions of these messages. Initially,
% \cmd{\LangRedefinition} is set to relax and no redefinition files
% are input.
% \begin{macrocode}
\let\LangRedefinitions=\relax
% \end{macrocode}
% \begin{macro}{french}
% Translations due to Jean-Michel SARLAT.
% \begin{macrocode}
\DeclareOption{french}{%
\def\LangRedefinitions{\InputIfFileExists{eqfr.def}%
{\typeout{exerquiz: Inputting French Option}}%
{\typeout{exerquiz: French Option: Cannot find the file eqfr.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{german}
% Translation due to Michael Wiedmann.
% \begin{macrocode}
\DeclareOption{german}{%
\def\LangRedefinitions{\InputIfFileExists{eqde.def}%
{\typeout{exerquiz: Inputting German Option}}%
{\typeout{exerquiz: German Option: Kann die Datei eqde.def
nicht finden, benutze Default, Englisch.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{norsk}
% Translation due to Hans Fredrik Nordhaug.
% \begin{macrocode}
\DeclareOption{norsk}{%
\def\LangRedefinitions{\InputIfFileExists{eqno.def}%
{\typeout{exerquiz: Inputting Norsk Option}}%
{\typeout{exerquiz: Norsk Option: Cannot find the file eqno.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{dutch}
% Translation due to Henny Wilbrink
% \begin{macrocode}
\DeclareOption{dutch}{%
\def\LangRedefinitions{\InputIfFileExists{eqnl.def}%
{\typeout{exerquiz: Inputting Dutch Option}}%
{\typeout{exerquiz: Dutch Option: Kan bestand eqnl.def niet vinden,
gebruik default, Engels.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{spanish}
% Translation due to Pedro Luis Luque
% \begin{macrocode}
\DeclareOption{spanish}{%
\def\LangRedefinitions{\InputIfFileExists{eqes.def}%
{\typeout{exerquiz: Inputting Spanish Option}}%
{\typeout{exerquiz: Spanish Option: Opci\'on Espa\~nola: no puede
encontrar el fichero eqes.def, usar\'a por defecto, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{italian}
% Translation due to PierLuigi Zezza
% \begin{macrocode}
\DeclareOption{italian}{%
\def\LangRedefinitions{\InputIfFileExists{eqit.def}%
{\typeout{exerquiz: Opzione Lingua Italiana}}%
{\typeout{exerquiz, Opzione Italiano: Non trovo il file eqit.def,
utilizzo quello di default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{russian}
% Translation due to Sergei V. Znamenskii
% \begin{macrocode}
\DeclareOption{russian}{%
\def\LangRedefinitions{\InputIfFileExists{eqru.def}%
{\typeout{exerquiz: Inputting Russian Option}}%
{\typeout{exerquiz: Russian Option: Cannot find the file eqru.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{dansk}
% Translation due to Erik Leimand
% \begin{macrocode}
\DeclareOption{dansk}{%
\def\LangRedefinitions{\InputIfFileExists{eqda.def}%
{\typeout{exerquiz: Inputting Dansk Option}}%
{\typeout{exerquiz: Dansk Option: Cannot find the file eqda.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{polish}
% Translation due to Jerzy Mycielski
% \begin{macrocode}
\DeclareOption{polish}{%
\def\LangRedefinitions{\InputIfFileExists{eqpo.def}%
{\typeout{exerquiz: Inputting Polish Option}}%
{\typeout{exerquiz: Polish Option: Cannot find the file
eqpo.def, using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{finnish}
% Translation due to Paivi Porras
% \begin{macrocode}
\DeclareOption{finnish}{%
\def\LangRedefinitions{\InputIfFileExists{eqfin.def}%
{\typeout{exerquiz: Inputting Finnish Option}}%
{\typeout{exerquiz: Finnish Option: Cannot find the file eqfin.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{catalan}
% Translation due to Ramon Ballester
% \begin{macrocode}
\DeclareOption{catalan}{%
\def\LangRedefinitions{\InputIfFileExists{eqcat.def}%
{\typeout{exerquiz: Inputting Catalan Option}}%
{\typeout{exerquiz: Catalan Option: Cannot find the file eqcat.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{czech}
% Translation due to Robert Marik
% \begin{macrocode}
\DeclareOption{czech}{%
\def\LangRedefinitions{\InputIfFileExists{eqcz.def}%
{\typeout{exerquiz: Inputting Czech Option}}%
{\typeout{exerquiz: Czech Option: Cannot find the file eqcz.def,
using the default, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{brazil}
% Translation due to Koichi Sameshima
% \begin{macrocode}
\DeclareOption{brazil}{%
\def\LangRedefinitions{\InputIfFileExists{eqbr.def}%
{\typeout{exerquiz: Inputting Brazilian Portuguese Option}}%
{\typeout{exerquiz: Portuguese Option: Opc\~ao Portugu\^es: n\~ao foi poss\'ivel
encontrar o arquivo eqbr.def, usaremos o padr\~ao, English.}}}}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{\eq@ColorPackage}}
\@ifpackageloaded{xcolor}%
{%
\@ifpackagelater{xcolor}{2004/07/04}{}
{%
\PackageError{exerquiz}{%
*************************************************\MessageBreak
* Your Version of `xcolor.sty' is too old!\MessageBreak
* You need the version from 2004/07/04 or newer\MessageBreak
* or use: \string\usepackage[noxcolor]{exerquiz}\MessageBreak
*************************************************}{}%
}%
}{}
% \end{macrocode}
% \subsection{Switches}
% Boolean switches used by the declared options.
% \begin{macrocode}
%\newif\ifpreview \previewfalse
\let\iterate\relax
\newif\ifeq@solutionsafter \eq@solutionsafterfalse
\newif\ifeq@hidesolution \eq@hidesolutionfalse
\newif\ifeq@globalshowsolutions \eq@globalshowsolutionsfalse
\newif\ifeq@nosolutions \eq@nosolutionsfalse
\newif\ifeq@proofing \eq@proofingfalse
\newif\ifeqforpaper \eqforpaperfalse
%
%<*package|eqexam>
%\newif\ifeqforpaper \eqforpaperfalse
\newif\ifeq@noforms \eq@noformsfalse
%\newif\ifeq@nosolutions \eq@nosolutionsfalse
\newif\ifeq@noquizsolutions \eq@noquizsolutionsfalse % dps new
%\newif\ifeq@solutionsafter \eq@solutionsafterfalse
\newif\ifeq@nocorrections \eq@nocorrectionsfalse
%\newif\ifeq@proofing \eq@proofingfalse
\newif\ifeq@nolink \eq@nolinkfalse
%\newif\ifeq@globalshowsolutions \eq@globalshowsolutionsfalse
%\newif\ifeq@hidesolution \eq@hidesolutionfalse
\def\eq@ckglobalhide{\ifeq@globalshowsolutions\eq@hidesolutionfalse\fi}
\def\hidesymbol{h}\def\Hidesymbol{H}
% \end{macrocode}
% When the first solution is written, \cs{therearesolutions} is
% made true. When the solutions are input back into the file, and
% this switch is still false, then no exercise header is typeset;
% this avoids an empty exercise section with only the header.
% \begin{macrocode}
\newif\iftherearesolutions \therearesolutionsfalse
% \end{macrocode}
% \begin{macro}{\SolutionsAfter}
% \begin{macro}{\SolutionsAtEnd}
% Some macros to turn \cs{eq@solutionsafter} on or off
% \begin{macrocode}
\def\SolutionsAfter{\eq@solutionsaftertrue\eq@nolinktrue}
\def\SolutionsAtEnd{\eq@solutionsafterfalse\eq@nolinkfalse}
\def\NoSpaceToWork{\let\eq@insertverticalspace=n}
\def\SpaceToWork{\let\eq@insertverticalspace=y}
\SpaceToWork
%
%<*package>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\CorrectionsOn}
% \begin{macro}{\CorrectionsOff}
% Use these macros to locally turn on or off the inclusion
% of the correction code.
% \begin{macrocode}
\def\CorrectionsOn{\global\eq@nocorrectionsfalse}
\def\CorrectionsOff{\global\eq@nocorrectionstrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Process Options and Require Packages}
% The \texttt{quiz} environments use Acrobat forms and JavaScript
% so we need to load in the AcroForm Dictionary---unless the
% \texttt{dviwindo} (\cmd{\eq@noformstrue}) option is requested.
% \begin{macrocode}
\AtBeginDocument{\ifeq@noforms\else\begin{Form}\fi}
\AtEndDocument
{%
\include@solutions
\ifeq@noforms\else
\include@quizsolutions
\fi
\end{Form}
% \end{macrocode}
% (04/12/07) I put a \cs{clearpage} for some good reason, can't remember, I think
% it had to do with templates, but dvipdfm has problems with this. The document
% level JavaScript are not inserted, they are cleared out by the \cs{clearpage}.
% So, we'll only to a \cs{clearpage} if the driver is not dvipdfm.
% \begin{macrocode}
\if\eq@drivernum2\else\clearpage\fi
}
% \end{macrocode}
% \subsection{Load Configuration File: exerquiz.cfg}
% Look for configuration file, exerquiz.cfg.
%\begin{verbatim}
% \ExecuteOptions{noquizsolutions,nocorrections}
%\end{verbatim}
% sets several options.
% \begin{macrocode}
\InputIfFileExists{exerquiz.cfg}{}{}
% \end{macrocode}
% \begin{macrocode}
\ProcessOptions
%\def\eq@xcolor{xcolor}\ifx\eq@ColorPackage\eq@xcolor
%\def\eq@coloropts{hyperref,table}\else\def\eq@coloropts{}\fi
%\RequirePackage[\eq@coloropts]{\eq@ColorPackage}
\RequirePackage{\eq@ColorPackage}
%\RequirePackage{color}
\RequirePackage{verbatim}
\RequirePackage{hyperref}
\RequirePackage{insdljs}
\RequirePackage{eforms}
% \end{macrocode}
% \begin{macrocode}
\@ifundefined{eq@drivernum}{%
\PackageError{Exerquiz}%
{You have not specified dvips, dvipsone, pdftex or dvipdfm
\MessageBreak in the option list of the exerquiz package}
{Place one of the driver names dvips, dvipsone, pdftex or dvipdfm
\MessageBreak in the option list of the exerquiz package.}
}{}
% \end{macrocode}
% \begin{macrocode}
%
% \end{macrocode}
% \subsection{The Template \& Language dependent messages}\label{ss:ldm}
% The following define labels and messages for the exercise and
% various quiz environments. They are all redefined when a
% language option is used. All of them can be redefined to
% customize a users document.
%
% In attempt to better manage the language localizations, I've placed the
% template for Web and Exerquiz in the Exerquiz.dtx file.
% \begin{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Web.sty %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Language dependent definitions for Web.sty
%<*template>
\DeclareOption{newlanguage}{%
\AtEndOfPackage{%
\def\today{\ifcase\month\or January
\or February \or March \or April
\or May \or June \or July \or August
\or September \or October \or November
\or December \fi \the\day, \the\year}
\def\web@versionlabel{Version}
\def\web@toc{Table of Contents}
\def\web@continued{cont.}
\def\web@article{Begin \hyperlink{section.1}{Article}}
\def\web@directory{Directory}
\def\web@revision{Last Revision Date:}
\def\web@copyright{Copyright}
\def\web@section{Section}
% Label Navibar
\def\web@back{Back}
\def\web@doc{Doc}} % restricted to three characters
\PassOptionsToPackage{newlanguage}{exerquiz}
}
%
% \end{macrocode}
% \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Exerquiz.sty %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\DeclareOption{newlanguage}{%
% \def\LangRedefinitions{\InputIfFileExists{eqlang.def}%
% {\typeout{exerquiz: Inputting a New Language Option}}%
% {\typeout{exerquiz: Language Option: Cannot find the file
% eqpo.def, using the default, English.}}}}
%
%\def\eqretnSymb{$\blacksquare$}%{\rule{6bp}{6.8bp}}
% The exercise label
%\newcommand\exlabel{Exercise}
%\newcommand\exlabelsol{\exlabel}
%% The exercise label
%% Accents: \renewcommand\exlabel{\"Ubung} (German)
%\renewcommand\exlabel{Exercise}
%% The value of this macro is written to \jobname.sol,
%% accented characters must be protected with a \noexpand
%% E.g., \renewcommand\exlabelsol{\noexpand\"Ubung} (German)
%\renewcommand\exlabelsol{\exlabel}
% \end{macrocode}
% \begin{macrocode}
% Title of exercise solution section
%\newcommand\exsectitle{Solutions to \exlabel s}
%\newcommand\exsecrunhead{\exsectitle} %% change to @ form
%
%% Title of exercise solution section
%% E.g.: \renewcommand\exsectitle
%% {L\"osungen der \exlabel en} (German)
%\renewcommand\exsectitle{Solutions to \exlabel s}
%\renewcommand\exsecrunhead{\exsectitle} %% change to @ form
% \end{macrocode}
% \begin{macrocode}
%<*package|eqexam>
% \end{macrocode}
% \begin{macro}{\exsolafter}
% \begin{macro}{\exsolafterDefault}
% \begin{macro}{\renameSolnAfterTo}
% \begin{macro}{\resetSolnAfterToDefault}
%\changes{v6.05g}{2007/01/28}
%{
% Added to commands for use in exerquiz or in eqexam. They are
% \cs{renameSolnAfterTo} for conveniently changing the solution
% after label, and \cs{resetSolnAfterToDefault} for resetting
% back to the default.
%}
% Solution label for solutionafter option for exercise
% \begin{macrocode}
\newcommand{\exsolafter}{\eq@exsolafterDefault}
\newcommand{\eq@exsolafterDefault}{\textit{Solution}:}
\newcommand{\renameSolnAfterTo}[1]{\def\exsolafter{#1}}
\newcommand{\resetSolnAfterToDefault}{\def\exsolafter{\eq@exsolafterDefault}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macrocode}
%
%
%% Solution label for solutionafter option for exercise
%\renewcommand\exsolafter{\textit{Solution}:}
% \end{macrocode}
% \begin{macrocode}
% Title of quiz solution section
%\newcommand\eq@sqslsectitle{Solutions to Quizzes}
%\newcommand\sqslsectitle{\eq@sqslsectitle}
%
%% Title of short quiz solution section
%% Example: \renewcommand\eq@sqslsectitle
%% {L\"osungen der Aufgaben} (German)
%\renewcommand\eq@sqslsectitle{Solutions to Quizzes}
%\renewcommand\sqslsectitle{\eq@sqslsectitle}
% \end{macrocode}
% \begin{macrocode}
% Running header/section title for solutions to short quizzes
%\newcommand\eq@sqslsecrunhead{Solutions to Quizzes}
% User access
%\newcommand\sqslsecrunhead{\eq@sqslsecrunhead}
%
%% Running header/section title for solutions to short quizzes
%\renewcommand\eq@sqslsecrunhead{Solutions to Quizzes}
%% User access
%\renewcommand\sqslsecrunhead{\eq@sqslsecrunhead}
% \end{macrocode}
% \begin{macrocode}
% Label for solutions to quizzes, appears in solutions sections
%\newcommand\eq@sqsllabel{\string\textbf{Solution to Quiz:}}
% User access
%\newcommand\sqsllabel{\eq@sqsllabel}
%
%% Label for solutions to short quizzes, appears
%% in solutions sections
%% Protect accents with \noexpand
%% E.g.: \renewcommand\eq@sqsllabel
%% {\string\textbf{L\noexpand\"osung zu Aufgabe:}} (German)
%\renewcommand\eq@sqsllabel{\string\textbf{Solution to Quiz:}}
%% User access
%\renewcommand\sqsllabel{\eq@sqsllabel}
% \end{macrocode}
% \begin{macrocode}
% Solution label for solutionafter option for shortquiz
%\newcommand\sqsolafter{\textit{Solution}:}
%
%% Solution label for solutionafter option for shortquiz
%\renewcommand\sqsolafter{\textit{Solution}:}
% \end{macrocode}
% \begin{macrocode}
% Here is the default short quiz label.
%\newcommand\eq@sqlabel{\textcolor{red}{Quiz}}
% User access to shortquiz label
%\newcommand\sqlabel{\eq@sqlabel}
%
%% Here is the default short quiz label.
%\renewcommand\eq@sqlabel{\textcolor{red}{Quiz.}}
%% User access to shortquiz label
%\renewcommand\sqlabel{\eq@sqlabel}
% \end{macrocode}
% \begin{macrocode}
% Here is the default short quiz return label
% No formatting allowed
%\newcommand\eq@sqslrtnlabel
% {\ifeq@solutionsafter\else\expandafter\string\fi\eqretnSymb}
% User access to shortquiz label
%\newcommand\sqslrtnlabel{\eq@sqslrtnlabel}
%
%% Here is the default short quiz return label
%% No formatting allowed
%\renewcommand\eq@sqslrtnlabel{End Quiz}
%% User access to shortquiz label
%\renewcommand\sqslrtnlabel{\eq@sqslrtnlabel}
% \end{macrocode}
% \begin{macrocode}
% Short quiz feedback messages
%\newcommand\eqsqrtmsg{"Right!"}
%\newcommand\eqsqwgmsg{"Wrong!"}
%
%% Short quiz feedback messages
%\renewcommand\eq@sqrtmsg{"Right!"}
%\renewcommand\eq@sqwgmsg{"Wrong!"}
% \end{macrocode}
% \begin{macrocode}
% Here is the default quiz label.
%\newcommand\eq@bqlabel{Begin Quiz}
% User access to quiz label
%\newcommand\bqlabel{\eq@bqlabel}
% Used for writing JavaScript Messages on screen
%\newcommand\eq@bqlabelISO{\eq@bqlabel}
%\newcommand\bqlabelISO{\eq@bqlabelISO}
%
%% Here is the default quiz label.
%% No formatting allowed
%% For Example: \renewcommand\eq@bqlabel{D\'ebut} (French)
%\renewcommand\eq@bqlabel{Begin Quiz}
%% User access to shortquiz label
%\renewcommand\bqlabel{\eq@bqlabel}
%% Used for writing JavaScript Messages on screen.
%% Use PDFDocEncoding
%% For Example:
%% \renewcommand\eq@bqlabelISO{D\string\351but} (French)
%% Use \string not \noexpand, this helps out
%% TeX4ht by Eitan Gurari.
%\renewcommand\eq@bqlabelISO{\eq@bqlabel}
%\renewcommand\bqlabelISO{\eq@bqlabel}
% \end{macrocode}
% \begin{macrocode}
% Here is the default quiz label.
% No formatting allowed
%\newcommand\eq@eqlabel{End Quiz}
% User access to shortquiz label
%\newcommand\eqlabel{\eq@eqlabel}
%
%% Here is the default quiz label.
%% No formatting allowed
%\renewcommand\eq@eqlabel{End Quiz}
%% User access to shortquiz label
%\renewcommand\eqlabel{\eq@eqlabel}
% \end{macrocode}
% \begin{macrocode}
% JavaScript Messages for Quiz Environments
%\newcommand\eq@Score{Score:}\newcommand\eq@OutOf{out of}
%\newcommand\eqScore{\eq@Score}\newcommand\eqOutOf{\eq@OutOf}
%
%% JavaScript Messages for Quiz Environments. Use PDFDocEncoding
%% Note: Use \string rather than \noexpand for escape codes,
%% i.e. \string\374
%%
%% In the Text Field showing the score, there is the default
%% phrase in English
%% Score: 2 out of 3, the word "Score" and "out of" needs
%% translation.
%\renewcommand\eq@Score{Score:}\renewcommand\eq@OutOf{out of}
% \end{macrocode}
% \begin{macrocode}
%\newcommand\eqInitQuizMsg{%
% "You must initialize the Quiz! Click on "+msg+"."}
%
%% If you are taking a quiz and click on an alternative without
%% initializing the quiz
%% first, this message appears.
%% This string is placed in the DLJS, so the escape sequences
%% need to be protected more. Instead of \string\340 we need
%% \string\\340.
%% Example: \renewcommand\eqInitQuizMsg{% (German)
%% "Sie m\string\\374ssen die Aufgaben initialisieren!
%% Bitte klicken Sie auf "+msg+"."}
%\renewcommand\eqInitQuizMsg{%
% "You must initialize the Quiz! Click on "+msg+"."}
% \end{macrocode}
% \begin{macrocode}
%\newcommand\eqQuizTotalMsg{%
% "\eqScore\space"+Score+" \eqOutOf\space"+nQuestions}
%\newcommand\eqQuizPointsMsg{%
% "\eqScore\space"+ptScore+" \eqOutOf\space"+nPointTotal}
%\newcommand\eqQuizPercentMsg{pcScore+"\%"}
%\newcommand\eqQuizGradeMsg{quizGrade}
%
%% This macro doesn't usually need translation, it uses \eqScore
%% and \eqOutOf. However, if the sentence "Score: 2 out of 3"
%% does not translate conveniently into a particular language,
%% this macro may have to be modified. It's the one that puts
%% the message in the message box.
%\renewcommand\eqQuizTotalMsg
%% {"\eqScore\space"+Score+" \eqOutOf\space"+nQuestions}
%\renewcommand\eqQuizPointsMsg{%
% "\eqScore\space"+ptScore+" \eqOutOf\space"+nPointTotal}
%\renewcommand\eqQuizPercentMsg{pcScore+"\%"}
%\renewcommand\eqQuizGradeMsg{quizGrade}
% \end{macrocode}
% \begin{macrocode}
%\newcommand\eqMadeChoice{%
% "You have already made a choice.
% Your choice was ("+Responses[probno]+").
% Do you want to change it?"}
%
%% In the link form of a quiz, of you change your choice,
%% this message appears. This string is placed in the
%% DLJS, so the escape sequences need to be protected more.
%% Instead of \string\340 we need \string\\340.
%% For Example: \renewcommand\eqMadeChoice{%
%% "Vous avez d\string\\351j\string\\340 fait un choix,
%% ce choix est ("+Responses[probno]+").
%% Souhaitez vous le modifier ?"} (French)
%\renewcommand\eqMadeChoice{%
% "You have already made a choice.
% Your choice was ("+Responses[probno]+").
% Do you want to change it?"}
% \end{macrocode}
% Default language phrases used by \cmd{\eqButton}. These are overwritten by the
% language options.
% \begin{macrocode}
%\newcommand\eq@local@CA{Correct}
%\newcommand\eq@local@RC{My Answers!}
%\newcommand\eq@local@AC{Please!}
%% Default button labels for \eqButton
%% Accents are handled as above:
%% A French Language Example
%% \renewcommand\eq@local@CA{R\string\351ponses}
%% \renewcommand\eq@local@RC{Correctes}
%% \renewcommand\eq@local@AC{SVP !}
%\renewcommand\eq@local@CA{Correct}
%\renewcommand\eq@local@RC{My Answers!}
%\renewcommand\eq@local@AC{Please!}
% \end{macrocode}
% Default language phrases used by \cmd{\CorrAnsButton}. These are overwritten by the
% language options.
% \begin{macrocode}
%\newcommand\eq@local@CorrAnsButton{Ans}
%
%% Default button label of \CorrAnsButton.
%\renewcommand\eq@local@CorrAnsButton{Ans}
% \end{macrocode}
% The following are (error) messages generated from the math fill-in questions.
% \begin{macrocode}
%<*package>
\newcommand\eqerrABS{"Absolute values not balanced. Please correct."}
\newcommand\eqerrBadMathFunc{"The expression `"+aF[i]+"' is neither a
defined function, nor a valid math expression."}
\newcommand\eqParens{"Parentheses"}
\newcommand\eqBrackets{"Brackets"}
\newcommand\eqBraces{"Braces"}
\newcommand\eqerrDelimNotBal{aGroup[i][2] + " not balanced.
Please correct."}
\newcommand\eqerrBadExp{"Invalid mathematical expression.
A problem with one of the exponents. Please correct."}
\newcommand\eqerrUnfinishQuiz{"There is an unfinished quiz,
please finish before moving on to another."}
\newcommand\noPeekMsg{"Viewing Solutions to quizzes is not allowed
until you take or finish this quiz!"}
\newcommand\highThresholdMsg{"You are required to respond to all
questions before the quiz is evaluated."}
\newcommand\eqSyntaxErrorUndefVar{"Syntax Error: Possibly an undefined
variable present, or an expression is not written in an expected
format."}
%
%
%% These (error) messages are generated when the user enters an
%% invalid math expression into a math fill-in response box.
%% The messages come in the form of an app.alert() so
%% PDFDocEncoding needs to be used.
%<*template>
\renewcommand\eqerrABS{"Absolute values not balanced. Please correct."}
\renewcommand\eqerrBadMathFunc{"The expression `"+aF[i]+"' is neither
a defined " +"function, nor a valid math expression."}
\renewcommand\eqParens{"Parentheses"}
\renewcommand\eqBrackets{"Brackets"}
\renewcommand\eqBraces{"Braces"}
\renewcommand\eqerrDelimNotBal{aGroup[i][2] + " not balanced.
Please correct."}
\renewcommand\eqerrBadExp{"Invalid mathematical expression.
A problem with one of the exponents. Please correct."}
\renewcommand\eqerrUnfinishQuiz{"There is an unfinished quiz,
please finish before moving on to another."}
\renewcommand\noPeekMsg{"Viewing Solutions to quizzes is not allowed
until you take or finish this quiz!"}
\renewcommand\highThresholdMsg{"You are required to respond to all
questions before the quiz is evaluated."}
\renewcommand\eqSyntaxErrorUndefVar{"Syntax Error: Possibly an
undefined variable present."}
%
%<*template>
%%%%%%%%%%%%%%%%%%%%%% End Message Section %%%%%%%%%%%%%
%% Some typeout messages %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In exerquiz.sty
\typeout{Inputting French Option}
\typeout{French Option: Cannot find the file eqfr.def, using the
default, English.}
\typeout{Solutions not allowed with this option}
\typeout{Check: `#1' is not an acceptable option, inserting
default, `check'.}
%
% \end{macrocode}
%
% Announce driver option
% \begin{macrocode}
%<*package>
\typeout{^^Jexerquiz: * Using \eq@driver\space option *^^J}
% \end{macrocode}
% \subsection{Handles, counters and such}
% Handles to write solutions to quizzes and exercises to a file.
% \begin{macrocode}
%
%<*package|eqexam>
\newwrite \ex@solns \immediate\openout \ex@solns \jobname.sol
\newwrite \quiz@solns \immediate\openout \quiz@solns \jobname.qsl
% \end{macrocode}
% Counters to keep track of exercise questions.
% \begin{macrocode}
\newcounter{eqexno} \setcounter{eqexno}{0}
\newcounter{@exno} \setcounter{@exno}{0} % running exno
% \end{macrocode}
% Counter to keep track of quiz questions.
% \begin{macrocode}
\newcounter{quizno} \setcounter{quizno}{0}
\renewcommand\thequizno{\alph{quizno}}
%
%<*package>
\renewcommand\theHquizno{\curr@quiz.\theeqquestionnoi.\alph{quizno}}
%
%<*package|eqexam>
% \end{macrocode}
% Keep track of point values of quizzes
% \begin{macrocode}
\newcounter{eqpointvalue} \setcounter{eqpointvalue}{0}
% \end{macrocode}
% Some scratch registers and boxes.
% \begin{macrocode}
%\newsavebox{\eq@tmpbox} % defined in eqforms
%\newdimen\eq@tmpdima % defined in eqforms
\newlength\eq@tmplength
% \end{macrocode}
% \begin{macro}{eqquestionno}
% The counter that keeps track of the question number. Used by the \texttt{questions }[environment
% \begin{macrocode}
\newcounter{eqquestionnoi}
\newcounter{eqquestionnoii}
\newcounter{eqquestionnoiii}
\newcount\@eqquestiondepth \@eqquestiondepth=0
\newcounter{questionno}
%
%<*package>
\newcounter{grpquestionno}
%
% \end{macrocode}
% \end{macro}
% \begin{macro}{partno}
% This counter keeps track of the parts of an exercise, when the *-option
% is used.
% \begin{macrocode}
%<*package|eqexam>
\newcounter{partno}
\renewcommand\thepartno{\alph{partno}}
%\newcounter{list@partno}
%\renewcommand\thelist@partno{\alph{list@partno}}
% \end{macrocode}
% \end{macro}
% \subsection{Write to a file}
% We must have a way to write the solutions of our exercises and
% quizzes to a file. The following \cmd{\verbatimwrite} was
% taken from the \texttt{moreverb} package, it uses the
% \texttt{verbatim} package.
%
% \begin{macrocode}
\def\verbatimwrite{\@bsphack
\let\do\@makeother\dospecials
\catcode`\^^M\active \catcode`\^^I=12
\def\verbatim@processline{%
\immediate\write\verbatim@out
{\the\verbatim@line}}%
\verbatim@start}
\def\endverbatimwrite{\@esphack}
% \end{macrocode}
% \section{The \texttt{exercise} Environment}
%
% We use \cmd{\raggedright} within a \texttt{tabular} environment,
% so we must use a little trick, illustrated in the \textsl{\LaTeX\
% Companion} by M. Goossens et al. This macro is used with \texttt{exercise}
% with parts, \texttt{shortquiz} and \texttt{quiz} environments.
% \begin{macrocode}
\providecommand\PBS[1]{\let\temp=\\#1\let\\=\temp}
%\newcommand\PBS[1]{\let\temp=\\#1\let\\=\temp}
%
%<*package>
% \end{macrocode}
% Define some formatting commands. These can all be redefined to
% customize the document.
% \begin{macro}{\exlabelformat}
% This is the formatted label for the exercise environment.
% \begin{macrocode}
\newcommand\exlabelformat{{\scshape\exlabel\ \theeqexno.}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\exlabelformatwp}
% This is the formatted label for the exercise environment with parts.
% When an exercises has parts, the word `Exercise' is not a link,
% so we color this word for emphasis.
% \begin{macrocode}
\newcommand\exlabelformatwp{{\scshape\exlabel\ \theeqexno.}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\exsllabelformat}
% This is the formatted solution label.
% \begin{macrocode}
\newcommand\exsllabelformat{\noexpand\textbf{\exlabelsol\ \theeqexno.}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\exsllabelformatwp}
% This is the formatted solution when the *-options is use, that is,
% when there are multiple parts to the question.
% \begin{macrocode}
\newcommand\exsllabelformatwp
{\noexpand\textbf{\exlabelsol\ \theeqexno(\thepartno)}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\exrtnlabelformat}
% This is the formatted return label (return from the solution).
% \begin{macrocode}
\newcommand\exrtnlabelformat{\exlabelsol\ \theeqexno}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\exrtnlabelformat}
% This is the formatted return label (return from the solution),
% for an exercise with parts.
% \begin{macrocode}
\newcommand\exrtnlabelformatwp{$\square$}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqexerskip}
% Amount of skip before and after exercise environment
% \begin{macrocode}
%
%<*package|eqexam>
\newcommand{\eqexerskip}[1]{\def\eq@exerskip{\vskip#1}}
\eqexerskip{\medskipamount}
\newcommand{\priorexskip}[1]{\def\eq@priorexskip{\vspace{#1}}}
\priorexskip{\medskipamount}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqafterexersolnskip}
% Amount of skip after solutions, this one is written to a file, so
% we must protect it from early expansion.
% \begin{macrocode}
\newcommand\eqafterexersolnskip{\string\medskip}
%
%<*package>
% \end{macrocode}
% \end{macro}
% \begin{macro}{\nolinkcolor}
% This is the color to paint the word 'Exercise' with parts;
% or it colors all the 'Exercise's when the nosolutions option
% has been used
% \changes{v6.05a}{2006/05/08}
% {
% Changed \cs{nolinkcolor} into a text fill-in. Now, the command \cs{nolinkcolor}
% fills in \cs{@nolinkcolor}, which holds the named color.
% }
% \begin{macrocode}
\newcommand{\nolinkcolor}[1]{\def\@nolinkcolor{#1}}
\nolinkcolor{blue}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\proofingsymbol}
% \begin{macro}{\proofingsymbolColor}
% Proofing symbol and accompanying color (little green bullet)
% \changes{v6.05b}{2006/05/12}
% {
% added a command to change the color of the proofing symbol
% changed the definition of \cs{proofingsymbol} to a text fillin. This creates the command
% \cs{@proofingsymbol}. Can now control the symbol and the color (through \cs{proofingsymbolColor}
% }
% \begin{macrocode}
\newcommand{\proofingsymbolColor}[1]{\def\@proofingsymbolColor{#1}}
\proofingsymbolColor{webgreen}
\newcommand{\proofingsymbol}[1]{\def\@proofingsymbol{\textcolor{\@proofingsymbolColor}{#1}}}
\proofingsymbol{$\bullet$}
%\newcommand{\proofingsymbol}{\textcolor{\@proofingsymbolColor}{$\bullet$}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Define \texttt{exercise} Environment}
% Defines the \texttt{exercise} environment for writing exercises,
% and solutions. The solutions are written to the file
% \cmd{\jobname.sol}, and input at the end of the file. Hypertext
% links connect the statement of the exercise with its solution.
%
%\smallskip\noindent\textbf{Basic usage}
%\begin{verbatim}
%\begin{exercise}
%The exercise question is posed.
%\begin{solution}
%The solution to exercise goes here.
%\end{solution}
%\end{exercise}
%\end{verbatim}
% These environments should be nested as illustrated above.
%
% The \texttt{exercise} environment has three optional arguments. The syntax
% for an exercise without parts is\dots
%\begin{verbatim}
% \begin{exercise}[][h|H] ...\end{exercise}
%\end{verbatim}%
%
% (1) The value of this first optional argument, \texttt{}, is a counter.
% You can use the \texttt{exercise}
% environment then to create other environments with their own
% counters. A special value of zero (0) for this optional argument,
% means not to associate any counter with the environment. These
% features can be used in combination with the \cs{SolutionsAfter}
% and \cs{SolutionsAtEnd} commands to obtain different effects,
% see the manual for examples
%
% (2) The second optional argument is an `\texttt{h}' or an \texttt{H}, this signals that the
% solution to the exercise should not be written to the \cmd{\jobname.sol}
% file. See manual for examples.
%
% The \texttt{exercise} environment has three optional arguments. The syntax
% for an exercise with parts is\dots
%\begin{verbatim}
% \begin{exercise}[]* ...\end{exercise}
% \begin{exercise*}[] ...\end{exercise*}
%\end{verbatim}%
%
% (1) The value of this first optional argument, \texttt{}, is a counter.
% You can use the \texttt{exercise}
% environment then to create other environments with their own
% counters. A special value of zero (0) for this optional argument,
% means not to associate any counter with the environment. These
% features can be used in combination with the \cs{SolutionsAfter}
% and \cs{SolutionsAtEnd} commands to obtain different effects,
% see the manual for examples
%
% (2) The second argument is a star \texttt{*}. The presence of a * signals
% that this exercise has multiple parts. See the manual for the proper
% syntax.
%
% Beginning with version 6.07, there is now a \texttt{exercise*}
% environment, this is what I should have done originally, but now its
% done. The \texttt{exercise*} signals an exercise with parts. It takes
% one optional parameter, the name of a counter \texttt{} that is to
% be used.
% \begin{macro}{\exerSolnInExtFile}
% With the exercises, you have the option of including them in the main document, or putting them
% in an external document. The \cs{exerSolnsInExtFile} command lets you specify an external file name.
% Just use the \textit{basename}, hyperref will add the extension. If an external file is specified, all
% solution links are changed to links between documents. Usage:
%\begin{verbatim}
%\exerSolnsInExtFile{myExSonls}
%\end{verbatim}
% \begin{macrocode}
\newcommand{\exerSolnsInExtFile}[2][]
{\let\exerSolns@ExtFile=y\gdef\eq@exerSolns@fileName{#2}%
\gdef\exerSolns@ReturnPath{#1}}
\let\exerSolns@ExtFile=n
\def\exerSolns@ReturnPath{}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
%
%<*package|eqexam>
\def\marginparpriorhook{} % used to material before the exercise
\def\marginparafterhook{} % used to material after the exercise
\let\afterlabelhskip=\space
% \end{macrocode}
% Inserted in the header of each exercise solution. May be used for inserting
% addition text or macros in the solution.
% \begin{macrocode}
\let\exersolnheadhook=\@empty
% \end{macrocode}
% \begin{macro}{\eqexheader}
% \begin{macro}{\eqexheader@wrapper}
% \cs{eqexheader} typesets `Exercise xx'. \cs{eqexheader@wrapper} creates a hypertarget
% at the heading. Portions of \cs{eqexheader} is also used by \textsf{eqExam}.
% \begin{macrocode}
\newcommand{\eqexheader}
{%
%
%<*package>
\ifeq@nolink % no link to solution
%
%<*package|eqexam>
\hbox{\color{\@nolinkcolor}\if\exerstar*\exlabelformatwp\else
\exlabelformat\fi}%
%
%<*package>
\else
\if\exerSolns@ExtFile y%
\hbox{\href{\eq@exerSolns@fileName\#ex.\the@exno}%
{\exlabelformat}}%
\else
\hbox{\hyperlink{ex.\the@exno}{\exlabelformat}}%
\fi
\fi
%
%<*package|eqexam>
}
\def\eqexheader@wrapper{\hypertarget{qex.\the@exno}{\eqexheader}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\eqexlisttabheader}
% \cs{eqexlisttabheader} typesets `(a)' when we have exercises with parts.
% Portions are also used by \textsf{eqExam}.
% \begin{macrocode}
\newcommand{\eqexlisttabheader}
{%
%
%<*package>
\ifeq@nolink
%
%<*package|eqexam>
\color{\@nolinkcolor}(\hfil\thepartno\hfil)%
%
%<*package>
\else
\if\exerSolns@ExtFile y%
\href{\eq@exerSolns@fileName\#ex.\the@exno\thepartno}%
{(\hfil\thepartno\hfil)}%
\else
\hyperlink{ex.\the@exno\thepartno}{(\hfil\thepartno\hfil)}%
\fi
\fi
%
%<*package|eqexam>
}
% \end{macrocode}
% \end{macro}
% \begin{environment}{exercise}
% With some of the preliminaries out of the way, we begin the exercise `environment'.
% \begin{macrocode}
\newenvironment{exercise}
{%
\par\eq@priorexskip\noindent%\begingroup % set defaults
\def\eq@argi{eqexno}% % use eqexno counter
% \def\exerstar{x}% % default, no *
\if\eq@exerstarEnv*\def\exerstar{*}\else\def\exerstar{x}\fi % default, no *
\def\currhideopt{x}%
\@ifnextchar[{\exercise@}{%
\if\exerstar*%
\def\eq@next{\@exercise}% was \exercise@@@
\else
\def\eq@next{\exercise@@}%
\fi\eq@next}%
}{\par\global\eq@exerciseheadingtrue\eq@exerskip}
% \@ifnextchar[{\exercise@}{\exercise@@[\eq@argi]}}
\def\exercise@[#1]{\def\eq@arg{#1}%
\if\eq@arg h%
\def\currhideopt{h}%
\eq@hidesolutiontrue\eq@nolinktrue%
\ifeq@globalshowsolutions
\eq@hidesolutionfalse\eq@nolinkfalse
\fi
\def\eq@next{\@exercise}% h, no *, no counter
\else
\if\eq@arg H%
\edef\currhideopt{\Hidesymbol}%
\eq@hidesolutiontrue\eq@nolinktrue%
\ifeq@globalshowsolutions
\eq@hidesolutionfalse\eq@nolinkfalse
\fi
\def\eq@next{\@exercise}% h, no *, no counter
\else
\def\currhideopt{x}%
\if\exerstar*%
\def\eq@next{\def\eq@argi{#1}\@exercise}% was \exercise@@
\else
\def\eq@next{\def\eq@argi{#1}\exercise@@}%
\fi
\fi
\fi
\eq@next}
% \end{macrocode}
% specified counter, test for *
% \begin{macrocode}
\def\exercise@@{\@ifstar{\def\exerstar{*}\@exercise}% was \exercise@@@
{\exercise@@@}}%
% \end{macrocode}
% we have recorded the presence of a star, is there
% another optional argument, h
% \begin{macrocode}
\def\exercise@@@{%
\@ifnextchar[{\exercise@@@@}{\@exercise}}
\def\exercise@@@@[#1]{\def\eq@arg{#1}%
\if\eq@arg h%
\def\currhideopt{h}%
\eq@hidesolutiontrue\eq@nolinktrue
\ifeq@globalshowsolutions
\eq@hidesolutionfalse\eq@nolinkfalse
\fi
\def\eq@next{\@exercise}% h, no *, no counter
\else
\if\eq@arg H%
\edef\currhideopt{\Hidesymbol}%
\eq@hidesolutiontrue\eq@nolinktrue%
\def\eq@next{\@exercise}% h, no *, no counter
\else
\def\currhideopt{x}%
\typeout{The option #1 is not recognized}
\let\eq@next=\relax
\fi
\fi
\eq@next}
% \end{macrocode}
% \begin{macro}{\exerSolnHeader}
% When a solution is written to the .sol file, there is a header line that contains formatting information.
% This command can be redefined as desired. We also introduce to markers, \cs{eqEXt} and \cs{endeqEXt} which
% can be used in any way your imaginations can conjure up. Basically, the mark the beginning and ending of the solution.
% \begin{macrocode}
\newif\ifeq@exerciseheading \eq@exerciseheadingtrue
\newcommand\exerSolnHeader[3]
{%
\ifeqforpaper\else\webnewpage\fi\markright{#1}\par\noindent%
%
%<*package>
\hypertarget{#2}{#3}\relax
%
%<*eqexam>
#3%
%
%<*package|eqexam>
\solnhspace
}
% \end{macrocode}
% These two mark the beginning and end of solution to an exercise.
% \begin{macrocode}
\let\eqEXt=\relax
\let\endeqEXt=\relax
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\let\eq@writeexheader\@empty
\def\@exercise
{%
\let\verbatim@out=\ex@solns
\if\eq@argi0\else\refstepcounter{\eq@argi}\fi\stepcounter{@exno}%
\if\exerstar*% if exercise with parts
\eq@nolinktrue
\else
\if\currhideopt H%
\else
\ifeq@solutionsafter
\eq@nolinktrue % no link to solution
\else
\eq@ckglobalhide %
\ifeq@hidesolution\else
% \end{macrocode}
% Here's where we write the header to the .sol file.
% \begin{macrocode}
\gdef\eq@writeexheader{%
\immediate\write\verbatim@out{\string\eqEXt
\string\exerSolnHeader{\exsecrunhead}{ex.\the@exno}%
{\exsllabelformat}\exersolnheadhook\string\relax}%
}%
\fi
\fi
\fi
\fi
\ifvmode\ifdim\lastskip>\z@
\vskip-\lastskip
\fi\fi
\if\exerstar*%
\let\solution=\solnexer@woparts
\let\endsolution=\endsolnexer@woparts
\let\parts=\exercise@parts
\let\endparts\endexercise@parts
\else
\let\solution=\solnexer@woparts
\let\endsolution=\endsolnexer@woparts
\let\parts=\relax
\let\endparts=\relax
\if\Hidesymbol h\eq@nolinkfalse\ifeq@solutionsafter
\eq@nolinktrue\fi\fi
\fi
% \eq@exerskip
% \end{macrocode}
% Here is where `Exercise' is typeset; the commands \cs{marginparpriorhook} and \cs{marginpartafterhook}
% can be used to insert content in before and after the `Exercise'.
% \begin{macrocode}
\ifeq@exerciseheading
\prior@questionsHook\marginparpriorhook\noindent\eqexheader@wrapper
\afterlabelhskip\marginparafterhook\ignorespaces
\fi
}
% \end{macrocode}
% \end{environment}
% \subsection{Define \texttt{solution} Environment for \texttt{exercise}}
% \begin{macro}{solution}
% This is the \texttt{solution} environment for
% \texttt{exercise}; either start \cmd{\verbatim} or,
% \cmd{\eq@solutionsaftertrue} write the label \cmd{\exsolafter}.
%
% The solution macro for the \texttt{exercise} environment now takes an optional
% argument. This argument must be a vertical skip ( i.e., [1in] ). When the solution
% does not correspond to a tabular multi-part question, a vertical skip
% |\vspace{#1}| is introduced when the \texttt{nosolutions} is in effect and when
% \texttt{solutionsafter} is not. This feature may be useful for constructing
% tests in this space is left for the student to write in the answer; yet, later
% when \texttt{solutionsafter} is true, the solutions appear instead of the vertical
% white space.
% \begin{macrocode}
\let\solnhspace=\space
\def\solnexer@woparts{\def\bLeaveVspace{x}% = no vertical space added
\def\next{\@ifnextchar[{\solnexer@@woparts}%
{\solnexer@@woparts[\null]}}%
\ifx\endparts\endexercise@parts@tabular
\def\next{\solnexer@@@woparts}%
\fi
\next}
\let\eqPriorVspace\@gobble
\def\solnexer@@woparts[#1]{%
\ifx#1\null
\else
\gdef\sameVspace{#1}%
\ifeq@nosolutions
\ifeq@solutionsafter\else
\let\bLeaveVspace=\@empty
\def\leavevspace{%
\ifx\eq@insertverticalspace y\par\eqPriorVspace{#1}%
{\nobreak\parbox[b][#1][t]{\linewidth}{\vfill}}%
\fi
}%
\fi
\fi
\fi
\solnexer@@@woparts
}
\def\solutionsafterSkip{\smallskip}
\def\solnexer@@@woparts
{%
\def\exerwparts@cols{x}%
\let\verbatim@out=\ex@solns
\if\currhideopt H%
\let\procsoln=\comment
\let\endprocsoln=\endcomment
\def\eq@next{\procsoln}%
\else
\eq@ckglobalhide
\ifeq@hidesolution
\let\procsoln=\comment
\let\endprocsoln=\endcomment
\else
\ifx\bLeaveVspace\@empty\leavevspace\fi
\let\procsoln=\verbatimwrite
\let\endprocsoln=\endverbatimwrite
\fi
\def\eq@next{%
\ifeq@solutionsafter
\par\solutionsafterSkip
\noindent\exsolafter\space\ignorespaces
\else
\eq@writeexheader % write the solution header 11/03/05
\global\let\eq@writeexheader\@empty
\global\therearesolutionstrue\expandafter\procsoln
\fi
}%
\fi
\eq@next}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\endsolnexer@woparts}
% Unless \cmd{\eq@solutionsaftertrue}, then \cmd{\endverbitim},
% and write return labels.
% \begin{macrocode}
\def\endsolnexerhook{}
\def\endsolnexerhookaux{}
% \end{macrocode}
% This macro attempts to insert the return link at the end of the
% last paragraph of the solutions, this makes the return label
% look nice, and saves a little space.
% \begin{macrocode}
\def\eq@fititin{\noindent\unskip\nobreak\hfill\penalty50
\hskip2em\hbox{}\nobreak\hfill}
\let\eqfititin=\eq@fititin
%
%<*package>
\def\ReturnTo#1#2{\eq@fititin\hyperlink{#1}{#2}}
\def\xReturnTo#1#2{\eq@fititin\href{#1}{#2}}
%
% \end{macrocode}
% \begin{macro}{\eqExerSolnTrailer}
% The material that follows the solution in the .sol file.
% \begin{macrocode}
%<*package|eqexam>
\newcommand\eqExerSolnTrailer
{%
%
%<*package>
\if\exerSolns@ExtFile y\string\xReturnTo
{\exerSolns@ReturnPath\jobname\#qex.\the@exno}%
\else
\string\ReturnTo{qex.\the@exno}%
\fi
{\hbox{\if\exerstar*\exrtnlabelformatwp\else\exrtnlabelformat\fi}}%
\string\endeqEXt\ifeqforpaper\string\par\eqafterexersolnskip\fi^^J
%
%<*eqexam>
\string\ReturnTo{page.\the\c@page}%
{\hbox{\if\exerstar*\exrtnlabelformatwp\else\exrtnlabelformat\fi}}%
\string\endeqEXt\ifeqforpaper\string\par\eqafterexersolnskip\fi^^J
%
%<*package|eqexam>
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\endsolnexer@woparts
{%
\if\currhideopt H%
\csname endprocsoln\endcsname
\else
\ifeq@solutionsafter
\eq@fititin\hbox{\exrtnlabelformat}%
\else
\endprocsoln
\eq@ckglobalhide
\ifeq@hidesolution\else
\endsolnexerhookaux
% \end{macrocode}
% Here's were we write the trailer for the solution
% \begin{macrocode}
\immediate\write\verbatim@out{\eqExerSolnTrailer}%
\fi
\fi
\fi
\endsolnexerhook}
% \end{macrocode}
% \end{macro}
% \subsection{The \texttt{exercise*} Environment: Exercises with Parts}
% Exercises with parts are enclosed within a \texttt{parts} environment. There are two types
% of parts listing: list-type and tabular-type.
% \begin{environment}{exercise*}
% For the exercise* environment, we set a flag to indicate that the \cs{exerstar}
% has been set in the star environment, the begin the \cs{exercise} and finished with
% \cs{endexercise}.
%\changes{v6.07}{2007/05/05}
%{
% Created the \texttt{exercise*} environment, this is equivalent to the \texttt{*} option of the
% \texttt{exercise} environment. You can use either version, but now, \texttt{exercise*} is preferred.
%}
% \begin{macrocode}
\let\eq@exerstarEnv\relax
\newenvironment{exercise*}{\def\eq@exerstarEnv{*}\exercise}
{\endexercise}
% \end{macrocode}
% \end{environment}
% \begin{macro}{parts}
% Initially, we see if there is an optional argument, if yes, the
% tabular environment is used, the argument is the number of columns
% requested. Otherwise, we use a list environment.
% \begin{macrocode}
\def\exercise@parts{\@@par\ifdim\parskip>\z@\vskip-\parskip\fi
\def\exerwparts@cols{x}\@ifnextchar[%
{\let\endparts=\endexercise@parts@tabular\exercise@parts@tabular@}%
{\let\endparts=\endexercise@parts@list\exercise@parts@list}}
% \end{macrocode}
% \subsubsection{List-type Parts Question}
% This is a redesigned \texttt{list} environment. Meant to be used with the
% \texttt{exercise} environment with the *-option.
% \begin{macrocode}
\def\eq@extralabelsep{0pt}
\newenvironment{exercise@parts@list}
{\settowidth{\eq@tmplength}{\normalfont(d)}%
\eq@nolinkfalse
\begin{list}{\normalfont
\if\Hidesymbol h\eq@nolinkfalse\ifeq@solutionsafter
\eq@nolinktrue\fi\fi
\if\currhideopt H%
\else
\ifeq@solutionsafter
\eq@nolinktrue % no link to solution
\else
\ifeq@nosolutions
\eq@nolinktrue % no link to solution
\else
\eq@ckglobalhide
\ifeq@hidesolution\eq@nolinktrue\else
% \end{macrocode}
% Write the solution header to .sol for list type question.
% \begin{macrocode}
\gdef\eq@writeexheader{%
\immediate\write\verbatim@out{\string\eqEXt
\string\exerSolnHeader{\exsecrunhead}%
{ex.\the@exno\thepartno}{\exsllabelformatwp}\relax}%
}%
\fi
\fi
\fi
\fi
\makebox[\eq@tmplength]{\eqexlisttabheader}%
}{%
\usecounter{partno}%
\setlength{\topsep}{3pt}%
\setlength{\partopsep}{0pt plus 1pt minus 1pt}%
\setlength{\parsep}{0pt}\setlength{\itemindent}{0pt}%
\setlength{\listparindent}{\parindent}%
\settowidth{\labelsep}{\normalfont\ }%
\addtolength{\labelsep}{\eq@extralabelsep}%
\settowidth{\labelwidth}{\normalfont(d)}%
\setlength{\leftmargin}{\labelwidth}%
\addtolength{\leftmargin}{\labelsep}%
\let\eq@item=\item
\def\item{\def\currhideopt{x}\eq@hidesolutionfalse\eq@nolinkfalse%
\@ifnextchar[\@ckhide\eq@item}}%
}{\end{list}}
% \end{macrocode}
% \subsubsection{Tabular-type Parts Question}
% Now for the tabular style of multi-part exercise, the argument
% \#1 is the number of columns requested.
% \begin{macrocode}
\def\exercise@parts@tabular@[#1]{%
\def\exerwparts@cols{#1}\exercise@parts@tabular}
% \end{macrocode}
% Set up the tabular environment, after making a lot of decisions.
% \begin{macrocode}
\newenvironment{exercise@parts@tabular}
{%
\setcounter{partno}{0}%
\settowidth{\eq@tmplength}{\normalfont(d)\ }\sbox{\eq@tmpbox}{(d)}%
\let\eq@item=\item@part@tabular
\def\item{\eq@hidesolutionfalse\eq@nolinkfalse
\@ifnextchar[\@ckhide\eq@item}\eq@nolinkfalse
\eq@tmpdima=\linewidth \divide\eq@tmpdima by\exerwparts@cols
\vskip\partopsep\noindent\normalbaselines\tabcolsep=0pt
\begin{tabular}{*{\exerwparts@cols}{p{\eq@tmpdima}}}%
}{\end{tabular}}
% \end{macrocode}
% Redefine \verb+\item+, could be risky
% \begin{macrocode}
\def\item@part@tabular{\leavevmode\refstepcounter{partno}%
\eq@solutionsafterfalse % no solutionsafter are allowed
\ifeq@solutionsafter
\eq@nolinktrue % no link to solution
\else\ifeq@nosolutions
\eq@nolinktrue % no link to solution
\else
\eq@ckglobalhide
\ifeq@hidesolution\eq@nolinktrue\else
% \end{macrocode}
% Write the solution header to .sol for tabular type question.
% \begin{macrocode}
\gdef\eq@writeexheader{%
\immediate\write\verbatim@out{%
\string\eqEXt\string\exerSolnHeader{\exsecrunhead}%
{ex.\the@exno\thepartno}{\exsllabelformatwp}\relax}%
}%
\fi\fi\fi
\PBS\raggedright
\settowidth{\eq@tmplength}{\normalfont(d)\ }%
\sbox{\eq@tmpbox}{\normalfont(d)}%
\eq@tmpdima=\wd\eq@tmpbox
\addtolength\eq@tmplength{\eq@extralabelsep}%
\hangindent=\eq@tmplength\hangafter=1\relax
\makebox[\eq@tmpdima]{\eqexlisttabheader}\ \ignorespaces
}
% \end{macrocode}
% \begin{macrocode}
\def\@ckhide[#1]{\def\eq@arg{#1}%
\def\currhideopt{x}%
\if\eq@arg H%
\eq@hidesolutiontrue\eq@nolinktrue%
\edef\currhideopt{\Hidesymbol}%
\else
\ifeq@globalshowsolutions\else
\if\eq@arg h%
\eq@hidesolutiontrue\eq@nolinktrue%
\def\currhideopt{h}%
\fi
\fi
\fi
\eq@item
}
% \end{macrocode}
% \end{macro}
% \subsection{Including the \texttt{exercise} Solutions}
% Include solutions to the exercises back into the file. This
% section also handles solutions to quizzes as well. This macro
% was taken from the \TeX book.
% \begin{macro}{\includeexersolutions}
% This macro inserts the solutions to the exercises, if there are
% any solutions. If a user uses this macro to insert the solutions
% elsewhere, \cmd{\include@solutions} is called, then put is to
% \cmd{\relax}.
% \begin{macrocode}
\def\includeexersolutions
{%
%
%<*package>
\if\exerSolns@ExtFile n%
%
%<*package|eqexam>
\include@solutions\let\include@solutions=\relax
%
%<*package>
\fi
%
%<*package|eqexam>
}
% \end{macrocode}
% \end{macro}
% The internal command that insert solutions. This command
% appears at the end of document, where it will insert the
% solutions, unless it has been redefined to \cmd{\relax} by
% \cmd{\includesolutions}.
% \begin{macrocode}
\let\eqsolutionshook\@empty
\let\priorexsectitle\@empty
\let\priorexslinput\@empty
\def\exerSolnsHeadnToc{\section*{\exsectitle}%
\addcontentsline{toc}{section}{\protect\numberline{}\exsectitle}}
\newcommand{\exerSolnInput}
{%
\let\webnewpage=\relax
\immediate\closeout\ex@solns
\ifeq@nosolutions\else
% changed from \exsecrunhead, 6/1/05
\iftherearesolutions\newpage\markright{\exsectitle}%
\ifx\webnewpage\relax
\def\webnewpage{\let\webnewpage=\newpage}%
\fi
\priorexsectitle\exerSolnsHeadnToc\priorexslinput
\input{\jobname.sol}%
\eqsolutionshook
\fi
\fi
}
\def\include@solutions
{%
%
%<*package>
\if\exerSolns@ExtFile n%
%
%<*package|eqexam>
\exerSolnInput
%
%<*package>
\fi
%
%<*package|eqexam>
}
%
%<*package>
% \end{macrocode}
% \section{Early end of input}
% There is no support for the Acrobat Forms features with the
% texttt{dviwindo} option by \textsf{hyperref}; therefore there is
% none here as well. \textsf{dviwindo} can use the
% \texttt{exercise} environment, but not the quizzes, so end here.
% \begin{macrocode}
\ifeq@noforms\endinput\fi
% \end{macrocode}
% Begin the Quiz Part of Exerquiz
% \section{The \texttt{shortquiz} Environment}
% \subsection{The \texttt{questions} Environment}
% The \texttt{questions} environment is used inside the
% \texttt{shortquiz} and \texttt{quiz} environments, though it can
% also be used a stand alone list. Beginning with version 5.5, the \texttt{questions}
% environment can be nested three deep.
% \begin{macro}{questions}
% This is a redesigned \texttt{list} environment.
% \begin{macrocode}
%
%<*package|eqexam>
\newcommand{\prior@questionsHook}{}
\newcommand{\post@questionsHook}{}
\renewcommand{\theeqquestionnoi}{\arabic{eqquestionnoi}}
\newcommand{\labeleqquestionnoi}{\color{blue}\bfseries\theeqquestionnoi.}
\renewcommand{\theeqquestionnoii}{\alph{eqquestionnoii}}
\newcommand{\labeleqquestionnoii}{\color{blue}\bfseries(\theeqquestionnoii)}
\renewcommand{\theeqquestionnoiii}{\roman{eqquestionnoiii}}
\newcommand{\labeleqquestionnoiii}{\color{blue}\bfseries(\theeqquestionnoiii)}
\newenvironment{questions}
{%
\ifnum\@eqquestiondepth>\tw@\@toodeep\else\advance\@eqquestiondepth\@ne\fi
\def\@quesctr{eqquestionno\romannumeral\the\@eqquestiondepth}%
\begin{list}{\prior@questionsHook\gdef\eqPTs{1}\global\let\eqQT=\eq@na%
\makebox[\labelwidth][r]{\normalfont\bfseries\csname label\@quesctr\endcsname}%
\post@questionsHook}%
{\usecounter{\@quesctr}%
% \setcounter{eqpointvalue}{0}%\setcounter{questionno}{0}%
\settowidth{\labelwidth}{\normalfont\bfseries00.\ }%
\setlength{\topsep}{3pt}\setlength{\parsep}{0pt}%
\setlength{\itemindent}{0pt}\setlength{\itemsep}{3pt}%
\setlength{\leftmargin}{\labelwidth}%
% \setlength{\labelsep}{0pt}}%
\settowidth{\labelsep}{\ }}
}{\end{list}}
% \end{macrocode}
% \end{macro}
% \subsection{The \texttt{shortquiz} and \texttt{shortquiz*} Environments}
% This \texttt{shortquiz} environment sets up multiple choice
% questions, with immediate feedback whether the user clicked on the
% right or wrong answer. Solutions to the \texttt{shortquiz} may,
% or may not be included.
% \begin{macro}{shortquiz}
% The shortquiz environment, really just a shell to define the
% \cmd{\Ans} macro and the \texttt{solution} environment that go with
% the \texttt{shortquiz}
% \begin{macrocode}
\def\sq@priorhook{\medskip\noindent}
\def\@shortquizCnt{0}
\def\@sqGenBaseName{eqSqBn\@shortquizCnt}
\newenvironment{shortquiz}
{%
{\count0=\@shortquizCnt\advance\count0by1\relax
\xdef\@shortquizCnt{\the\count0 }}%
\goodbreak\@ifstar{\gdef\sqstar{*}\@shortquiz}
{\gdef\sqstar{}\@shortquiz}%
}{\aeb@endshortquiz}
\newenvironment{shortquiz*}
{%
{\count0=\@shortquizCnt\advance\count0by1\relax
\xdef\@shortquizCnt{\the\count0 }}%
\gdef\sqstar{*}\@shortquiz
}{\aeb@endshortquiz}
\def\@shortquiz{\@ifnextchar[%
{\@@shortquiz}{\@@shortquiz[\@sqGenBaseName]}}
% \end{macrocode}
% \#1: unique name to be used for defining objective style questions.
% Required if there are objective question; use this parameter
% if there are objective questions. Also required if
% using the * option (forms)
% \begin{macrocode}
\def\@@shortquiz[#1]{%\begingroup
\gdef\oField{#1}\gdef\curr@quiz{#1}\gdef\currQuiz{#1}%
\global\let\eqQuizType=s\let\@qzsolndest\@empty
\if\sqstar*\relax
\let\@Ans=\Ans@sq@f
\ifx\oField\@empty
\typeout{^^JExerquiz: Base field name required when using
shortquiz with '*' option}
\typeout{Exerquiz: Assuming link style^^J}
\let\@Ans=\Ans@sq@l
\fi
\else
\let\@Ans=\Ans@sq@l
\fi
\setcounter{questionno}{0}%
\let\answers=\answers@sq
\let\endanswers=\endanswers@sq
\let\manswers=\manswers@sq
\let\endmanswers=\endmanswers@sq
\let\solution=\solution@sq
\let\endsolution=\endsolution@sq
% \end{macrocode}
% Lay down the question header. \cs{sqlabel} defaults to a red ``Quiz''.
% \begin{macrocode}
\sq@priorhook\sqlabel\space\ignorespaces
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aeb@endshortquiz}
% \begin{macro}{\aftershortquizskip}
% We reset the labels to the default in case the author
% of the document has redefined them temporarily. The author can
% avoid this reset, by redefining the global variables.
% \begin{macrocode}
\def\aftershortquizskip{\medskip}
\def\aeb@endshortquiz{\setcounter{quizno}{0}%
\global\let\sqlabel=\eq@sqlabel
\global\let\sqslrtnlabel=\eq@sqslrtnlabel
\global\let\sqsllabel=\eq@sqsllabel
\par\aftershortquizskip%\endgroup
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\sqLinks}
% \begin{macro}{\sqForms}
% (01/01/05) Use these two commands to locally change the style of multiple choice
% questions: link or form.
% \begin{macrocode}
\def\sqLinks{\gdef\sqstar{}}\sqLinks{}
\def\sqForms{\gdef\sqstar{*}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macrocode}
%
%<*package>
% \end{macrocode}
% The \texttt{shortquiz} contains two other environments, each nested inside
% the next: The \texttt{answers} environment and the \texttt{solution}
% environment. The latter environment is optional.
%
% \smallskip\noindent\textbf{Basic Usage for the \texttt{shortquiz} environment}
%\begin{verbatim}
%No solutions included With Solutions
%\begin{shortquiz} \begin{shortquiz}
%The question The question
%\begin{answers} \begin{answers}[qz:mysoln]
%\Ans1 ... &\Ans0 &... &\Ans0 ... \Ans1 ... &\Ans0 &... &\Ans0 ...
%\end{answers} \begin{solution}
%\end{shortquiz} .....
% \end{solution}
% \end{answers}
% \end{shortquiz}
%\end{verbatim}
% To further complicate matters, the \texttt{shortquiz} can be
% used with the \texttt{questions} environment to create a series of
% numbered short question quizzes. See the manual for examples.
% \texttt{solution} environment is defined next.
% \begin{macro}{solution}
% The \texttt{solution} environment does double duty, it is used by both
% the \texttt{shortquiz} and \texttt{quiz} environments.
% The macro \cmd{\solution@sq} is the one that actually does the work
% of \cmd{\solution}: It writes the solutions to the file
% \cmd{\jobname.qsl}. This macro obeys the \texttt{forpaper}
% option. In this case, solutions are separated by a
% \cmd{\medskip} rather then put on a separate page. It also
% obeys the \texttt{solutionsafter} option
% \begin{macrocode}
%
%<*package|eqexam>
\def\solution@sq{\let\eq@next=\relax
\ifx\@qzsolndest\@empty
\typeout{exerquiz: * Solutions unexpected here *}%
\typeout{exerquiz: * Will assume 'solutionsafter' option *}%
\eq@solutionsaftertrue
\fi
\ifeq@solutionsafter
\par\smallskip\noindent
\sqsolafter
\else
\global\therearequizsolutionstrue\let\verbatim@out=\quiz@solns
\immediate\write\verbatim@out{%
% \end{macrocode}
% Mark in the solutions files whether this is a quiz or a shortquiz solution.
% \begin{macrocode}
\ifx\eqQuizType q\string\eqQt\else\string\eqSQt\fi%
\string\quizSolnHeader\ifx\eqQuizType q\ifx\allow@peek n%
[{\curr@quiz}{\currQuizStartPage}]\fi\fi%
{\@qzsolndest}{\sqsllabel}\relax}%
\expandafter\verbatimwrite\fi
}
\def\solutionsAfterSkip{\par\bigskip}
\def\endsolution@sq
{%
\ifeq@solutionsafter
\eq@fititin\hbox{\sqslrtnlabel}\solutionsAfterSkip
\else
\endverbatimwrite
\ifx\@qzsolndest\@empty\else
\immediate\write\verbatim@out{\eqSqSolnTrailer}%
\fi
\fi
\global\let\@qzsolndest=\@empty
}
%
%<*package>
% \end{macrocode}
% \begin{macro}{\saveDest}
% \begin{macro}{\useDest}
% These two macros are used, as needed to save the destination name of a solution, then
% re-emitting it later, just prior to the solution. Useful for grouped questions.
% \begin{macrocode}
\def\saveDest{\xdef\holdDest{\@qzsolndest}}
\def\useDest{\def\@qzsolndest{\holdDest}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macrocode}
%
%<*package|eqexam>
\def\fpAfterSolutionsSkip{\par\medskip}
\newcommand\eqSqSolnTrailer{%
\ifx\eqQuizType q%
\string\ReturnTo{page.\the\c@page}%
{\hbox{\sqslrtnlabel}}\string\endeqQt
\else
\string\ReturnTo{page.\the\c@page}%
{\hbox{\sqslrtnlabel}}\string\endeqSQt
\fi
\ifeqforpaper\string\fpAfterSolutionsSkip\fi^^J%
}
%
%<*package>
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqQt}
% The \cmd{\eqQt} is a marker at the beginning of each quiz
% solution. It takes one argument: 0 if the solution is from a
% short quiz; 1 if the solution is from a quiz. If you want to
% input the \texttt{*.qsl} file and typeset the solutions, separate
% from the generating document, you can redefine this command
% for various purposes, for example, to strip of the shortquiz
% solutions. Here's an example:
%\begin{verbatim}
%\makeatletter
%\renewcommand\eqQt[1]{\ifx#10\expandafter\eqQtSQ\fi}
%\long\def\eqQtSQ#1\ReturnTo{\@gobbletwo}
%\makeatother
%\begin{document}
%\input{mydoc.qsl}
%\end{document}
%\end{verbatim}
%\noindent The default action of \cmd{eqQt} is to do nothing and to eat its argument.
% \begin{macrocode}
%\let\eqQt=\@gobble
%
%<*package|eqexam>
\let\eqSQt=\relax
\let\endeqSQt=\relax
\let\eqQt=\relax
\let\endeqQt=\relax
% \end{macrocode}
% \end{macro}
% \begin{macro}{\quizSolnHeader}
% Each solution begins with \cmd{\quizSolnHeader}. This can be redefined
% for whatever reason. It takes three arguments, one of which is optional.
% \#1 is the \cmd{\noPeek} parameters; \#2 is the named destination to this
% solution; \#3 is the \cmd{\sqsllabel}.
%
% If you want to typeset solutions separately, you could redefine
% \cmd{\quizSolnHeader} as desired, and used in conjunction with
% \cmd{eqQt}.
% \begin{macrocode}
\newcommand\quizSolnHeader[3][]{%
\ifeqforpaper\else\webnewpage\fi\noindent
%
%<*package>
\ifx#1\empty\else\noPeek#1\fi
\hypertarget{#2}{#3}\relax
%
%<*eqexam>
#2%
%
%<*package|eqexam>
\solnhspace
}
%
%<*package>
% \end{macrocode}
% \end{macro}
% \begin{macro}{\NoPeeking}
% \begin{macro}{\AllowPeeking}
% A \texttt{quiz} solution has an additional (optional) feature. If
% \cmd{\NoPeeking} is executed, then an open action is placed on the opening
% page of each solution. This open action simply changes the page back to
% the page of the quiz. This is an attempt at keeping students from ``peeking''
% at the solutions before, or while they are taking a quiz. \cmd{\AllowPeeking}
% is the default.
% \begin{macrocode}
\def\AllowPeeking{\global\let\allow@peek=y}\AllowPeeking
\def\NoPeeking{\global\let\allow@peek=n}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\noPeekAction}
% The default definition of \cmd{quizSolnHeader} contains a macro called
% \cmd{\noPeek}. This is the action that \cmd{\noPeek} performs. The actual
% definition of \cmd{\noPeek} is driver dependent, and is listed elsewhere.
% An open page action will be created with a JavaScript action, which calls
% a DLJS function \texttt{noPeek("\#1",\#2)}. The first parameter is the base
% name of the quiz; the second parameter is the page number the quiz starts from
% (so that we can return to that page when the student tries to view the solution
% when he is not authorized to).
% \begin{macrocode}
\def\noPeekAction#1#2{%
/AA <> >>
}
% \end{macrocode}
% \end{macro}
% \subsection{The \texttt{shortquiz} Solutions}
% When the first solution is written, \cmd{\therearequizsolutions} is
% made true. When the solutions are input back into the file, and
% this switch is still false, then no quiz header is typeset;
% this avoids an empty quiz solutions section with only the header.
% \begin{macrocode}
%
%<*package|eqexam>
\newif\iftherearequizsolutions \therearequizsolutionsfalse
% \end{macrocode}
% \begin{macro}{\includequizsolutions}
% This macro inserts the solutions to the short quizzes, if there are
% any solutions. If a user uses this macro to insert the solutions
% elsewhere, \cmd{\include@quizsolutions} is called, then put is to
% \cmd{\relax}.
% \begin{macrocode}
\def\includequizsolutions
{%
\include@quizsolutions
\let\include@quizsolutions=\relax
}
%
%<*package>
% \end{macrocode}
% \end{macro}
% Commands executed at the beginning of the page of quiz solutions
% \begin{macrocode}
\let\eqqzsolutionshook\@empty
\let\priorsqslsectitle\@empty
\let\priorsqslinput\@empty
\def\quizSolnsHeadnToc{\section*{\sqslsectitle}%
\addcontentsline{toc}{section}{\protect\numberline{}\sqslsectitle}}
\newcommand{\quizSolnInput}
{%
\let\webnewpage=\relax
\immediate\closeout\quiz@solns
\ifeq@noquizsolutions\else
\iftherearequizsolutions\newpage\markright{\eq@sqslsecrunhead}%
\ifx\webnewpage\relax
\def\webnewpage{\let\webnewpage=\newpage}%
\fi
\priorsqslsectitle\quizSolnsHeadnToc\priorsqslinput
\input{\jobname.qsl}\eqqzsolutionshook
\fi
\fi
}
% \end{macrocode}
% The internal command that insert solutions. This command
% appears at the end of document, where it will insert the
% solutions, unless it has been redefined to \cmd{\relax} by
% \cmd{\includequizsolutions}.
% \begin{macrocode}
\def\include@quizsolutions{\quizSolnInput}
% \end{macrocode}
%
% \section{The \texttt{quiz} and \texttt{quiz*} Environments}
%
% In this section we introduce the \texttt{quiz} environment, and all its
% supporting elements.
%
% \subsection{Define the \texttt{quiz} Environment}
%
% \begin{macrocode}
\def\q@priorhook{\par\medskip}
\let\eq@initializeServerSubmit\@empty
% \end{macrocode}
% \begin{macro}{\quiztype}
% \begin{macro}{\defaultquiztype}
% The command \cs{quiztype} can be used to force subsequent quizzes to be link
% style or form style, independent of the environment. Recognized values are
% \texttt{f} and \texttt{l}. Once the override \cs{quiztype} has been used,
% you can recover the default behavior of the quizzes by expanding
% \cs{defaultquiztype}.
% \begin{macrocode}
\newcommand{\quiztype}[1]{\def\@quiztype{#1}}\let\@quiztype\@empty
\newcommand{\defaultquiztype}{\let\@quiztype=\@empty}
% \end{macrocode}
% \end{macro}
% \end{macro}
% begin dps 12/20/03
% \begin{macrocode}
\def\setdefault@Ans{\expandafter\global\expandafter
\let\expandafter\@Ans\expandafter=\csname Ans@\@@quiztype\endcsname
}
% end dps 12/20/03
% \end{macrocode}
% \begin{macro}{\useForms}
% \begin{macro}{\useLinks}
% For multiple choice questions, here we give the option of using a mixture of links
% and forms.
% \begin{macrocode}
% dps 12/20/03
\newcommand\useForms{\let\@Ans=\Ans@f}
\newcommand\useLinks{\let\@Ans=\Ans@l}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{environment}{quiz}
% The \texttt{quiz} environment takes an optional `\texttt*'
% and one required argument. There are two styles of quizzes:
% links or checkboxes. Beginning with v6.08, the use of the \texttt*-option
% is discouraged, use the quiz* environment instead.
%\begin{verbatim}
%\begin{quiz}[*]{}
% ...
%\end{quiz}
%\end{verbatim}
% \begin{itemize}
% \item optional \texttt{*} $=$ use checkboxes, otherwise use links
% \item \texttt{}: required argument $=$ base name of quiz.
% \end{itemize}
% \begin{macrocode}
\newenvironment{quiz}
{\goodbreak\@ifstar{\def\qstar{*}\@quiz*f}{\def\qstar{x}\@quiz*l}}
{\aeb@endquiz}
\def\@quiz*#1#2%
{%
\setcounter{eqpointvalue}{0}\setcounter{questionno}{0}%
\eq@initializeServerSubmit
\global\let\eqQuizType=q\tabcolsep=0pt
\gdef\eqPTs{1}\global\let\eqQT\eq@na
\gdef\quiz@total{#2}\gdef\curr@quiz{#2}%
\gdef\currQuiz{#2}\xdef\currQuizStartPage{\thepage}%
\xdef\aPointType{0}%
\ifx\@quiztype\@empty
\gdef\@@quiztype{#1}%
\else
\xdef\@@quiztype{\@quiztype}%
\fi
\setdefault@Ans
\let\@qzsolndest=\@empty
\let\answers=\answers@q\let\endanswers=\endanswers@q
\let\solution=\solution@sq\let\endsolution=\endsolution@sq
\q@priorhook\eq@beginQuiz\space\ignorespaces
}
% \end{macrocode}
% Here is the end for the \texttt{quiz} and \texttt{quiz*} environments. The
% \cs{eq@prior@endQuiz} can be used for whatever purposes a
% developer wants.
% \begin{macrocode}
\let\eq@prior@endQuiz\@empty
\def\aeb@endquiz
{%
\eq@prior@endQuiz
\eq@endQuiz
\global\let\bqlabel=\eq@bqlabel % reset beginning label to default
\global\let\eqlabel=\eq@eqlabel % reset ending label to default
\global\let\bqlabelISO=\eq@bqlabelISO
}
% \end{macrocode}
% \end{environment}
% \begin{environment}{quiz*}
% This environment is more latexy, \texttt{quiz*} environment is for quizzes with forms. Equivalent
% to \verb!\begin{quiz}*...\end{quiz}!/
% \begin{macrocode}
\newenvironment{quiz*}{\goodbreak\def\qstar{*}\@quiz*f}{\aeb@endquiz}
% \end{macrocode}
% \end{environment}
% \begin{macro}{\Quiz}
% A convenience macro for setting the name of the quiz. This command defines the
% text macro \cs{thisQuiz} which contains the quiz name. Can be used in conjunction
% with \cs{floatQuiz} and \cs{startQuizHere}.
% \changes{v6.05c}{2006/05/19}
% {
% Added a convenience macro for setting the name of the quiz. This command defines the
% text macro \cs{thisQuiz} which contains the quiz name. Can be used in conjunction
% with \cs{floatQuiz} and \cs{startQuizHere}.
% }
%
% \begin{macrocode}
\def\Quiz#1{%
\def\thisQuiz{#1}%
\def\curr@quiz{\thisQuiz}%
\def\currQuiz{\curr@quiz}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\floatQuiz}
% \begin{macro}{\dockQuiz}
% Use \cs{floatQuiz} to create commands \cs{startQuizHere} and \cs{endQuizHere}. These commands expand to the
% `Begin Quiz' button or link (`End Quiz' button or link). But these commands can be placed anywhere before the
% \texttt{quiz} environment (after the \texttt{quiz} environment). Use \cs{dockQuiz} to return to the default behavior of the
% \texttt{quiz} environment.
% \changes{v6.05c}{2006/05/19}
% {
% Added \cs{floatQuiz}, \cs{dockQuiz} and \cs{startQuizHere} to start a quiz in an
% arbitrary place prior to the beginning of the quiz.
% }
%\par\medskip\noindent Usage:
%\begin{verbatim}
%\Quiz{myQuiz}
%\floatQuiz
%........
%\begin{center}
%\startQuizHere
%\end{center}
%....
%\begin{quiz*}{\thisQuiz}
%....
%\end{quiz*}
%....
%\endQuizHere
% ...
%\docQuiz
%\begin{quiz}{anotherQuiz}
%....
%\end{verbatim}
% \begin{macrocode}
\def\noindgobble{\noindent\@gobbletwo}
\let\startQuizHere\relax
\let\endQuizHere\relax
\let\dockQuiz\relax
\newcommand\floatQuiz{%
\global\let\eq@beginQuiz@saved\eq@beginQuiz
\global\let\eq@endQuiz@saved\eq@endQuiz
\global\let\startQuizHere\eq@beginQuiz
\global\let\endQuizHere\eq@endQuiz
\global\let\eq@beginQuiz\noindgobble
\global\let\eq@endQuiz\@empty
\global\let\dockQuiz\eq@dockQuiz
}
\newcommand\eq@dockQuiz{%
\global\let\eq@beginQuiz\eq@beginQuiz@saved
\global\let\eq@endQuiz\eq@endQuiz@saved
\global\let\startQuizHere\relax
\global\let\endQuizHere\relax
\global\let\eq@beginQuiz@saved\relax
\global\let\eq@endQuiz@saved
\global\let\dockQuiz\relax
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Begin/End Quiz with Link or Buttons}
%
% Redefine this macro to \cmd{\eq@BeginQuizButton} to get a form button
% for the \texttt{quiz} environment. Pressing on the link or button
% initializes the quiz. The default is `link': \cmd{\eq@BeginQuizLink}.
% \begin{macrocode}
\newcommand\eq@beginQuiz{\eq@BeginQuizLink}
% \end{macrocode}
% Redefine this macro to |\eq@EndQuizButton| to get a form button
% for the \texttt{quiz} environment. Pressing on the link or button
% will score the quiz. The default is `link': |\eq@EndQuizLink|.
% \begin{macrocode}
\newcommand\eq@endQuiz{\eq@EndQuizLink}
% \end{macrocode}
% \begin{macro}{\useBeginQuizButton}
% Use a button instead of a link for begin quiz
% \begin{macrocode}
\newcommand\useBeginQuizButton[1][]
{\renewcommand\eq@beginQuiz{\eq@BeginQuizButton[#1]}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\useEndQuizButton}
% Use a button instead of a link for end quiz
% \begin{macrocode}
\newcommand\useEndQuizButton[1][]
{\renewcommand\eq@endQuiz{\eq@EndQuizButton[#1]}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\useBeginQuizLink}
% Use a link begin quiz (the default)
% \begin{macrocode}
\newcommand\useBeginQuizLink
{\renewcommand\eq@beginQuiz{\eq@BeginQuizLink}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\useEndQuizLink}
% Use a link end quiz (the default)
% \begin{macrocode}
\newcommand\useEndQuizLink
{\renewcommand\eq@endQuiz{\eq@EndQuizLink}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@initQuiz}
% \begin{macro}{\priorInitQuiz}
% \begin{macro}{\postInitQuiz}
% \cs{@initQuiz} is executed when you click on `Begin Quiz'. Included here are some
% macro hooks for insert code prior to, and after the quiz initialization. This
% command appears in the commands \cs{eq@@BeginQuizLinkActions} and \cs{eq@@BeginQuizButtonActions} below.
% \begin{macrocode}
\newcommand\@initQuiz
{InitializeQuiz("\curr@quiz",\ifeq@nocorrections0\else1\fi);\jsR
var \curr@quiz = new Object();\jsR
\curr@quiz.oAlertCheck = { bAfterValue: false };\jsR
\curr@quiz.Grp = {};\jsR
}
% \end{macrocode}
% \cs{priorInitQuiz} and \cs{postInitQuiz} are hooks that allow a document author to
% execute JavaScript just prior to submittal and just after. These appear in
% \cs{eq@@BeginQuizLinkActions} and \cs{eq@@BeginQuizButtonActions} below.
% \begin{macrocode}
\newcommand{\priorInitQuiz}{}
\newcommand{\postInitQuiz}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% Here are a couple of macros used with `End Quiz', and are used for
% submitting quiz results to a web server.
% \begin{macrocode}
\let\eq@submitURL=\@empty
\let\eq@insertHiddenFields=\@empty
% \end{macrocode}
%
% \subsubsection{With Links}
%
% \begin{macro}{\eq@BeginQuizLink}
% Begin quiz with links
% \begin{macrocode}
\def\eq@@BeginQuizLinkActions
{%
\A{\JS{%
\priorInitQuiz
\@initQuiz
\postInitQuiz}}%
}
\def\eq@BeginQuizLinkDefaults{\Border{0 0 0}}
\def\eq@BeginQuizLink
{%
\set@@Link{}{}{}{\color{\@linkcolor}\bqlabel}{}%
{\eq@setWidgetProps\setLink@driver}%
{\eq@BeginQuizLinkDefaults\eq@@BeginQuizLinkActions\every@Link}%
\space\ignorespaces
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eq@EndQuizLink}
% Code the the link version of `End Quiz'.
% \begin{macrocode}
\newcommand\priorSubmitQuiz{}
\newcommand\postSubmitQuiz{}
\def\eq@@EndQuizLinkActions
{%
\A{\JS{%
if (!isQuizInitialized("\curr@quiz"))\jsR\jsT
app.alert(InitMsg("\bqlabelISO"),3);\jsR
else {\jsR\jsT
if (\minQuizResp(\thequestionno)) {\jsR\jsT\jsT
DisplayQuizResults("\curr@quiz",\theeqpointvalue,%
\thequestionno);\jsR\jsT\jsT
\eq@submitURL
\postSubmitQuiz
resetQuiz("\curr@quiz");\jsR\jsT
}\jsR
}}}%
}
\def\eq@EndQuizLinkDefaults{\Border{0 0 0}}
\def\eq@EndQuizLink
{%
\ifx\eq@CGI\@empty
\let\eq@submitURL=\@empty
\let\eq@insertHiddenFields=\@empty
\fi
\set@@Link{}{}{}{\color{\@linkcolor}\eqlabel}{}%
{\eq@setWidgetProps\setLink@driver}%
{\eq@EndQuizLinkDefaults\eq@@EndQuizLinkActions\every@Link}%
\makebox[0pt][r]{\eq@insertHiddenFields}\gdef\eq@CGI{}%
\ignorespaces
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{With Buttons}
%
% \begin{macro}{\eq@BeginQuizButton}
% This is the button when the user wants button rather than link for the
% \texttt{quiz} environment.
% \begin{macrocode}
\def\eq@BeginQuizButtonDefaults
{%
\CA{\bqlabel}\RC{\bqlabel}\AC{\bqlabel}\H{P}\F{\FPrint}
\BC{1 0 0}\BG{.7529 .7529 .7529}\W{1}\S{B}
}
\def\eq@@BeginQuizButtonActions
{%
\A{\JS{%
\priorInitQuiz
\@initQuiz
\postInitQuiz}%
}%
}
\newcommand\eq@BeginQuizButton[1][]
{%
\push@@Button{#1}{beginQuiz.\curr@quiz}{}{\DefaultHeightOfWidget}%
{\eq@protect\A}{\eq@setButtonProps\eq@Button@driver}%
{\eq@BeginQuizButtonDefaults\eq@@BeginQuizButtonActions\every@ButtonField
\every@BeginQuizButton}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eq@EndQuizButton}
% The `End Quiz' code for Links
% \begin{macrocode}
\def\eq@EndQuizButtonDefaults
{%
\CA{\eqlabel}\RC{\eqlabel}\AC{\eqlabel}\F{\FPrint}
\BC{1 0 0}\BG{.7529 .7529 .7529}\W{1}\S{B}\H{P}
}
\def\eq@@EndQuizButtonActions
{%
\A{\JS
{if (!isQuizInitialized("\curr@quiz"))\jsR\jsT
app.alert(InitMsg("\bqlabelISO"),3);\jsR
else {\jsR\jsT
if (\minQuizResp(\thequestionno)) {\jsR\jsT\jsT
DisplayQuizResults("\curr@quiz",\theeqpointvalue,%
\thequestionno);\jsR\jsT\jsT
\eq@submitURL
\postSubmitQuiz
resetQuiz("\curr@quiz");\jsR\jsT
}\jsR
}}%
}
}
\newcommand\eq@EndQuizButton[1][]
{%
\ifx\eq@CGI\@empty
\let\eq@submitURL=\@empty
\let\eq@insertHiddenFields=\@empty
\fi
\push@@Button{#1}{endQuiz.\curr@quiz}{}{\DefaultHeightOfWidget}%
{\eq@protect\A}{\eq@setButtonProps\eq@Button@driver}%
{\eq@EndQuizButtonDefaults\eq@@EndQuizButtonActions\every@ButtonField
\every@EndQuizButton}%
\makebox[0pt][r]{\eq@insertHiddenFields}\gdef\eq@CGI{}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\databaseName}
% \begin{macro}{\tableName}
% \begin{macro}{\eqCGI}
% \begin{macro}{\eqSubmit}
% These four commands give general support for submitting quiz data
% to a web server for storage in a database. Use in my \textsf{eq2db} Package
% which I have not completed yet.
% \begin{macrocode}
\newcommand\databaseName[1]{\def\db@Name{#1}}\def\db@Name{}
\newcommand\tableName[1]{\def\db@Table{#1}}\def\db@Table{}
\newcommand\eqCGI[1]{\def\eq@CGI{#1}}\def\eq@CGI{}
\newcommand\eqSubmit[3]{\eqCGI{"#1"}\databaseName{#2}\tableName{#3}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% The next two commands are used in the \textsf{eq2db} package. We make the
% definitions here so that they can be used even if the package is not loaded.
% In this way, a self-contained quiz can be submitted just by loading the
% package.
% \begin{macrocode}
\newcommand\addHiddenTextField[3][]{}
\newcommand\populateHiddenField[2]{}
% \end{macrocode}
% \subsection{Correcting the Quiz}
%
% \begin{macro}{\eqButton}
% Use this button to correct the quiz. Can be customize with
% optional arguments.
% section.
%\begin{verbatim}
% #1 = optional attributes of button
% #2 = title of textfield that contains the score.
%\end{verbatim}
% \begin{macrocode}
\def\eqButtonDefaults
{%
\CA{\eq@local@CA}\RC{\eq@local@RC}
\AC{\eq@local@AC}\H{P}\W{1}\S{B}
\BC{1 0 0}\BG{.7529 .7529 .7529}
}
\def\@@eqButtonActions
{%
\A{\JS{if (isEndQuizPushed("\eqBaseName"))\jsR\jsT
correctQuiz("\eqBaseName",\thequestionno);}%
}%
}
\newcommand\eqButton[2][]
{%
% \end{macrocode}
% If nocorrections is true, then this button does not appear.
% \begin{macrocode}
\ifeq@nocorrections\else
\medskip\def\eqBaseName{#2}%
\push@@Button{#1}{correct.#2}{}{\DefaultHeightOfWidget}%
{\eq@protect\A}{\eq@setButtonProps\eq@Button@driver}%
{\eqButtonDefaults\@@eqButtonActions\every@ButtonField
\every@eqButton}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Measuring Quiz Results}
%
% \begin{macro}{\minQuizResp}
% Define the threshold level. The two permissible values are \texttt{lowTreshold}
% and \texttt{highThreshold}. These are names of DLJS. New threshold functions
% can be defined and specified.
% \begin{macrocode}
\newcommand\minQuizResp{lowThreshold}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\PTs}
% Use this macro to assign weights to the quiz questions. Use only within
% the \texttt{questions} environment, just after an \cmd{\item}. If
% \cmd{\PTs} does not appear, then a weight of $1$ is assumed.
%\par\noindent|#1 = number of points for the current question.|
% \begin{macrocode}
\newcommand\PTs{%
\@ifstar{\def\eq@star{*}\@PTs}{\def\eq@star{x}\@PTs}%
}
\def\@PTs#1{%
\gdef\eq@PTs{#1}\ifx\eq@PTs\@empty\gdef\eq@PTs{1}\fi
\global\let\eqPTs=\eq@PTs\global\let\eq@PTs=\@empty
\if\eq@star*\else\PTs@Hook\fi
}
\def\eq@PTs{0} % initialize this variable
% begin dps 12/20/03
% \end{macrocode}
% \begin{macro}{\QT}
% \cs{QT} is used for entering the ``question type'' for the question (optional).
% This question type is entered into the ``\texttt{tagged}'' data, and is meant to be
% used for classifying and in tracking the problem types. Example: \verb+\QT{limits}+.
% \begin{macrocode}
\newcommand\QT[1]
{%
\gdef\eq@qT{#1}\ifx\eq@qT\@empty\global\let\eq@qT=\eq@na\fi% not applicable
\global\let\eqQT=\eq@qT\global\let\eq@qT=\eq@na
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\eq@na{na} % not applicable
\let\eq@qT=\eq@na
% end dps 12/20/03
% \end{macrocode}
% \end{macro}
% \begin{macro}{\PTsHook}
% Used to typeset the number of points.
% \begin{macrocode}
\newcommand\PTsHook[1]{\def\PTs@Hook{#1}}
\let\PTs@Hook=\@empty
\let\eq@PTs=\@empty
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqGradeScale}
% This is an array of letter grades and grade ranges. This macro is use as the argument
% of the JS function \texttt{GetGrade}.
% \begin{macrocode}
\newcommand\eqGradeScale{%
"A",[90, 100],"B",[80,90],"C",[70,80],"D",[60,70],"F",[0,60]}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ScoreField}
% This text field will receive the scores
% of a quiz. The command \cmd{\eqScore} was defined
% in Section~\ref{ss:ldm}. This command takes an optional
% argument and a required argument.
%\begin{verbatim}
%#1 = one or more commands that will customize the design of the
% field. See the manual for examples.
%#2 = Base name of the quiz
%\end{verbatim}
% \begin{macrocode}
\def\ScoreFieldDefaults
{%
\Ff{\FfReadOnly}\BC{1 0 0}\BG{}\S{N}
\DV{\eqScore}\V{\eqScore}
}
\newcommand\ScoreField[2][]
{%
\medskip\text@@Field{#1}{ScoreField.#2}{\SFW}%
{\DefaultHeightOfWidget}{}{\eq@setWidgetProps\eq@TextField}%
{\ScoreFieldDefaults\every@eqTextField\every@ScoreField}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\GradeField}
% This command creates a text field that shows the letter grade of the user's
% effort on the current quiz.
% \begin{macrocode}
\def\GradeFieldDefaults
{%
\textColor{0 0 1 rg}
\BC{1 0 0}\BG{1 1 1}\S{N}
\Ff{\FfReadOnly}\Q{1}
}
\newcommand\GradeField[2][]
{%
\medskip\text@@Field{#1}{GradeField.#2}{20bp}%
{\DefaultHeightOfWidget}{}{\eq@setWidgetProps\eq@TextField}%
{\GradeFieldDefaults\every@eqTextField\every@GradeField}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\AnswerField}
% This command creates a text field to receive the answers to the
% fill-in questions.
% \begin{macrocode}
\def\AnswerFieldDefaults
{%
\BC{0 0 0}\S{N}\Ff{\FfReadOnly}
}
\newcommand\AnswerField[2][]
{%
\text@@Field{#1}{Ans.#2}{\RBW}{\DefaultHeightOfWidget}%
{}{\eq@setWidgetProps\eq@TextField}%
{\AnswerFieldDefaults\every@eqTextField\every@AnswerField}%
}
% \end{macrocode}
% \end{macro}
% Now let's define some additional text fields for the quiz environment.
% \begin{macro}{\PointsField}
% This command creates a text field which displays the number of points in the
% quiz scored by the user of the \texttt{quiz}.
% \begin{macrocode}
\def\PointsFieldDefaults
{%
\rawPDF{}\BC{1 0 0}\BG{}\S{N}\Ff{\FfReadOnly}
}
\newcommand\PointsField[2][]
{%
\medskip\text@@Field{#1}{PointsField.#2}{\SFW}%
{\DefaultHeightOfWidget}{}{\eq@setWidgetProps\eq@TextField}%
{\PointsFieldDefaults\every@eqTextField\every@PointsField}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\PercentField}
% This command creates a text field which displays user's score in percent
% form.
% \begin{macrocode}
\def\PercentFieldDefaults
{%
\rawPDF{}\BC{1 0 0}\BG{}\S{N}\Ff{\FfReadOnly}%
}
\newcommand\PercentField[2][]
{%
\medskip\text@@Field{#1}{PercentField.#2}{\SFW}%
{\DefaultHeightOfWidget}{}{\eq@setWidgetProps\eq@TextField}%
{\PercentFieldDefaults\every@eqTextField\every@PercentField}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\RestoreScoreField}
% Reset the score field to its default, in case some author
% changed things.
% \begin{macrocode}
\newcommand\RestoreScoreField
{%
\global\let\eqScore=\eq@Score
\global\let\eqOutOf=\eq@OutOf
}
% \end{macrocode}
% \end{macro}
%
% \section{Multiple Choice Alternatives}
% \subsection{For \texttt{shortquiz}}
% \subsubsection{The \texttt{answers} Environment}
% \begin{macro}{\answers}
% The alternatives of a multiple choice question are enclosed in
% the \texttt{answers} environment.
% This environment takes an optional argument, and one
% required argument. The required parameter is the number of
% columns to construct in the underlying \texttt{tabular}
% environment; the presence of the optional argument means the author
% wants to include the solution to this quiz question. The value of
% the optional parameter is the named destination of the solution.
% The optional parameter for the named destination can also be a
% `\texttt*', in which case a name of \texttt{\string\curr@quiz.\string\thequestionno}
% is assigned.
% \begin{macrocode}
%
%<*package|eqexam>
\def\answers@sq{\stepcounter{questionno}%
\if\sqstar*\relax\let\@Ans=\Ans@sq@f\else\let\@Ans=\Ans@sq@l\fi
\def\answerType{r}%
\@ifnextchar[{\answers@@sq}%
{\@ifstar{\answers@@sq[\curr@quiz.\thequestionno]}{\answers@@sq[]}}}
% dps 4/16/05
\def\manswers@sq{\stepcounter{questionno}%
\if\sqstar*\relax\let\@Ans=\Ans@ck@sq@f\else\let\@Ans=\Ans@ck@sq@l\fi
\def\answerType{c}%
\@ifnextchar[{\answers@@sq}%
{\@ifstar{\answers@@sq[\curr@quiz.\thequestionno]}{\answers@@sq[]}}}
% \end{macrocode}
% \end{macro}
%\begin{verbatim}
% #1 = named destination to be associated with solution
% #2 = number of columns in the tabular environment
%\end{verbatim}
% If the number of columns specified, then we use a list environment.
% \begin{macrocode}
\let\sq@hwdest=\@empty % hard-wired destination
\def\answers@@sq[#1]#2{%
\gdef\numCols{#2}%
\ifx\sq@hwdest\@empty
\xdef\@qzsolndest{#1}%
\else
\gdef\@qzsolndest{\sq@hwdest}%
\fi
\ifx#21\gdef\eq@listType{1}\expandafter\answers@sq@list\else
\gdef\eq@listType{0}\expandafter\answers@@sq@tabular\fi{#2}%
}
% \end{macrocode}
% \begin{macro}{\setMClabelsep}
% \changes{v6.05e}{2006/18/06 v6.05e}
% {
% Added control over the separation between the MC label and subsequent text:
% \cs{setMClabelsep} and \cs{resetMClabelsep}.
% }
% \begin{macro}{\resetMClabelsep}
% \begin{macro}{\eq@hspanner}
% \begin{macro}{\eq@hspanner@default}
% Some convenience macros for computing the width of labels. The command \cs{setMClabelsep}
% can be used to set the separation between the MC label and the beginning of text. The
% argument for this command is anything that takes up horizontal space. The command sets
% the value of \cs{eq@hspanner}. The default value % of the separation is given by \cs{eq@hspanner@default}.
% The default value can be restored by executing \cs{resetMClabelsep}.
% \begin{macrocode}
\def\eq@hspanner{\ }
\def\eq@hspanner@default{\ }
\def\eq@lw@l{\eq@l@l\eq@hspanner}
\def\setMClabelsep#1{\def\eq@hspanner{#1}}
\def\resetMClabelsep{\let\eq@hspanner\eq@hspanner@default}
% \end{macrocode}
% For the link-style MC question, the default width, \cs{eq@l@l}, of the label is the normalsize width of
% `(d)'. For a form checkbox or radiobutton bux, the default width, cs{eq@lw@f}, is \cs{RadioFieldSize},
% normally defined as \texttt{11bp}.
% \begin{macrocode}
\def\eq@l@l{\normalsize\normalfont(d)}
\def\eq@lw@f{\kern\RadioFieldSize\eq@hspanner}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% This macro will pick up the 0 (false) or 1 (true) of the \cs{Ans} command.
% \begin{macrocode}
%\newcommand\Ans@list[2][0]{\gdef\eq@pPTs{#1}%
% \xdef\Ans@choice{#2}\item\relax}
\newcommand\Ans@list[2][0]{\gdef\eq@pPTs{#1}%
\xdef\Ans@choice{#2}\item\relax\if\eq@listType1%
\addtocounter{quizno}{-1}\refstepcounter{quizno}\fi}
% \end{macrocode}
% Answers environment for a list environment.
% \begin{macrocode}
\newenvironment{answers@sq@list}[1]
{%
\if\answerType r
\let\endanswers=\endanswers@sq@list
\else
\let\endmanswers=\endanswers@sq@list
\fi
\vskip\aboveanswersSkip
\begin{list}{\strut\@Ans}%\begin{list}{\strut\@Ans\ }
{%
% \usecounter{list@partno}%
\if\sqstar*\relax
\settowidth{\labelwidth}{\eq@lw@f}%
\else
\settowidth{\labelwidth}{\eq@lw@l}%
\fi
\setlength{\parsep}{0pt}\setlength{\itemindent}{0pt}%
\setlength{\topsep}{0pt}\setlength{\partopsep}{0pt}%
\setlength{\listparindent}{\parindent}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{0pt}%
\def\Ans{\Ans@list}%
% \def\Ans{\item\relax\eq@Ans}%
}%
}%
{\end{list}\setcounter{quizno}{0}}
% \end{macrocode}
% Answers environment for a tabular environment.
% \begin{macrocode}
\newcommand\Ans@tabular[2][0]{\gdef\eq@pPTs{#1}%
\xdef\Ans@choice{#2}\leavevmode\@Ans
}
\def\answers@@sq@tabular#1{%
\vskip\aboveanswersSkip\noindent\tabcolsep=0pt
\eq@tmpdima=\linewidth \divide \eq@tmpdima by#1 %
\def\Ans{\Ans@tabular}%
\begin{tabular}{*{#1}{p{\eq@tmpdima}}}}%
% \end{macrocode}
% \begin{macro}{\endanswers}
% Close off \texttt{tabular} environment, and reinitialize the
% \texttt{quizno} counter.
% \begin{macrocode}
\def\endanswers@sq{\end{tabular}\setcounter{quizno}{0}}%
\def\endmanswers@sq{\end{tabular}\setcounter{quizno}{0}}%
\def\popiiictm{\special{CTM: pop pop pop}}
%
%<*package>
% \end{macrocode}
% \end{macro}
% \subsubsection{Link Style}
% \begin{macro}{\Ans@sq@l}
% For the link multiple choice type question. The driver independent stuff starts
% here, then goes to |\Ans@sq@l@driver| the rest of the code that depends on the
% driver.
% \begin{macrocode}
%\def\sqWrongRespJS{app.alert(\eqsqwgmsg,3);}
%\def\sqRightRespJS{app.alert(\eqsqrtmsg,3);}
\def\sqWrongRespJS{OnBlurRespBox( false, "\oField" );}
\def\sqRightRespJS{OnBlurRespBox( true, "\oField" );}
\def\Ans@sq@l@Actions
{%
\A{\if\Ans@choice1
\JS{\sqRightRespJS}
\ifx\@qzsolndest\@empty\else
\ifeq@solutionsafter\else
/Next <>
\fi
\fi
\else
\JS{\sqWrongRespJS\jsR
\ifx\oField\@empty\else
updateTally("\oField.\thequestionno");
\fi}%
\fi
}%
}
\def\linkContentFormat{\alph{quizno}}
%
%<*eqexam>
\def\linkContentFormat{%
\if\probstar*\arabic{quizno}\else\alph{quizno}\fi}
%
%<*package|eqexam>
%\def\linkContentFormat{\alph{quizno}}
\def\linkContentWrapper{(\hfil\linkContentFormat\hfil)}%
\def\Ans@sq@l{%
\leavevmode\if\eq@listType1\stepcounter{quizno}%
\else\refstepcounter{quizno}\fi\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@l}\sbox{\eq@tmpbox}{\eq@l@l}%
\eq@tmpdima=\wd\eq@tmpbox
\def\link@@Content{\linkContentWrapper}%
\hangindent=\eq@tmplength\hangafter=1\relax
%
%<*eqexam>
\Ans@sq@l@driver
%
%<*package>
\set@@Link{}{}{}%
{\makebox[\eq@tmpdima]{\color{\@linkcolor}\link@@Content}}%
{\eq@protect\A}{\eq@setWidgetProps\setLink@driver}%
{\set@LinkTextDefaults\Ans@sq@l@Actions\every@Link}%
\Ans@proofing{\eq@tmpdima}%
%
%<*package|eqexam>
\eq@hspanner\ignorespaces}
%
%<*package>
% \begin{macro}{\Ans@ck@sq@l}
% Created in support of eqExam to give multiple selection for the
% online and email options. Otherwise, it defaults to a radio button field.
% \begin{macrocode}
%
%<*package|eqexam>
% dps 4/16/05
\let\Ans@ck@sq@l=\Ans@sq@l
%
%<*package>
% \end{macrocode}
% \end{macro}
% \subsubsection{Form Style}
% \begin{macro}{\Ans@sq@f}
% For the link multiple choice type question. The driver independent stuff starts
% here, then goes to |\Ans@sq@f@driver| the rest of the code that depends on the
% driver.
% \begin{macrocode}
\def\@@Ans@sq@f@Defaults
{%
\BC{0 0 0}\Ff{\FfNoToggleToOff}
\textSize{12}\textColor{0 g}
}
% \end{macrocode}
% For short quizzes, refine the type of responses: turn off the alert message (the default is on);
% or have a (red) `\texttt{x}' make an incorrect answer, and a (green) check mark a correct answer.
% \begin{macrocode}
\def\sqTurnOffAlerts{\let\@sqTurnOffAlerts=0}
\def\sqTurnOnAlerts{\let\@sqTurnOffAlerts=1}
\sqTurnOnAlerts
\def\sqNoCorrections{\let\@sqAlertsOnly=1}
\def\sqCorrections{\let\@sqAlertsOnly=0}
\sqNoCorrections
% \end{macrocode}
% The actions for the form version of a multiple choice question of a shortquiz.
% \begin{macrocode}
\def\Ans@sq@f@Actions
{%
\A{\if\Ans@choice1%
\JS{event.target.textColor=\correctColor;\jsR
event.target.style=style.ch;\jsR
\if\@sqTurnOffAlerts1OnBlurRespBox( true, "\oField" );\fi}%
\ifx\@qzsolndest\@empty\else
\ifeq@solutionsafter\else
/Next <>
\fi
\fi%
\else
\JS{event.target.textColor=\wrongColor;\jsR
event.target.style=style.cr;\jsR
\if\@sqTurnOffAlerts1OnBlurRespBox( false, "\oField" );\fi
\ifx\oField\@empty\else\jsR
updateTally("\oField.\thequestionno");
\fi}%
\fi%
}%
}
\def\Ans@proofing
#1{%
\ifeq@proofing\if\Ans@choice1\relax
\llap{\@proofingsymbol\,\hskip#1\relax}%
\fi\fi
}
%
%<*package|eqexam>
\def\Ans@sq@f{%
\if\eq@listType1\stepcounter{quizno}%
\else\refstepcounter{quizno}\fi\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@f}%
\eq@tmpdima=\wd\eq@tmpbox%
\hangindent=\eq@tmplength\hangafter=1\relax
%
%<*eqexam>
\Ans@sq@f@driver
%
%<*package>
\insertGrayLetters\radio@@Button{}{mc.\oField.\thequestionno}{\RadioFieldSize}%dps 11/16/05 changed from \oField to mc.\oField
{\RadioFieldSize}{\Ans@choice\alph{quizno}}{\eq@protect\A}%
{\eq@setWidgetProps\eq@RadioCheck@driver}%
{\@@Ans@sq@f@Defaults\Ans@sq@f@Actions\every@RadioButton
\every@sqRadioButton}%
\Ans@proofing{\RadioFieldSize}%
%
%<*package|eqexam>
\eq@hspanner\ignorespaces}
%
%<*package>
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Ans@ck@sq@f}
% Created in support of eqExam to give multiple selection for the
% online and email options. Otherwise, it defaults to a radio button field.
% \begin{macrocode}
%
%<*package|eqexam>
% dps 4/16/05
\let\Ans@ck@sq@f=\Ans@sq@f
%
%<*package>
% \end{macrocode}
% \end{macro}
% \subsection{For \texttt{quiz}}
% \subsubsection{The \texttt{answers} Environment}
% \begin{macro}{\answers}
% This is the answers environment for the \texttt{quiz}
% environment. The \texttt{quiz} environment states
% \verb+\let\answers=\answers@q+. This is to avoid a conflict
% with \texttt{shortquiz}, which also as an \texttt{answers}
% environment.
%\begin{verbatim}
% #1 = named destination to be associated with solution
% #2 = number of columns in the tabular environment
%\end{verbatim}
% If the number of columns is $1$, then we use a list environment,
% else, we use a tabular environment.
% \begin{macrocode}
%
%<*package|eqexam>
\newlength\aboveanswersSkip
\setlength\aboveanswersSkip{3pt}
%
%<*package>
\let\q@hwdest=\@empty % hard-wired destination
\newcommand\answers@q
{%
\addtocounter{eqpointvalue}{\eqPTs}\stepcounter{questionno}%
\@ifnextchar[{\answers@@q}%
{\@ifstar{\answers@@q[\curr@quiz.\thequestionno]}{\answers@@q[]}}%
}
\def\answers@@q[#1]#2%
{%
\gdef\numCols{#2}%
\edef\eqtmp{\aPointType}\xdef\aPointType{\eqtmp,[\eqPTs,"mc"]}%
\ifx\q@hwdest\@empty
\xdef\@qzsolndest{#1}%
\else
\gdef\@qzsolndest{\q@hwdest}%
\fi
\ifx#21\gdef\eq@listType{1}\expandafter\answers@q@list\else
\gdef\eq@listType{0}\expandafter\answers@q@tabular\fi{#2}%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\newenvironment{answers@q@list}[1]
{%
\let\endanswers=\endanswers@q@list
\vskip\aboveanswersSkip
\begin{list}{\strut\@Ans}%\
{%
% \usecounter{list@partno}%
% \if\qstar*\relax
\ifx\@Ans\Ans@f
\settowidth{\labelwidth}{\eq@lw@f}%
\else
\settowidth{\labelwidth}{\eq@lw@l}%
\fi
\setlength{\parsep}{0pt}\setlength{\itemindent}{0pt}%
\setlength{\listparindent}{\parindent}
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{0pt}
\def\Ans{\Ans@list}%
%\def\Ans{\item\relax\eq@Ans}%
}%
}{\end{list}\setcounter{quizno}{0}%
% dps 12/20/03
\setdefault@Ans
}
% \end{macrocode}
% \begin{macrocode}
\def\answers@q@tabular#1{%
\vskip\aboveanswersSkip\noindent\tabcolsep=0pt
\eq@tmpdima=\linewidth \advance\eq@tmpdima-\leftskip
\divide\eq@tmpdima by#1
\def\Ans{\Ans@tabular}%
\let\endanswers=\endanswers@q@tabular
\begin{tabular}{*{#1}{p{\eq@tmpdima}}}%
}
% \end{macrocode}
% \begin{macro}{\endanswers}
% Again, we put \verb+\let\endanswers=\endanswers@q+.
% \begin{macrocode}
\def\endanswers@q@tabular
{%
\end{tabular}\setcounter{quizno}{0}%
% dps 12/20/03
\setdefault@Ans
}
% \end{macrocode}
% \end{macro}
% \subsubsection{Link Style}
% \begin{macro}{\Ans@l}
% For the forms version of the \texttt{quiz} environment.
% \begin{macrocode}
% \#1 = 0 or 1 (wrong or right)
% dps 12/19/03 removed the notify because we are not embedding a radio button field
\def\Ans@@l@Actions
{%
\A{\JS{%
this.getField("mc.\curr@quiz.\thequestionno").value = "\Ans@choice\alph{quizno}";\jsR
RecordPointValue([0,\eqPTs,\eq@pPTs],\thequestionno);\jsR
RecordProblemType("\eqQT",\thequestionno);\jsR
ProcessQuestion(\Ans@choice,"\alph{quizno}",\thequestionno,%
\arabic{quizno},"\curr@quiz",0,\ifeq@nocorrections0\else1\fi,%
"\bqlabelISO"\ifx\eqQuizType q\ifx\eq@online y\ifeq@noquizsolutions\else,1\fi\fi\fi)}%
}
}
\def\Ans@r@l@Defaults
{%
\BC{}\S{S}\W{1}\Ff{\FfNoToggleToOff}
\textSize{12}\textColor{0 g}
}
\def\Ans@l{%
\leavevmode\if\eq@listType1\stepcounter{quizno}%
\else\refstepcounter{quizno}\fi\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@l}\sbox{\eq@tmpbox}{\eq@l@l}%
\hangindent=\eq@tmplength\hangafter=1\relax
\eq@tmpdima=\wd\eq@tmpbox
\def\link@@Content{(\hfil\linkContentFormat\hfil)}%
% begin dps changes 12/19/03
\makebox[0pt][l]{\radio@@Button{}{mc.\curr@quiz.\thequestionno}%
{\eq@tmpdima}{\RadioFieldSize}{\Ans@choice\alph{quizno}}%
{\eq@protect\A}{\eq@setWidgetProps\eq@l@check@driver}%
{\Ans@r@l@Defaults\every@RadioButton\every@qRadioButton}}%
% end dps changes 12/19/03
\set@@Link{}{}{}%
{\makebox[\eq@tmpdima]{\color{\@linkcolor}\link@@Content}}%
{\eq@protect\A}{\eq@setWidgetProps\setLink@driver}%
{\set@LinkTextDefaults\Ans@@l@Actions\every@Link}%
\ifeq@nocorrections\else
\if\Ans@choice1\relax
\edef\Ans@c@l@Choice{\noexpand\DV{Yes}%
\ifx\@qzsolndest\@empty\noexpand\BC{}\noexpand\Ff{\FfReadOnly}%
\else % there is a solution to this multiple choice question
\ifeq@noquizsolutions
\noexpand\BC{}\noexpand\Ff{\FfReadOnly}%
\else
\noexpand\BC{0 .6 0}\noexpand\A{\noexpand\quiz@SolutionActionHook}%
\fi
\fi
}%
\else
\def\Ans@c@l@Choice{\Ff{\FfReadOnly}\BC{}}%
\fi
\makebox[0pt][r]{\check@@Box{}%
{mcq.\curr@quiz.\thequestionno.\arabic{quizno}}%
{\eq@tmpdima}{0pt}{Yes}{}% \@tempdimb
{\eq@setWidgetProps\eq@l@check@driver}% \eq@RadioCheck@driver
{\Ans@c@f@Defaults\Ans@c@l@Choice\every@RadioButton
\every@qRadioButton}}%
\fi
\Ans@proofing{\eq@tmpdima}%
\eq@hspanner\ignorespaces}
% \end{macrocode}
% \end{macro}
% \subsubsection{Form Style}
% \begin{macro}{\Ans@f}
% For the form button multiple choice type question. The driver independent stuff starts
% here, then goes to |\Ans@f@driver| the rest of the code that depends on the
% driver.
% \begin{macrocode}
%\def\Ans@f{\leavevmode\refstepcounter{quizno}\PBS\raggedright\Ans@@f}
\def\Ans@f{\leavevmode\if\eq@listType1\stepcounter{quizno}%
\else\refstepcounter{quizno}\fi\PBS\raggedright\Ans@@f}
\def\Ans@r@f@Defaults
{%
\BC{0 0 0}\S{S}\W{1}\Ff{\FfNoToggleToOff}
\textSize{12}\textColor{0 g}
}
% Action of the radio button field
\def\Ans@r@f@Actions
{%
\A{\JS{%
RecordPointValue([0,\eqPTs,\eq@pPTs],\thequestionno);\jsR
RecordProblemType("\eqQT",\thequestionno);\jsR
ProcessQuestion(\Ans@choice,"\alph{quizno}",\thequestionno,%
\arabic{quizno},"\curr@quiz",0,\ifeq@nocorrections0\else1\fi,%
"\bqlabelISO"\ifx\eqQuizType q\ifx\eq@online y\ifeq@noquizsolutions\else,1\fi\fi\fi);}%
}
}
% Action of the check box underlying the radio button field
\def\quiz@SolutionActionHook{%
/S/GoTo/D(\@qzsolndest)/Next<<\JS
{this.resetForm(["mcq.\curr@quiz.\thequestionno.\arabic{quizno}"]);}>>
}
\def\Ans@c@f@Defaults
{%
\BC{0 0 0}\S{S}\W{1}\F{\FHidden}\textSize{12}\textColor{0 .6 0 rg}
\symbolchoice{circle}
}
% \end{macrocode}
% \changes{v6.05d}{2007/04/14}
% {
% Added the command \cs{insertGrayLetters}. This can be defined to place symbols under
% the multiple choice form boxes. The command \cs{bottomOfAnsfStack} is there as a
% hook for whatever purposes are desired.
% }
% \begin{macrocode}
\let\bottomOfAnsfStack\relax
\def\insertGrayLetters{\ifaebshowgrayletters
\rlap{\makebox[\RadioFieldSize]{\textcolor{gray}{\Alph{quizno}}}}\else\relax\fi}
\def\Ans@@f
{%
\settowidth{\eq@tmplength}{\eq@lw@f}%
\hangindent=\eq@tmplength\hangafter=1
\bottomOfAnsfStack\insertGrayLetters
\radio@@Button{}{mc.\curr@quiz.\thequestionno}%
{\RadioFieldSize}{\RadioFieldSize}{\Ans@choice\alph{quizno}}%
{\eq@protect\A}{\eq@setWidgetProps\eq@RadioCheck@driver}%
{\Ans@r@f@Defaults\Ans@r@f@Actions\every@RadioButton
\every@qRadioButton}%
\ifeq@nocorrections\else
\if\Ans@choice1\relax
\edef\Ans@c@f@Choice{\noexpand\DV{Yes}%
\ifx\@qzsolndest\@empty\noexpand\Ff{\FfReadOnly}%
\else
\ifeq@noquizsolutions
\noexpand\Ff{\FfReadOnly}%
\else
\noexpand\BC{0 .6 0}\noexpand\A{\noexpand\quiz@SolutionActionHook}%
\fi
\fi
}%
\else
\def\Ans@c@f@Choice{\Ff{\FfReadOnly}}%
\fi
\makebox[0pt][r]{\check@@Box{}%
{mcq.\curr@quiz.\thequestionno.\arabic{quizno}}%
{\RadioFieldSize}{\RadioFieldSize}{Yes}{}%
{\eq@setWidgetProps\eq@RadioCheck@driver}%
{\Ans@c@f@Defaults\Ans@c@f@Choice\every@RadioButton
\every@qRadioButton}}%
\fi
\Ans@proofing{\RadioFieldSize}%
\eq@hspanner\ignorespaces}
%
%<*package|eqexam>
% \end{macrocode}
%\subsection{The \cs{bChoices}/\cs{eChoices} Pair}
% (2/15/05) This pair of macros is not really an environment, the
% \cs{eChoices} really does nothing other than to act as an ending marker. The idea
%behind this pair of macros twofold: (1) To provide a convenient way of listing
%alternate choices for a multiple choice questions, the ``environment'' makes it
%easy to change the number of columns, or to change from tabular to list (or visa-versa);
%(2) Laying out the alternatives in a list style, makes it easy to develop techniques
%of randomizing the alternatives. Here is an example of usage:
%\begin{verbatim}
%\begin{answers}{4}
%\bChoices[2]
% \Ans0 a choice\eAns
% \Ans1 another choice\eAns
% \Ans0 still another choice\eAns
% \Ans0 another\eAns
% \Ans0 incoming\eAns
% \Ans0 more choices\eAns
% \Ans0 another still\eAns
% \Ans0 too many\eAns
% \Ans0 choices\eAns
%\eChoices
%\end{answers}
%\end{verbatim}
%\noindent The argument of the \texttt{answers} environment is $4$ which means we are
%going to use the tabular environment with $4$ columns. Now within those $4$ we are going
%to only use the first $2$ columns ( this is the optional argument of \cs{bChoices}.
%
% If the optional argument is removed from \cs{bChoices}, the choices are typeset
% in the with $4$ columns. If the argument of \cs{answers} is changed to $1$, then the
% optional argument of \cs{bChoices} is ignored, and the alternatives are typeset in a
% one column list environment.
%
% By changing the two parameters (one for \cs{answers} and one for \cs{bChoices})
% you can easily modify how the alternatives are typeset.
%\par\medskip\noindent
% This counter tracts the column number we are in.
% \begin{macrocode}
\newcount\eq@tabColCnt
% \end{macrocode}
% \begin{macro}{\bChoices}
% This command has one optional argument, the number of columns to use.
% \begin{macrocode}
\def\bChoices{\@ifnextchar[{\@ansChoices}{\@ansChoices[\numCols]}}
% \end{macrocode}
% If \cs{numCols} is $1$, we use a list environment, otherwise, a tabular is used.
% \begin{macrocode}
\def\@ansChoices[#1]%
{%
\global\eq@tabColCnt=0
\ifnum\numCols=1 % list mode
\def\eq@next{\@layoutListAns}%
\else % tabular mode
\def\eq@next{\@layoutTabularAns{#1}}%
\fi
\eq@next
}
\let\eChoices=\relax
% \end{macrocode}
% \end{macro}
% If the next token is \cs{Ans} we grab its all stuff between
% \cs{Ans} and \cs{eAns} and typeset it. We continue until the
% next token is not \cs{Ans}. (This last token
% should be \cs{eChoices}.)
% \begin{macrocode}
\def\@layoutListAns{\@ifnextchar\Ans{\@getListAns}%
{\@lookforendansChoices{\@layoutListAns}}%
}
\long\def\@getListAns\Ans#1\eAns{%
\Ans#1\vspace{\@rowskip}%
\@layoutListAns
}
\long\def\@lookforendansChoices#1{%
\@ifnextchar\eChoices{\rowsep{\rowsep@default}%
\expandafter\@findendans\@gobble}{\expandafter#1\@gobble}%
}
% \end{macrocode}
% The argument is the number of columns to typeset, this number
% is forced to be \texttt{<=} to the number of columns specified in the \texttt{answers}
% environment.
% \begin{macrocode}
\def\@layoutTabularAns#1{%
\let\eq@tabSep=\@empty
\gdef\numShortCols{#1}%
\ifnum#1>\numCols \xdef\numShortCols{\numCols}\fi
\@@layoutTabularAns
}
% \end{macrocode}
% If the next token is \cs{Ans} we grab its all stuff between
% \cs{Ans} and \cs{eAns} and typeset it and insert the appropriate
% token, either \texttt{\&} or \texttt{\string\cr}.
% We continue until the next token is not \cs{Ans}. (This last token
% should be \cs{eChoices}.)
% \begin{macrocode}
\def\@@layoutTabularAns{%
\@ifnextchar\Ans{\@getTabAns}%
{\@lookforendansChoices{\@@layoutTabularAns}}%
}
\def\rowsep#1{\gdef\@rowsep{[#1]}\gdef\@rowskip{#1}}\rowsep{\rowsep@default}
\def\rowsepDefault#1{\def\rowsep@default{#1}}
\def\rowsep@default{0pt}
\long\def\@getTabAns\Ans#1\eAns{%
\global\advance\eq@tabColCnt1
\let\@save@tabSep=\eq@tabSep
\ifnum\eq@tabColCnt=\numShortCols
\global\eq@tabColCnt=0 \xdef\eq@tabSep{\noexpand\\\noalign{\kern\@rowskip\relax}}%
% \global\eq@tabColCnt=0 \xdef\eq@tabSep{\noexpand\\\@rowsep}%
\else
\gdef\eq@tabSep{&}%
\fi
\@ifnextchar\eChoices{\@save@tabSep\Ans#1\rowsep{\rowsep@default}
\expandafter\@findendans\@gobble}%
{\@save@tabSep\Ans#1\@@layoutTabularAns}%
}
\def\@findendans{\@ifnextchar\end{}{\expandafter\@findendans\@gobble}}
%
% \end{macrocode}
% \end{macro}
%\subsection{In Support of showgrayletters}
% This is a hack to reference multiple choice questions when the \texttt{showgrayletters}
% option is in effect. We define \cs{REF} to return the uppercase version of the letters.
% \begin{macrocode}
\def\aeb@exiii{\expandafter\expandafter\expandafter}
% \end{macrocode}
% \begin{macro}{\REF}
% Same syntax as \cs{ref}, including a \texttt{*} option. the \texttt{*} version does
% not create a link. If \texttt{showgrayletters} is not in effect, then \cs{REF} is equivalent to
% \cs{ref}.
%\changes{v6.06c}{2007/04/26}
%{
% Added \cs{REF} in support of the \texttt{showgrayletters} option.
%}
% \begin{macrocode}
\def\REF{\@ifstar{\aeb@REFstar}{\aeb@REF}}
\def\aeb@REFstar#1{\@ifundefined{r@#1}{\hbox{\reset@font\bfseries ??}}
{\ifaebshowgrayletters\aeb@buildUpperCaseRef{#1}%
\else\ref*{#1}\fi}%
}
\def\aeb@REF#1{\@ifundefined{r@#1}{\hbox{\reset@font\bfseries ??}}
{\ifaebshowgrayletters\aeb@buildUpperCaseRef{#1}%
\else\ref{#1}\fi}%
}
\def\aeb@buildUpperCaseRef#1{%
\xdef\tmp@expand{\aeb@exiii\@firstoffive\csname r@#1\endcsname}%
\xdef\tmp@expand{\uppercase{\tmp@expand}}\tmp@expand
}
% \end{macrocode}
% \end{macro}
% \section{Objective Style Questions}
% The code for objective style questions is very simple. The
% evaluation of the user's response is done by JavaScript. The
% JavaScript is inserted into the PDF file through DLJS. For
% authors using \textsf{pdftex} or \textsf{dvipdfm}, this process
% is automatic; for authors using the distiller (hence, would use
% the \texttt{dvips} or \texttt{dvipsone} option), the solution is
% also automatic if you use \textbf{Acrobat 5.0}. If you do not have
% the latest version of Acrobat, the DLJS must be inserted
% manually using the \texttt{Document > Insert Pages} menu item. See
% paragraphs below for a little more detail, or see the manual.
%
% There are two kinds of questions that can be posed (actually only one type):
% (1) a question that has a numerical answer;
% (2) a question that has a symbolic answer in one variable,
% $x$. The symbolic answer must reduce, however, to a numerical value when
% $x$ is given a numerical value. Thus, only questions whose answers can
% be reduced to numerical values can be posed.
%
% If the author has Acrobat 5.0, the \textsf{exerquiz} package should be
% built using the \texttt{Acrobatv} option in the
% \textsf{exerquiz.ins} file. In this case, Document level
% Javascript will be input when the newly distilled file is
% first opened in the Acrobat Viewer. If the function ``CkBalP'' is
% undefined, the we input the FDF file contained the Doc Level JS.
% The file needs to be saved (Save As) for the Doc Level JS to
% remain in the PDF file.
%
% In the case of the author using Acrobat 4.0, he/she needs to load manually
% insert the \texttt{eq\_DLJS.pdf} file. If only exercises are used, this insertion is not needed.
% \begin{macrocode}
%<*package>
% \end{macrocode}
% \begin{macro}{\oQuestion}
% This was my first attempt and I have not deleted it from the package yet.
% Useful for posing a single question only. The argument is the (unique) name
% of this question. This name is used to define the macro \cmd{\oField} which is used
% by support macros. The \texttt{shortquiz} environment can also be used for
% single/multiple questions as well.
% \begin{macrocode}
\newenvironment{oQuestion}[1]
{%
\gdef\oField{#1}\gdef\curr@quiz{#1}\def\currQuiz{#1}%
\let\@qzsolndest=\@empty
% \setcounter{questionno}{0}
\stepcounter{questionno}%
\let\eqQuizType=s\gdef\eqPTs{1}\global\let\eqQT=\eq@na%
\let\solution=\solution@sq
\let\endsolution=\endsolution@sq
}{}
\def\oSolution#1{\edef\@qzsolndest{#1}}
% \end{macrocode}
% \end{macro}
% \subsection{Math Fill-In Questions}
% \begin{macro}{\RespBox}
% \begin{macro}{\RespBoxMath}
% \begin{macro}{\RespBoxNT}
% \cmd{\RespBox} and \cmd{\RespBoxNT} lay out a text box, into which the
% user enters his/her response to the question. \cmd{\RespBox} expects the presence
% of \cmd{\sqTallyBox}, whereas \cmd{\RespBoxNT} does not (NT = No Tally ).
%\par\medskip
% Usage: |\RespBox[#1]#2(#3)[#4]#5#6#7#8[#9]*#10|
% \begin{description}
% \item[\ttfamily\#1 :] Optional parameter used to modify the appearance of the
% text field.
% \item[\ttfamily\#2 :] The correct answer to the question.
% This must be a numerical value, or a function of one variable.
% JavaScript Note:
% In JavaScript, functions such as \texttt{sin(x)} and \texttt{cos(x)} are
% methods of the \texttt{Math} object. It is not necessary, however, to
% type \texttt{Math.sin(x)} or \texttt{Math.cos(x)}; this is done by inserting
% the expression into a \texttt{with(Math)} group.
% \item[\ttfamily\#3 :] An optional parameter, \textit{delimited by parentheses},
% that defines the independent variable; \texttt{x}, is the default value. Note
% that this parameter is set off by parentheses. For a multivariate question, just
% list the variables in juxtaposition, \texttt{(xyz)}. An alternate method is to
% delimit with commas \texttt{(x,y,n)} and include the type of the variables
% \texttt{(r:x,r:y,i:n)}, where \texttt{"r"} means a real variable and \texttt{"i"}
% means an integer variable. The variables must be either of the old style (no commas, no typing)
% or the new style. Do not mix the styles.
% \item[\ttfamily\#4 :] Optional, a named destination to the solution to the
% question. If this parameter appears, then a solution must follow the
% question, enclosed in a \texttt{solution} environment.
% Alternately, the fourth parameter can be a `\texttt*', in which case, we have
% automatic naming of the destination, namely, \texttt{[\string\curr@quiz.\string\thequestionno]}
% \item[\ttfamily\#5 :] The number of samples points to be used, usually $3$ or $4$ is
% sufficient.
% \item[\ttfamily\#6 :] Precision required, the $\epsilon$ value, if you will.
% \item[\ttfamily\#7 :] Parameters \#7 and \#8 are used to define the interval from
% which to draw the sample points. There are two forms: (1) \#7 is the left-hand endpoint
% of the interval and \#8 is the right-hand endpoint (the use of \#7 and \#8 in this form
% is deprecated); (2) the interval is defined by standard interval notation, \texttt{[a,b]}.
% For a multivariate question---one where parameter \#2 lists more than one variable,
% separate the intervals for each variable by a `x', \texttt{[0,2]x[1,2]x[3,4]}.
% \item[\ttfamily\#8 :] (1) \#8 is the right-hand endpoint of the interval (the use of this
% parameter is deprecated); (2) in the second
% case, \#8 is not used.
% \item[\ttfamily\#9 :] This optional parameter is either the name of a customized
% comparison function \textit{or} a JavaScript object with at most two properties:
% \texttt{priorParse} and \texttt{comp}. See the demo file \texttt{integer\_tst.tex} for
% examples of usage.
% \item[\ttfamily\#10:] (Only detected if following an asterisk, `\texttt*')
% The name of a JavaScript function that is to be used to process the user input.
% \end{description}
% Example:
%\begin{flushleft}\footnotesize
%|\RespBoxMath{}(t)[soln]{3}{.0001}{[0,1]}[compare]*{ProcVec}|
%\end{flushleft}
% or (the deprecated form)
%\begin{flushleft}\footnotesize
%|\RespBoxMath{}(t)[soln]{3}{.0001}{0}{1}[compare]*{ProcVec}|
%\end{flushleft}
% \begin{macrocode}
\newcommand\RespBoxNT{\def\rbFlag{0}\@RespBox}
\newcommand\RespBox{\def\rbFlag{0}\@RespBox}
\newcommand\RespBoxMath{\def\rbFlag{0}\@RespBox}
% \end{macrocode}
% These commands can be used define the default appearance of the \cs{RespBoxMath},
% \cs{RespBoxTxt} et al. This first set controls all standard text fields.
% \begin{macrocode}
% \end{macrocode}
% Get any changes in the appearance of the text box
% \begin{macrocode}
\begin{defineJS}[\catcode`\@=0\relax]{\AAKqRespBoxMath}
if(event.willCommit){
RecordPointValue(@eqPTs,@thequestionno@ifx@grpquestions1,@thegrpquestionno,@grpPointValue,@grpTotalWeight,"@grpEvalFunction"@fi);
RecordProblemType("@eqQT",@thequestionno);
var retn = @processJSfunc(@rbArgs,@compareJSfunc);
if (retn != null)
ProcUserResp(retn,event.value,@thequestionno,0@ifx@grpquestions1,@thegrpquestion