texlive[60125] Master/texmf-dist: exam-randomizechoices (31jul21)

commits+karl at tug.org commits+karl at tug.org
Sat Jul 31 22:54:55 CEST 2021


Revision: 60125
          http://tug.org/svn/texlive?view=revision&revision=60125
Author:   karl
Date:     2021-07-31 22:54:54 +0200 (Sat, 31 Jul 2021)
Log Message:
-----------
exam-randomizechoices (31jul21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices-doc.pdf
    trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices-doc.tex
    trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices.pdf
    trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices.tex
    trunk/Master/texmf-dist/tex/latex/exam-randomizechoices/exam-randomizechoices.sty

Modified: trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices-doc.tex	2021-07-31 20:54:39 UTC (rev 60124)
+++ trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices-doc.tex	2021-07-31 20:54:54 UTC (rev 60125)
@@ -1,3 +1,7 @@
+% !TeX encoding = UTF-8
+% !TeX TS-program = pdflatex
+% !TeX spellcheck = en_GB
+
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% exam-randomizechoices-doc.tex
@@ -8,7 +12,7 @@
 %% The package itself is in the file exam-randomizechoices.sty.
 
 
-%% Copyright (c)2019, Jesse E. J. op den Brouw
+%% Copyright (c)2021, Jesse E. J. op den Brouw
 %%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -34,7 +38,7 @@
 %% J.E.J.opdenBrouw at hhs.nl
 
 %% The newest version of this package should always be available
-%% from BitBucket: https://bitbucket.org/jesseopdenbrouw/exam-randomizechoices/src/master/
+%% from GitHub: https://github.com/jesseopdenbrouw/exam-randomizechoices
 
 %--------------------------------------------------------------------
 %--------------------------------------------------------------------
@@ -41,21 +45,20 @@
 
 \documentclass[12pt,a4paper]{exam}
 
-\newcommand{\styversion}{\fileversion}
-\newcommand{\stydate}{\filedate}
-\newcommand{\docdate}{January 9, 2019}
-%\newcommand{\docdate}{Draft: \today}
+\newcommand{\styversion}{0.2}
+\newcommand{\stydate}{July 31, 2021}
+\newcommand{\docdate}{July 31, 2021}
 
 \usepackage{mathtools}
 %\usepackage{amssymb}
 
 %% Set input encoding to UTF-8
-\usepackage[utf8]{inputenc}
+%\usepackage[utf8]{inputenc}
 %% Use T1 output font encoding
 \usepackage[T1]{fontenc}
 
 %% Set page layout
-\usepackage[a4paper,left=1.0in,right=1.0in,top=1.0in,bottom=1.4in,footskip=0.5in]{geometry}
+\usepackage[a4paper,left=1.0in,right=1.0in,top=1.0in,bottom=1.31in,footskip=0.4in]{geometry}
 
 %% Use package enumitem
 \usepackage{enumitem}
@@ -96,9 +99,9 @@
   breakatwhitespace=true,
   title=\lstname,
   upquote=true,
-  aboveskip=0.3\baselineskip,
-  belowskip=-.5\baselineskip,
-  escapeinside={(*}{*)}
+  aboveskip=0.99\baselineskip,
+  belowskip=-.99\baselineskip,
+  escapeinside={(*}{*)},
 }
 
 \usepackage[colorlinks,linkcolor=blue]{hyperref}
@@ -120,6 +123,9 @@
 %% parskip et al.                                            
 \usepackage{parskip}
 
+%% filecontents
+%\usepackage{filecontents}
+
 %% The randomization package
 \usepackage[randomize,nokeeplast]{exam-randomizechoices}
 
