1

Is it possibile, using exsheets, to randomly select not recently selected question (like probsoln does, for example)?

  • 1
    I think it's possible with something like \includequestions[random=??, exclude=\questionsincludedlast]{filename(s)}. You may want to append the list provided by \questionsincludedlast from selection to selection and remove the old entries after n selections depending on your understanding (preference) of the word "recently". – alwaysask Aug 13 '16 at 16:12
  • Thank you! Where is the \questionsincludelast list stored? – zar Aug 13 '16 at 19:17
  • 1
    \questionsincludelast is a macro, initially empty I presume, that returns a list of question IDs used at the previous \includequestions command -- see manual p.36. You'll have to use it to add the ID list it returns to your custom list, say \recentlist, which you create (empty) and then update (append the new IDs to it) after every new \includequestions. In other words, you'll have to create the code to store the lists \questionsincludelast returned after every extraction. That's the theory I had in mind anyway. – alwaysask Aug 13 '16 at 19:59
1

With a little bit of effort this is surely possible. Two things are necessary:

  1. update a clist of previously included questions
  2. expand said list before passing it to the exclude option

The following code enables the first by appending the current value of \questionsincludedlast to the contents of the newly defined \includedquestions. The code assumes the package etoolbox loaded (which is loaded by exsheets:

\newcommand*\includedquestions{}
\newrobustcmd*\updateincludedlist{%
  \expandafter\ifblank\expandafter{\questionsincludedlast}
    {}
    {%
      \expandafter\ifblank\expandafter{\includedquestions}
        {\eappto\includedquestions{\questionsincludedlast}}
        {\eappto\includedquestions{,\questionsincludedlast}}%
    }%
}

The next code uses the above to pass the expanded list to the exclude option of \includequestions:

\newrobustcmd*\includequestionsX[1][]{%
  \updateincludedlist
  \edef\x{\includequestions[exclude={\includedquestions}}%
  \x,#1]%
}

An example of usage:

\documentclass{article}
\usepackage{exsheets,filecontents}

\begin{filecontents*}{\jobname-questions.tex}
\begin{question}[ID=A]
  A
\end{question}
\begin{question}[ID=B]
  B
\end{question}
\begin{question}[ID=C]
  C
\end{question}
\begin{question}[ID=D]
  D
\end{question}
\begin{question}[ID=E]
  E
\end{question}
\begin{question}[ID=F]
  F
\end{question}
\begin{question}[ID=G]
  G
\end{question}
\begin{question}[ID=H]
  H
\end{question}
\begin{question}[ID=I]
  I
\end{question}
\begin{question}[ID=J]
  J
\end{question}
\end{filecontents*}

\newcommand*\includedquestions{}
\newrobustcmd*\updateincludedlist{%
  \expandafter\ifblank\expandafter{\questionsincludedlast}
    {}
    {%
      \expandafter\ifblank\expandafter{\includedquestions}
        {\eappto\includedquestions{\questionsincludedlast}}
        {\eappto\includedquestions{,\questionsincludedlast}}%
    }%
}

\newrobustcmd*\includequestionsX[1][]{%
  \updateincludedlist
  \edef\x{\includequestions[exclude={\includedquestions}}%
  \x,#1]%
}

\begin{document}

\includequestionsX[random=2]{\jobname-questions.tex}

\includequestionsX[random=2]{\jobname-questions.tex}

\includequestionsX[random=2]{\jobname-questions.tex}

\includequestionsX[random=2]{\jobname-questions.tex}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.