是否可以使用exsheets
随机选择最近未选择的问题(例如probsoln
)?
答案1
只要付出一点努力,这肯定是可能的。需要做两件事:
- 更新先前包含的问题列表
- 在将该列表传递给
exclude
选项之前,请先展开该列表
以下代码通过将 的当前值附加\questionsincludedlast
到新定义的 的内容来启用第一个\includedquestions
。代码假设etoolbox
已加载包(由 加载exsheets
:
\newcommand*\includedquestions{}
\newrobustcmd*\updateincludedlist{%
\expandafter\ifblank\expandafter{\questionsincludedlast}
{}
{%
\expandafter\ifblank\expandafter{\includedquestions}
{\eappto\includedquestions{\questionsincludedlast}}
{\eappto\includedquestions{,\questionsincludedlast}}%
}%
}
下一个代码使用上面的代码将扩展列表传递给exclude
选项\includequestions
:
\newrobustcmd*\includequestionsX[1][]{%
\updateincludedlist
\edef\x{\includequestions[exclude={\includedquestions}}%
\x,#1]%
}
使用示例:
\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}