@@ -132,7 +138,21 @@
 % without generating pdf warnings:
 \newcommand{\bs}{\texorpdfstring{\char`\\}{}}
 
+% Redefine \LaTeX a bit...
+\makeatletter
+\DeclareRobustCommand{\LaTeX}{L\kern-.25em%
+        {\sbox\z@ T%
+         \vbox to\ht\z@{\hbox{\check at mathfonts
+                              \fontsize\sf at size\z@
+                              \math at fontsfalse\selectfont
+                              A}%
+                        \vss}%
+        }%
+        \kern-.05em%
+        \TeX}
+\makeatother
 
+
 %---------------------------------------------------------------------
 %---------------------------------------------------------------------
 %---------------------------------------------------------------------
@@ -143,7 +163,7 @@
 
 \cfoot[]{Page \thepage\ of \numpages}
 
-\title{The \texttt{exam-randomizechoices} package\\[2ex]\normalsize LaTeX package for creating random placed choices in multiple choice \\environments using the \texttt{exam} document class}
+\title{The \texttt{exam-randomizechoices} package\\[2ex]\normalsize \LaTeX{} package for creating random placed choices in multiple choice \\environments using the \texttt{exam} document class}
 
 \author{Jesse op den Brouw\\
   Department of Electrical Engineering\\
@@ -165,7 +185,7 @@
 \begin{center}
   \small
   This is the user's guide for version~\styversion{} [\stydate] of the
-  \verb|exam-randomizechoices| package. 
+  \verb|exam-randomizechoices| package.
 \end{center}
 
 \clearpage
@@ -205,9 +225,10 @@
 particular purpose.
 
 \subsection{Where to find}
-The development version of this package is available on BitBucket. See
+The development version of this package is available on GitHub. See
 
-\url{https://bitbucket.org/jesseopdenbrouw/exam-randomizechoices/}
+%\url{https://bitbucket.org/jesseopdenbrouw/exam-randomizechoices/}
+\url{https://github.com/jesseopdenbrouw/exam-randomizechoices}
 
 \subsection{Acknowledgements}
 The author wishes to thank the developers of the \verb|exam| document
@@ -221,7 +242,7 @@
 
 Please use a recent version of the \texttt{exam} document class. This
 package is tested with version 2.603 which is available in most distributions.
-Testing with version 2.605\$\bs beta\$ is planned.
+Testing with version 2.606\$\bs beta\$ is planned.
 
 \subsection{A word about reading this document}
 This document uses terminology which is described below:
@@ -461,6 +482,7 @@
 The \texttt{oneparcheckboxes} environment typesets the choices
 in al linear, horizontal way. An example is given below:
 
+
 \begin{lstlisting}
 \question[5] What is the result of $1+2$?
 
@@ -636,7 +658,7 @@
 \end{description}
 
 Sometimes you want the last given item to stick on its place. This is useful
-if you want to use an choice item if none of the other choices are correct:
+if you want to use a choice item if none of the other choices are correct:
 
 \begin{lstlisting}
 \question[5] What is the result of $2+5$?
@@ -729,7 +751,7 @@
 counterparts do.
 
 
-\subsection{Seeding rhe pseudo random generator}
+\subsection{Seeding the pseudo random generator}
 \label{sec:seeding}
 To get a consistent randomization, you must seed the pseudo random generator
 with the same seed every time you compile your document. You can set the
@@ -738,7 +760,7 @@
 Internally, the PGF macro \texttt{\bs pgfmathsetseed} is called, and it is
 flagged that you applied a seed. If you fail to do so, the seeding value is
 \texttt{\bs time}$\times$\texttt{\bs year} as stated by the PFG manual%
-\footnote{Version 3.0.1a, page 940.}. \LaTeX\ compilers keep track of
+\footnote{Version 3.1.9a, page 1046.}. \LaTeX\ compilers keep track of
 time by an integer that holds the minutes counted since midnight. The integer is
 incremented every time the time passes a minute boundary. So the scenario
 can be that you compile your document a couple of times with no apparent
@@ -778,12 +800,28 @@
 The key table is typeset using the \texttt{tabular}
 environment, so it can be wrapped in a \texttt{table} environment.
 
+The \texttt{\bs printkeytable} macro accepts an optional range as in:
+\begin{lstlisting}
+\printkeytable[21-40]
+\end{lstlisting}
+
+It will typeset only the keys in this range. This is useful for generating
+side-by-side key tables. The start question number may be omitted, in which
+case the table starts at 1. The end question number may be omitted, in which
+case the table will be typeset up to the last question.
+
 An example of a key table is presented below. Note the \textbf{??} in the
-Answer column. This is the result of using the standard multiple choice
+Key column. This is the result of using the standard multiple choice
 environments (they are not overloaded, so no label is applied).
 
+Usage of \texttt{\bs printkeytable}
+
 \printkeytable
 
+Usage of \texttt{\bs printkeytable[...-...]}
+
+\printkeytable[1-3]\quad\printkeytable[4-6]\quad\printkeytable[7-8]
+
 The text in the table header row can be changed using two command: the command
 \texttt{\bs keylistquestionname} sets the text above the question numbers, which
 defaults to ``Question'', the command \texttt{\bs keylistkeyname} sets the text
@@ -794,6 +832,39 @@
 \keylistkeyname{Answer Key}
 \end{lstlisting}
 
+\subsection{Saving the keys to a macro}
+It is possible to save the question numbers and the corresponding keys to
+a macro. Please note that only the environments \texttt{randomizechoices},
+\texttt{randomizeoneparchoices}, \texttt{choices} (if overloaded) and
+\texttt{oneparchoices} (if overloaded) can have valid keys in the key list.
+
+Saving a key list file is started by the command:
+
+\begin{lstlisting}
+\savekeylist[(*\textsl{\textrm{command name}}*)]
+\end{lstlisting}
+
+The optional argument is the macro name, including the \bs. if none is
+supplied, it defaults to \texttt{\bs keylist}
+The key list itself is constructed as a comma-separated list. The question
+number and answer keys are separated with a `/'. This makes it easy to
+parse the list with PGF's \texttt{\bs foreach} command (using \texttt{\bs
+mykeylist} as command name):
+
+\savekeylist[\mykeylist]
+
+\begin{lstlisting}
+\foreach \num/\key in \mykeylist {
+	\textcolor{green!\num0!red} {question \num\ has key \key} \\
+}
+\end{lstlisting}
+
+which typesets to:
+
+\foreach \num/\key in \mykeylist {
+	\textcolor{green!\num0!red} {question \num\ has key \key} \\
+}
+
 \subsection{Writing the keys to a file}
 The package provides the writing of the keys to the file.
 Please note that only the environments \texttt{randomizechoices},
