%
% This demo file shows how to randomize the choices of a quiz created
% by the exerquiz package, where the choices have verbatim text.
%
% The questions themselves are not randomized, but they can be, see random_tst.tex
% to see how to do this.
%
\documentclass{article}
\usepackage[designiv]{web}
\usepackage[allowrandomize,showgrayletters]{exerquiz}
\usepackage{ran-toks} % alt pkg name

% \previewOn\pmpvOn

% When using cross-referencing and \useLastAsSeed, the cross-references are never up to date.
% Once you randomize, read the auxiliary file (\jobname_rt.sav), copy the first seed listed
% and paste in as the argument of \useThisSeed. Compile a few more times to bring cross-references
% up to date.
%\useLastAsSeed
\useThisSeed{955908747}

\rowsepDefault{3pt}


\begin{document}

\begin{quiz*}{myRandomQuiz}
    Riddle me this.
\begin{questions}
    \item Try to guess the correct answer.
    \begin{answers}{2}
    \bChoices[random=true]
        \Ans0 1 a choice\eAns
        \Ans1\label{eq} 2 another choice\eAns
        \Ans0 3 still another choice\eAns
        \Ans0 4 another\eAns
        \Ans0 5 incoming\eAns
        \Ans0 6 more choices\eAns
        \Ans0 7 another still\eAns
        \Ans0 8 too many\eAns
        \Ans0 9 choices\eAns
        \Ans0 10 \input{mytext.verb}\eAns
        \eFreeze
        \Ans0 11 None of these\eAns
    \eChoices
    \end{answers}
\end{questions}
\end{quiz*}\quad\ScoreField\currQuiz\CorrButton\currQuiz


\newpage

\bRTVToks{myChoices}
\begin{rtVW}
\verb!$ true $!
\end{rtVW}
\begin{rtVW}
\verb!~ false %!
\end{rtVW}
\begin{rtVW}
\verb!% maybe ^!
\end{rtVW}
\begin{rtVW}
\verb!$& perhaps #$!
\end{rtVW}
\eRTVToks

\begin{quiz*}{myQuiz}
Solve each.
\begin{questions}

    \item Which is true? (Answer: \hyperref[rtAns3]{(\REF*{rtAns3})})
\useRTName{myChoices}
\begin{manswers}*{1}
\bChoices[random=true,label=rtAns]
    \Ans{1}\label{rtAns3} \rtTokByNum{1}\eAns
    \Ans{0} Wow, \rtTokByNum{2}, this is great!\eAns
    \Ans{0} \rtTokByNum{3}\eAns
    \Ans{0} \rtTokByNum{4}\eAns
\eFreeze
    \Ans{1} Hello mom!\eAns
\eChoices
\end{manswers}
\begin{solution}
The answer is \useSavedAlts{rtAns}, or to be more precise,
\useSavedAltsAns{rtAns}. \hyperref[rtAns3]{(\REF*{rtAns3})}
\end{solution}

    \item Which is true? (Ans: \hyperref[rtAns1]{(\REF*{rtAns1})})
\useRTName{myChoices}
\begin{answers}*{3}
    \bChoices[random,nCols=2]
        \Ans{1}\label{rtAns1} \rtTokByNum{1}\eAns
        \Ans{0} \rtTokByNum{2}\eAns
        \Ans{0} \rtTokByNum{3}\eAns
        \Ans{0} \rtTokByNum{4}\eAns
    \eChoices
\end{answers}
\begin{solution}
The answer is \hyperref[rtAns1]{(\REF*{rtAns1})} found in the
\nameref{rtAns1} on page~\pageref{rtAns1}.
\end{solution}

    \item Which is true?
\useRTName{myChoices}
\begin{answers}{3}
    \bChoices[random]
        \Ans{1} \rtTokByNum{1}\eAns
        \Ans{0} \rtTokByNum{2}\eAns
        \Ans{0} \rtTokByNum{3}\eAns
        \Ans{0} \rtTokByNum{4}\eAns
    \eChoices
\end{answers}
\end{questions}
\end{quiz*}\quad\ScoreField\currQuiz\CorrButton\currQuiz

\end{document}
