I am building a template for writing exams, and I'd like to randomly shuffle my enumerated lists at compile time. The answers to this question worked for that purpose, however I am using other functions to be able to switch between a 'Student View' and a view of the 'Key', and the solutions provided doesn't work with the functionality of the enumerate
package which I used when constructing my other functionality.
Here is an MWE, without the randomize functionality
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{amsmath, enumerate, ifthen, multicol, tikz}
\newif\ifgrading
\newcommand*\circleAns[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=2pt,color=ForestGreen] (char) {#1};}}
\makeatletter
\newcommand{\itemAns}{
\ifgrading
\stepcounter{enum\romannumeral\@enumdepth}
\item[\circleAns{\textcolor{ForestGreen}{\@nameuse{label\@enumctr}}}]
\else \item
\fi
}
\makeatother
\begin{document}
\begin{multicols}{2}
\gradingtrue
\begin{enumerate}[a)]
\itemAns
\item
\item
\end{enumerate}
\gradingfalse
\begin{enumerate}[a)]
\itemAns
\item
\item
\end{enumerate}
\end{multicols}
\end{document}
Producing the output:
Ideally, the randomization functionality would allow me to continue using both \begin{enumerate}[<options>]
and \itemAns
, and would also allow me to set a seed for the random generation process for repeatability. Thank you in advance for your assistance.