@@ -815,7 +886,7 @@
 \texttt{\bs mykeylist}).
 
 \writekeylist{\mykeylist}
-\vspace*{\baselineskip}
+%\vspace*{\baselineskip}
 \lstinputlisting[caption=]{\jobname.keylist}
 
 \vspace*{1.5\baselineskip}
@@ -858,59 +929,160 @@
 
 \subsection{Verbatim environments}
 Verbatim environments such as \texttt{verbatim} and \texttt{lstlistings}
-are currently \emph{not} supported in the new and (overloaded) standard multiple
+are \emph{not} supported in the new and overloaded standard multiple
 choice environments. This is due to the way the contents of these environments
-are collected. The \texttt{\bs verb} command is also not supported by the package
-but \texttt{\bs lstinline} is. An example, translated to English from a Dutch exam
-on the ATmega32 microcontroller chip:
+are collected. The contents is first read by \TeX{} and spaces at the end
+of a line are removed, and the end-of-line character is replaced by a space.
+This will disrupt the formatted code in the verbatim environments.
+There is extensive discussion on StackExchange on how to tackle this problem.
+One could use a \texttt{verbatimbox} environment which puts the contents in
+a box, or one could use the \texttt{VerbatimOut} environment which writes
+the contents to a file for later inclusion. A portable solution would
+be to write contents to (separate) files and include them. In the following
+example using the \texttt{filecontents*} environment, four temporary files
+are created and included using the \verb|\lstinputlisting| macro.
 
 \begin{lstlisting}
+% Use \usepackage{filecontents} in preamble
+%
 \question[5]
-The individual pins of Port D can be configured as input or output.
-The single bits of Port D are called PD7, PD6, PD5, PD4, PD3, PD2,
-PD1 and PD0. Which of the following alternatives configures PD0, PD1,
-PD6 and PD7 as output and the remaining pins as input?
+Which of the four alternative computes the sum of the integers 1
+to 10 (inclusive)?
 
+\begin{filecontents*}{\jobname a.c}
+sum = 0;
+for (i=0; i<10; i++) {
+    sum += i;
+}
+\end{filecontents*}
+\begin{filecontents*}{\jobname b.c}
+sum = 0;
+for (i=1; i<11; i++) {
+    sum += i;
+}
+\end{filecontents*}
+\begin{filecontents*}{\jobname c.c}
+sum = 0; i = 11;
+while (i>0) {
+    sum +- i;
+    i--;
+} 
+\end{filecontents*}
+\begin{filecontents*}{\jobname d.c}
+sum = 0; i = 0;
+do {
+    sum += i;
+    i++;
+} while (i<10);
+\end{filecontents*}
+
 \begin{randomizechoices}
-\choice \lstinline|out DDRD,0x3c|
-\CorrectChoice \lstinline|ldi r20,0xc3| \par \lstinline|out DDRD,r20|
-\choice \lstinline|out PORTD,0x3c|
-\choice \lstinline|ldi r20,195| \par \lstinline|PORTD,r20|
+\choice \lstinputlisting{\jobname a.c}\par    % please use \par otherwise label get clobbered
+\CorrectChoice \lstinputlisting{\jobname b.c}\par
+\choice \lstinputlisting{\jobname c.c}\par
+\choice \lstinputlisting{\jobname d.c}\par
 \end{randomizechoices}
 \end{lstlisting}
 
