% \subsubsection{Multiple choice and the like} % \DescribeEnv{multipleChoice}{Multiple choice} % \begin{macrocode} %<*classXimera> % Jim: Originally this was \renewcommand{\theenumi}{$(\mathrm{\alph{enumi}})$} % but that breaks tex4ht because mathmode can only be processed by mathjax. % so now I made this just italicized. % \end{macrocode} % \subsubsection{Options} % \begin{macrocode} \define@key{choice}{value}[]{\def\choice@value{#1}} % \end{macrocode} % This flags the answer as the correct answer % \begin{macrocode} \define@boolkey{choice}{correct}[true]{\def\choice@correct{#1}} % \end{macrocode} % Use an ID to refer to the choice. % \begin{macrocode} \define@key{multipleChoice}{id}{\def\mc@id{#1}} % \end{macrocode} % |\otherchoice| outputs the item if correct and nothing if incorrect. % \begin{macrocode} \define@key{otherchoice}{value}[]{\def\otherchoice@value{#1}} \define@boolkey{otherchoice}{correct}[true]{\def\otherchoice@correct{#1}} % \end{macrocode} % Default key choices for multiple choice options. % Default for choice pairs. % Default: answers without the option "correct=true" is "incorrect". % \begin{macrocode} \setkeys{choice}{correct=false,value=} % \end{macrocode} % Defaults for multipleChoice pairs. % Default to no id? -- Jason % \begin{macrocode} \setkeys{multipleChoice}{id=} % \end{macrocode} % Defaults for otherchoice pairs. % Default "otherchoice" to behave like "choice" for error checking. % \begin{macrocode} \setkeys{otherchoice}{correct=false,value=} % % \end{macrocode} % % \subsubsection{Choices} % \DescribeMacro{\choice}{Like |\item| but for choice environments.} % choice command denotes a possible answer choice for the multiple choice question. % \begin{macrocode} %<*classXimera> \newcommand{\choice}[2][]{% \setkeys{choice}{#1}% \item{#2} \ifthenelse{\boolean{\choice@correct}} {% Begin then result \ifhandout% if it's a handout do nothing. \else% otherwise place a checkmark when you select the "correct choice"... maybe? -- Jason \,\checkmark\,\setkeys{choice}{correct=false} \fi }% End then result {}% Begin/End else result. } %Define an expandable version of choice Not really meant to be used outside this package (used in wordChoice) % Is there a reason we can't just always use this as default? -- Jason \newcommand{\choiceEXP}[2][]{% \expandafter\setkeys\expandafter{choice}{#1}% \item{#2} \ifthenelse{\boolean{\choice@correct}} {% Begin then result \ifhandout \else \,\checkmark\,\setkeys{choice}{correct=false} \fi }% End then result {}% Begin/End else result. } %% note all the {} are needed in case the choice has [] in it. % \otherchoice is the \choice used in wordChoice command. \newcommand{\otherchoice}[2][]{% \ignorespaces% \setkeys{otherchoice}{#1}% \ifthenelse{\boolean{\otherchoice@correct}}% {% Start then result #2\ignorespaces\setkeys{otherchoice}{correct=false}\ignorespaces% }% End then result {}% Start/End else result \ignorespaces% }% \newcommand{\inlinechoice}[2][]{% \setkeys{choice}{#1}% \iffirstinlinechoice (\hspace{-.25em} \firstinlinechoicefalse \else / \fi #2 \ifthenelse{\boolean{\choice@correct}}% {% Start then result \ifhandout\else\checkmark\ignorespaces\setkeys{choice}{correct=false}\ignorespaces\fi% }% End then result {}% Start/End else result \hspace{-.25em}\ignorespaces% } % % \end{macrocode} % On the HTML side, |\choice| emits ||s. % \begin{macrocode} %<*htXimera> \newcounter{choiceId} \renewcommand{\choice}[2][]{% \setkeys{choice}{correct=false}% \setkeys{choice}{#1}% \stepcounter{choiceId}\IgnorePar% \HCode{}% #2\HCode{}} \let\inlinechoice\choice % % \end{macrocode} % \subsubsection{Environment(s)} % The environment |multipleChoice@| is for internal use only. % \DescribeEnv{multipleChoice}{Wrap |\choice|s in a |multipleChoice| environment to make a multiple choice question.} % \begin{macrocode} %<*classXimera> \newenvironment{multipleChoice}[1][] {% Environment Start Code \setkeys{multipleChoice}{#1}% \recordvariable{\mc@id}% \begin{trivlist} \item[\hskip \labelsep\small\bfseries Multiple Choice:]\hfil \begin{enumerate} }% Note this means that \item has to be the first line after \begin{multipleChoice}. {% Environment End Code \end{enumerate} \end{trivlist} } %multipleChoice@ is for internal use only! (used in wordChoice) %this is simply a wrapper for the sole showing (other)choice. \newenvironment{multipleChoice@}[1][]{}{)} % % \end{macrocode} % On the web, you might also expect these to be "problem environments" % but they aren't -- they're respondables. You might expect a % |\setcounter{choiceId}{0}| here --- that would be wrong, because then % the generated IDs would no longer be unique. % \begin{macrocode} %<*htXimera> \renewenvironment{multipleChoice}[1][] {\setkeys{multipleChoice}{#1}% \stepcounter{identification}\ifvmode \IgnorePar\fi \EndP\HCode{
}% }{\HCode{
}\IgnoreIndent} \ConfigureEnv{multipleChoice}{}{}{}{} % % \end{macrocode} % \subsection{Word choice} % \DescribeMacro{\wordChoice}{An in-line version of multipleChoice: % uses enumitem package note, it is coded as a single line to avoid % unwanted spaces in ``given'' mode.} % \begin{macrocode} %<*classXimera> \newcommand{\wordChoice}[1]{% \let\choicetemp\choice% Assign a "choicetemp" command to duplicate choice. \ifwordchoicegiven% If wordchoice option is on, we need to juggle around some definitions. \let\choice\otherchoice% %\begin{multipleChoice@}% -unnecessary (REMOVE THIS LINE IF THE YEAR IS 2019 or Beyond) #1 %\end{multipleChoice@}% -unnecessary (REMOVE THIS LINE IF THE YEAR IS 2019 or Beyond) \else% If it isn't the regular "choice" command should work. \let\choice\inlinechoice% \begin{multipleChoice@}% #1% \end{multipleChoice@}% \fi% \let\choice\choicetemp% Now that choicetmp has been manipulated to what we want, replace choice with it. }% % % \end{macrocode} % This is actually just word choice % \begin{macrocode} %<*htXimera> \renewenvironment{multipleChoice@}{\refstepcounter{problem}}{}% \ConfigureEnv{multipleChoice@}{\stepcounter{identification}\IgnorePar\HCode{}}{\HCode{}\IgnoreIndent}{}{} % % \end{macrocode} % \subsection{Select all} % \DescribeEnv{selectAll}{A multiple-multiple choice question} % \begin{macrocode} %<*classXimera> \newenvironment{selectAll}[1][] {\begin{trivlist}\item[\hskip \labelsep\small\bfseries Select All Correct Answers:]\hfil\begin{enumerate}} {\end{enumerate}\end{trivlist}} % % \end{macrocode} % In the future we need this to (optionally) be displayed in the % problem, while the actual code lives in the solution. Here is how % this could be implemented: Like the title/maketitle commands, the % multiple-choice could be stored in |\themultiplechoice|, flip a % boolean, and execute |\makemultiplechoice| at the |\end| of the % problem. We should also make a command called |\showchoices| that % will show choices in the handout. % On the web, |selectAll| is handled just like |multipleChoice|. % \begin{macrocode} %<*htXimera> \renewenvironment{selectAll}{\refstepcounter{problem}}{}% \ConfigureEnv{selectAll}{\stepcounter{identification}\ifvmode \IgnorePar\fi \EndP\HCode{
}}{\HCode{
}\IgnoreIndent}{}{} % % \end{macrocode}