在表格中选择之前未选择的问题

在表格中选择之前未选择的问题

是否可以使用exsheets随机选择最近未选择的问题(例如probsoln)?

答案1

只要付出一点努力,这肯定是可能的。需要做两件事:

  1. 更新先前包含的问题列表
  2. 在将该列表传递给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}

相关内容