-typesets possibly to:
+which will typically typeset to:
 
 \begin{questions}
-\setlength{\parskip}{0pt}
 \setcounter{question}{8}
 \question[5]
-The individual pins of Port D can be configured as input or output. The single bits
-of Port D are called PD7, PD6, PD5, PD4, PD3, PD2, PD1 and PD0. Which of the
-following alternatives configures PD0, PD1, PD6 and PD7 as output and the remaining
-pins as input?
+Which of the four alternative computes the sum of the integers 1 to 10 (inclusive)?
 
-%%Original Dutch text
-%%De individuele pinnen van Port D kunnen als ingang of uitgang geconfigureerd worden. De
-%%enkelvoudige bits van Port D worden PD7, PD6, PD5, PD4, PD3, PD2, PD1, PD0 genoemd.
-%%Welk van de volgende alternatieven configureert PD0, PD1, PD6 en PD7 als uitgang en de
-%%overige pinnen als ingang?
-%
-%\hspace*{\baselineskip}
+\begin{filecontents*}{\jobname a.c}
+sum = 0;
+for (i=0; i<10; i++) {
+    sum += i;
+}
+\end{filecontents*}
+\begin{filecontents*}{\jobname b.c}
+sum = 0;
+for (i=1; i<11; i++) {
+    sum += i;
+}
+\end{filecontents*}
+\begin{filecontents*}{\jobname c.c}
+sum = 0; i = 11;
+while (i>0) {
+    sum +- i;
+    i--;
+} 
+\end{filecontents*}
+\begin{filecontents*}{\jobname d.c}
+sum = 0; i = 0;
+do {
+    sum += i;
+    i++;
+} while (i<10);
+\end{filecontents*}
 
-\begin{randomizechoices}[norandomize]
-	\choice \lstinline|out DDRD,0x3c|
-	\CorrectChoice \lstinline|ldi r20,0xc3| \par \lstinline|out DDRD,r20|
-    \choice \lstinline|out PORTD,0x3c|
-	\choice \lstinline|ldi r20,195| \par \lstinline|PORTD,r20|
+\begin{randomizechoices}
+\choice \lstinputlisting[caption=,frame=none,numbers=none]{\jobname a.c}\par    % please use \par otherwise label get clobbered
+\CorrectChoice \lstinputlisting[caption=,frame=none,numbers=none]{\jobname b.c}\par
+\choice \lstinputlisting[caption=,frame=none,numbers=none]{\jobname c.c}\par
+\choice \lstinputlisting[caption=,frame=none,numbers=none,belowskip=0pt]{\jobname d.c}\par
 \end{randomizechoices}
+
 \end{questions}
 
+Please note that the \texttt{\bs verb} command is also not supported by the package
+but \texttt{\bs lstinline} command is.
+
+%% An example, translated to English from a Dutch exam
+%%on the ATmega32 microcontroller chip:
+%%
+%%\begin{lstlisting}
+%%\question[5]
+%%The individual pins of Port D can be configured as input or output.
+%%The single bits of Port D are called PD7, PD6, PD5, PD4, PD3, PD2,
+%%PD1 and PD0. Which of the following alternatives configures PD0, PD1,
+%%PD6 and PD7 as output and the remaining pins as input?
+%%
+%%\begin{randomizechoices}
+%%\choice \lstinline|out DDRD,0x3c|
+%%\CorrectChoice \lstinline|ldi r20,0xc3| \par \lstinline|out DDRD,r20|
+%%\choice \lstinline|out PORTD,0x3c|
+%%\choice \lstinline|ldi r20,195| \par \lstinline|PORTD,r20|
+%%\end{randomizechoices}
+%%\end{lstlisting}
+%%
+%%typesets possibly to:
+%%
+%%\begin{questions}
+%%\setlength{\parskip}{0pt}
+%%\setcounter{question}{8}
+%%\question[5]
+%%The individual pins of Port D can be configured as input or output. The single bits
+%%of Port D are called PD7, PD6, PD5, PD4, PD3, PD2, PD1 and PD0. Which of the
+%%following alternatives configures PD0, PD1, PD6 and PD7 as output and the remaining
+%%pins as input?
+%%
+%%%%Original Dutch text
+%%%%De individuele pinnen van Port D kunnen als ingang of uitgang geconfigureerd worden. De
+%%%%enkelvoudige bits van Port D worden PD7, PD6, PD5, PD4, PD3, PD2, PD1, PD0 genoemd.
+%%%%Welk van de volgende alternatieven configureert PD0, PD1, PD6 en PD7 als uitgang en de
+%%%%overige pinnen als ingang?
+%%%
+%%%\hspace*{\baselineskip}
+%%
+%%\begin{randomizechoices}[norandomize]
+%%	\choice \lstinline|out DDRD,0x3c|
+%%	\CorrectChoice \lstinline|ldi r20,0xc3| \par \lstinline|out DDRD,r20|
+%%    \choice \lstinline|out PORTD,0x3c|
+%%	\choice \lstinline|ldi r20,195| \par \lstinline|PORTD,r20|
+%%\end{randomizechoices}
+%%\end{questions}
+
 \subsection{Accessing the internal labels}
 Each \texttt{\bs question} command is accompanied with a label of the form
 \texttt{question@}$x$ as provided by the \texttt{exam} document class, where
-$x$ is the decimal number of the question. A \texttt{\bs CorrectChoice}
-command is provided with a label (by this package) of the form \linebreak \texttt{question@}$x$%
+$x$ is the decimal number of the question. Within the the environments
+\texttt{randomizechoices}, \texttt{randomizeoneparchoices}, \texttt{choices}
+(if overloaded) and \texttt{oneparchoices} (if overloaded), a
+\texttt{\bs CorrectChoice} command is provided with a label (by this package)
+of the form \texttt{question@}$x$%
 \texttt{@correctchoice} where $x$ is again the decimal number of the question.
 The user can access these labels by using the \texttt{\bs ref} command as shown
 below:
@@ -925,7 +1097,7 @@
 The question number is~\ref{question at 9} and the correct answer
 is~\ref{question at 9@correctchoice}.
 
-There is no need to change the cat code of `@'.
+%There is no need to change the cat code of `@'.
 
 \subsection{Error messages}
 The package will throw you some error messages in case something is wrong. The
@@ -1015,10 +1187,10 @@
 \choice two
 \CorrectChoice three
 \choice four
-\end{randomizechoices
+\end{randomizechoices}
 \end{lstlisting}
 
-the \texttt{\bs BODY} command now contains (comments and newlines are stripped):
+the \texttt{\bs BODY} command now contains (comments and newlines are stripped by \TeX):
 
 \begin{lstlisting}
 \choice one \choice two \CorrectChoice three \choice four
@@ -1117,7 +1289,7 @@
 is the consistent typesetting of my exams. I don't use sub parts and sub-sub parts
 because in my opinion this not the right way to prepare an exam. I've written a
 department consistent class that provides the department's cover pages and some
-other typesetting trickery. This class is used by a small core \TeX\ users. Regrettably,
+other typesetting trickery. This class is used by a small core of \TeX\ users. Regrettably,
 the majority of my colleagues use Word *cough*.
 
 \end{document}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices.tex	2021-07-31 20:54:39 UTC (rev 60124)
+++ trunk/Master/texmf-dist/doc/latex/exam-randomizechoices/exam-randomizechoices.tex	2021-07-31 20:54:54 UTC (rev 60125)
@@ -3,7 +3,7 @@
 %%
 %% Randomize mc choices using the exam class -- examples
 %%
-%% Copyright (c)2019, Jesse E. J. op den Brouw
+%% Copyright (c)2021, Jesse E. J. op den Brouw
 %%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -29,7 +29,7 @@
 %% J.E.J.opdenBrouw at hhs.nl
 
 %% The newest version of this package should always be available
-%% from BitBucket: https://bitbucket.org/jesseopdenbrouw/exam-randomizechoices/src/master/
+%% from GitHub: https://github.com/jesseopdenbrouw/exam-randomizechoices
 
 \documentclass[answers,addpoints]{exam}
 
@@ -36,15 +36,17 @@
 \usepackage{parskip}
 \usepackage[colorlinks,linkcolor=blue]{hyperref}
 \usepackage{mathtools}
+\usepackage[a4paper]{geometry}
 
 \usepackage[debug,randomize,nokeeplast]{exam-randomizechoices}
-\usepackage[a4paper]{geometry}
-
 \setrandomizerseed{999}
 
-%%\checkboxchar{\thecheckbox}
-%%\checkedchar{\thecheckbox}
 
+
+\usepackage{amssymb}
+\checkboxchar{$\square$}
+\checkedchar{$\raisebox{0.3ex}{\checkmark}\hspace{-0.95em}\square$}
+
 \CorrectChoiceEmphasis{\color{red}\slshape}
 
 \begin{document}
@@ -351,7 +353,7 @@
 \CorrectChoice Socrates
 \end{oneparchoices}
 
-%%%%%%%%21
+%%%%%%%%23
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -365,7 +367,7 @@
 \CorrectChoice Socrates
 \end{randomizechoices}
 
-%%%%%%%%22
+%%%%%%%%24
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -379,7 +381,7 @@
 \CorrectChoice Socrates
 \end{randomizechoices}
 
-%%%%%%%%23
+%%%%%%%%25
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -392,7 +394,7 @@
 \CorrectChoice Socrates
 \end{choices}
 
-%%%%%%%%24
+%%%%%%%%26
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -405,7 +407,7 @@
 \CorrectChoice Socrates
 \end{randomizeoneparchoices}
 
-%%%%%%%%25
+%%%%%%%%27
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -418,7 +420,7 @@
 \CorrectChoice Socrates
 \end{oneparchoices}
 
-%%%%%%%%26
+%%%%%%%%28
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -431,7 +433,7 @@
 \CorrectChoice Socrates
 \end{randomizecheckboxes}
 
-%%%%%27
+%%%%%29
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -444,7 +446,7 @@
 \CorrectChoice Socrates
 \end{checkboxes}
 
-%%%%%%%%28
+%%%%%%%%30
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -457,7 +459,7 @@
 \CorrectChoice Socrates
 \end{randomizeoneparcheckboxes}
 
-%%%%%29
+%%%%%31
 \question[5]
 One of these things is not like the others; one of these
 things is not the same. Which one is different?
@@ -470,6 +472,582 @@
 \CorrectChoice Socrates
 \end{oneparcheckboxes}
 
+%%%%%32+
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+\question[5]
+One of these things is not like the others; one of these
+things is not the same. Which one is different?
+
+\begin{randomizeoneparchoices}
+\choice John
+\choice Paul
+\choice George
+\choice Ringo
+\CorrectChoice Socrates
+\end{randomizeoneparchoices}
+
+
 %%\question
 %%Proceed with the next sub-questions.
 %%\begin{parts}
@@ -527,12 +1105,15 @@
 
 Key table
 
-\printkeytable
+\printkeytable[1-30]\quad\printkeytable[31-60]\quad\printkeytable[61-83]
 
 \writekeylist[testfile.txt]{\mykeylist}
 \writekeylist{\mykeylist}
 
+\savekeylist[\yesthekeylist]
 
+{\color{red}\ttfamily\yesthekeylist}
 
+That's all folks!
 \end{document}
 

Modified: trunk/Master/texmf-dist/tex/latex/exam-randomizechoices/exam-randomizechoices.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/exam-randomizechoices/exam-randomizechoices.sty	2021-07-31 20:54:39 UTC (rev 60124)
+++ trunk/Master/texmf-dist/tex/latex/exam-randomizechoices/exam-randomizechoices.sty	2021-07-31 20:54:54 UTC (rev 60125)
@@ -1,9 +1,9 @@
 %%
 %% exam-randomizechoices.sty
 %%
-%% Randomize mc choices using the exam class
+%% Randomize m.c. choices using the exam class
 %%
-%% Copyright (c)2019, Jesse E. J. op den Brouw
+%% Copyright (c)2021, Jesse E. J. op den Brouw
 %%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -29,8 +29,13 @@
 %% J.E.J.opdenBrouw at hhs.nl
 
 %% The newest version of this package should always be available
-%% from BitBucket: https://bitbucket.org/jesseopdenbrouw/exam-randomizechoices/src/master/
+%% from GitHub: https://github.com/jesseopdenbrouw/exam-randomizechoices
 
+%% Version 0.1 [09/01/2019]: Initial release
+%% Version 0.2 [31/07/2021]: Added \savekeylist
+%%                           Adapted \printkeytable to accept optional range
+%%                           Minor cosmetic changes
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%
 %% What LaTeX format do we need and version and date
@@ -38,8 +43,8 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
 %% Version and date
-\gdef\fileversion{0.1}
-\gdef\filedate{2019/01/09}
+\def\fileversion{0.2}
+\def\filedate{2021/07/31}
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -96,11 +101,10 @@
 %%                                                       %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % http://ctan.org/pkg/{environ,etoolbox,pgffor}
-\@ifpackageloaded{environ}{\if@@ercdebug\PackageWarning{exam-randomizechoicces}{Package environ already loaded}\fi}{\RequirePackage{environ}}
-\@ifpackageloaded{etoolbox}{\if@@ercdebug\PackageWarning{exam-randomizechoicces}{Package etoolbox already loaded}\fi}{\RequirePackage{etoolbox}}
-\@ifpackageloaded{pgffor}{\if@@ercdebug\PackageWarning{exam-randomizechoicces}{Package pgffor already loaded}\fi}{\RequirePackage{pgffor}}
+\RequirePackage{environ}
+\RequirePackage{etoolbox}
+\RequirePackage{pgffor}
 
-
 %% A scratch counter
 \newcounter{erc at counter}
 
@@ -276,7 +280,7 @@
     \fi
   \fi	
   %%
-  %% We travel the list items. If an item begin with the special marker
+  %% We travel the list items. If an item begins with the special marker
   %% \inaccessible, we prepend it with \correctchoice, otherwise we prepend it
   %% with \choice. At the end we have all the list items prepended with
   %% either \choice or \correctchoice. Then we append the list item to
@@ -321,8 +325,8 @@
   \fi
 
   %% Save choices environment
-  \let\@oldchoices\choices
-  \let\end at oldchoices\endchoices
+  \let\erc at oldchoices\choices
+  \let\enderc at oldchoices\endchoices
 
   %% Renew the choices environment
   \RenewEnviron{choices}[1][]{
@@ -331,10 +335,10 @@
     \erc at createrandomlist[#1]%
     %%
     %% Start the choices environment
-    \begin{@oldchoices}%
+    \begin{erc at oldchoices}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldchoices}%
+    \end{erc at oldchoices}%
   }
 
   \NewEnviron{randomizechoices}[1][]{
@@ -343,10 +347,10 @@
     \erc at createrandomlist[#1]%
     %%
     %% Start the choices environment
-    \begin{@oldchoices}%
+    \begin{erc at oldchoices}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldchoices}%
+    \end{erc at oldchoices}%
   }
 \else
   \NewEnviron{randomizechoices}[1][]{
@@ -371,8 +375,8 @@
   \fi
 
   %% Save oneparchoices environment
-  \let\@oldoneparchoices\oneparchoices
-  \let\end at oldoneparchoices\endoneparchoices
+  \let\erc at oldoneparchoices\oneparchoices
+  \let\enderc at oldoneparchoices\endoneparchoices
 
   %% Renew the oneparchoices environment
   \RenewEnviron{oneparchoices}[1][]{
@@ -381,10 +385,10 @@
     \erc at createrandomlist[#1]%
     %%
     %% Start the oneparchoices environment
-    \begin{@oldoneparchoices}%
+    \begin{erc at oldoneparchoices}%
       % Execute the list
       \erc at typesetchoices
-    \end{@oldoneparchoices}%
+    \end{erc at oldoneparchoices}%
   }
 
   \NewEnviron{randomizeoneparchoices}[1][]{
@@ -393,10 +397,10 @@
     \erc at createrandomlist[#1]%
     %%
     %% Start the oneparchoices environment
-    \begin{@oldoneparchoices}%
+    \begin{erc at oldoneparchoices}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldoneparchoices}%
+    \end{erc at oldoneparchoices}%
   }
 \else
   \NewEnviron{randomizeoneparchoices}[1][]{
@@ -421,8 +425,8 @@
   \fi
 
   %% Save choices environment
-  \let\@oldcheckboxes\checkboxes
-  \let\end at oldcheckboxes\endcheckboxes
+  \let\erc at oldcheckboxes\checkboxes
+  \let\enderc at oldcheckboxes\endcheckboxes
 
   %% Renew the oneparchoices environment
   \RenewEnviron{checkboxes}[1][]{
@@ -431,10 +435,10 @@
     \erc at createrandomlist[#1,nolabel]%
     %%
     %% Start the choices environment
-    \begin{@oldcheckboxes}%
+    \begin{erc at oldcheckboxes}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldcheckboxes}%
+    \end{erc at oldcheckboxes}%
   }
 
   \NewEnviron{randomizecheckboxes}[1][]{%
@@ -443,10 +447,10 @@
     \erc at createrandomlist[#1,nolabel]%
     %%
     %% Start the choices environment
-    \begin{@oldcheckboxes}%
+    \begin{erc at oldcheckboxes}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldcheckboxes}%
+    \end{erc at oldcheckboxes}%
   }
 \else
   \NewEnviron{randomizecheckboxes}[1][]{
@@ -471,8 +475,8 @@
   \fi
 
   %% Save oneparcheckboxes environment
-  \let\@oldoneparcheckboxes\oneparcheckboxes
-  \let\end at oldoneparcheckboxes\endoneparcheckboxes
+  \let\erc at oldoneparcheckboxes\oneparcheckboxes
+  \let\enderc at oldoneparcheckboxes\endoneparcheckboxes
 
   %% Renew the oneparcheckboxes environment
   \RenewEnviron{oneparcheckboxes}[1][]{
@@ -481,10 +485,10 @@
     \erc at createrandomlist[#1,nolabel]%
     %%
     %% Start the oneparcheckboxes environment
-    \begin{@oldoneparcheckboxes}%
+    \begin{erc at oldoneparcheckboxes}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldoneparcheckboxes}%
+    \end{erc at oldoneparcheckboxes}%
   }
 
   \NewEnviron{randomizeoneparcheckboxes}[1][]{%
@@ -493,10 +497,10 @@
     \erc at createrandomlist[#1,nolabel]%
     %%
     %% Start the oneparcheckboxes environment
-    \begin{@oldoneparcheckboxes}%
+    \begin{erc at oldoneparcheckboxes}%
       % Execute the list
       \erc at typesetchoices%
-    \end{@oldoneparcheckboxes}%
+    \end{erc at oldoneparcheckboxes}%
   }
 \else
   \NewEnviron{randomizeoneparcheckboxes}[1][]{%
@@ -513,13 +517,28 @@
 \fi
 
 %%
-%% Simple key table printer
+%% Simple key table printer, with key range
 %%
 %% Building a table with \foreach from the pgffor package is hard to do.
 %% See https://tex.stackexchange.com/questions/367979/latex-foreach-in-tabular-environment
 %% So we use \gappto and \xappto to build the table. At the end, we expand the macro
 %%
-\newcommand{\printkeytable}{%
+
+\newcounter{erc at printstart}\setcounter{erc at printstart}{0}
+\newcounter{erc at printstop}\setcounter{erc at printstop}{0}
+
+\newcommand{\printkeytable}[1][-]{%
+  \erc at printkeytable#1\@nil%
+}
+
+\def\erc at printkeytable#1-#2\@nil{%
+  %% Grab arguments
+  \setcounter{erc at printstart}{0#1}%
+  \setcounter{erc at printstop}{0#2}%
+  %% Sanity check
+  \ifnum\value{erc at printstart}<1\setcounter{erc at printstart}{1}\fi%
+  \ifnum\value{erc at printstop}<1\setcounter{erc at printstop}{\thequestion}\fi%
+  \ifnum\value{erc at printstop}>\thequestion\setcounter{erc at printstop}{\thequestion}\fi%
   \if@@ercdebug
     \PackageWarning{exam-randomizechoices}{Writing key table}%
   \fi
@@ -527,7 +546,7 @@
   \xdef\erc at keytable{}%
   %%
   %% Add the preamble of the table {regular tabular}
-  \gappto\erc at keytable{\begin{tabular} {|c|c|} \hline}%
+  \gappto\erc at keytable{\begin{tabular}[t] {|c|c|} \hline}%
   \xappto\erc at keytable{\erc at keylistquestionname\space & \erc at keylistkeyname}%
   \gappto\erc at keytable{ \\ \hline}%
   %%
@@ -534,7 +553,8 @@
   %% Write the table entries.
   \ifnum\thequestion=0\relax
   \else
-    \foreach \x in {1,...,\thequestion} {%
+%    \foreach \x in {1,...,\thequestion} {%
+    \foreach \x in {\arabic{erc at printstart},...,\arabic{erc at printstop}} {%
       %%
       %% Add '\ref{question@\x} & ', \x should be expandend, \ref not 
       \gappto\erc at keytable{\ref}%
@@ -611,4 +631,35 @@
   \fi
 }
 
+%%
+%% Simple key list saver. Saves the key list in a macro
+%%
+\def\savekeylist{\@ifnextchar[{\erc at savekeylist}{\erc at savekeylist[\keylist]}}%
+\def\erc at savekeylist[#1]{%
+    %%
+    \if@@ercdebug
+      \PackageWarning{exam-randomizechoices}{Saving key list to macro}%
+    \fi
+    %%
+    %% Create a command that has all the question numbers / question keys
+    %% separated by a / (but nothing if there are no questions)
+    \ifnum\thequestion=0\relax
+      \gdef\erc at keylist{}%
+    \else
+      %% Write the list entries.
+      \gdef\erc at keylist{\@gobble}%
+      \foreach \x in {1,...,\thequestion} {%
+        \@ifundefined{r at question@\x @correctchoice}{%
+          %not found
+          \xdef\erc at keylist{\erc at keylist,\x/?}%
+        }{%
+          %found
+         \xdef\erc at keylist{\erc at keylist,\x/\getrefnumber{question@\x @correctchoice}}%
+        }%
+      }%
+    \fi%
+    %% Save the keylist in the supplied macro
+    \expandafter\xdef\expandafter#1\expandafter{\erc at keylist}%
+}
+
 \endinput



More information about the tex-live-commits mailing list.