1

Here in the MWE:

\documentclass{article}
\usepackage{exsheets}
\SetupExSheets{counter-format=}
\begin{document}
\begin{question}[name=Answer the following in one sentence]
  \begin{enumerate}
    \item Who is the President?
    \item Who is the Prime minister?
    \item \includequestions[random=2]{classA}
  \end{enumerate}
\end{question}
\end{document}

The contents of classA.tex are:

\begin{input}
  \begin{question}
    Who is the Defence Minister?
  \end{question}
  \begin{question}
    Who is the Home Minister?
  \end{question}
  \begin{question}
    Who is the Finance Minister?
  \end{question}
  \begin{question}
    Who is the External Affairs Minister?
  \end{question}
\end{input}

Here is how it looks when compiled:

Compiled Image

The problem is around Item No. 3. The question text is repeated and the counter does not advance.

How do I overcome this? So, it will select questions randomly and will assign item nos. 3 and 4 to them?

If exsheets can not do this, is there another package that can do this?

3
  • exsheets does not allow you to select random subquestions. You get exactly what is expected: nested question environments… it might be possible (with some fantasy) with xsim but I have to experiment first
    – cgnieder
    Commented Sep 15, 2017 at 12:44
  • I might have something but I don't have much time left... I will post a solution with xsim this weekend…
    – cgnieder
    Commented Sep 15, 2017 at 13:17
  • @clemens anything that will show me a way out? If not exsheets, is there any other pacakge that will do it? :)
    – deshmukh
    Commented Sep 18, 2017 at 11:34

1 Answer 1

1

I don't think a satisfactory solution can be obtained with exsheets but it can with its successor xsim – the trick is to define another exercise type solely used for the subquestions.

\documentclass{article}
\usepackage{xsim}

\DeclareExerciseType{subquestion}{
  exercise-env = question ,
  solution-env = answer ,
  exercise-name = Question ,
  solution-name = Answer ,
  exercise-template = item ,
  solution-template = item
}

\DeclareExerciseProperty{title}

\DeclareExerciseEnvironmentTemplate{named}
  {\subsection*{\GetExercisePropertyTF{title}{#1}{??}}}
  {}

\DeclareExerciseEnvironmentTemplate{item}
  {\item}
  {}

\xsimsetup{
  exercise/template = named
}

\DeclareExerciseCollection{exercise-pool}

\begin{filecontents*}{\jobname-exercises.tex}
\begin{question}
  Who is the Defence Minister?
\end{question}
\begin{question}
  Who is the Home Minister?
\end{question}
\begin{question}
  Who is the Finance Minister?
\end{question}
\begin{question}
  Who is the External Affairs Minister?
\end{question}
\end{filecontents*}

\begin{document}

\collectexercises{exercise-pool}
\input{\jobname-exercises.tex}
\collectexercisesstop{exercise-pool}

\begin{exercise}[title=Answer the following in one sentence:]
  \begin{enumerate}
    \item Who is the President?
    \item Who is the Prime Minister?
    \printrandomexercises[collection=exercise-pool]{2}
  \end{enumerate}
\end{exercise}

\end{document}

enter image description here


PS: the code requires xsim v0.10 which at the time of writing (2017-09-18 14:57 CEST) is not yet available but is on its way to CTAN (and the popular distributions).

16
  • this is exactly what I was looking for. But my xsim is not v0.10 so I am unable to confirm. I will keep an eye for xsim 0.10.
    – deshmukh
    Commented Sep 20, 2017 at 5:37
  • @deshmukh I sent the version to CTAN, the update should be available in a few days
    – cgnieder
    Commented Sep 20, 2017 at 8:31
  • I updated xsim to remote rev 45355 (0.10) and tried compiling the code. It fails. The log file shows: ! Undefined control sequence. l.211 \file_input_stop: ? ! Emergency stop. l.211 \file_input_stop: Does xsim need some other package that I might be missing?
    – deshmukh
    Commented Sep 27, 2017 at 10:51
  • @deshmukh never update a package alone. Always update your complete TeX distribution using the according package manager. You are missing updated versions of packages on which xsim relies upon!
    – cgnieder
    Commented Sep 27, 2017 at 11:32
  • Sorry, it took me so long to get back. I reinstalled TexLive2017 and compiled the file. But it does not show random questions. It shows only the first two questions. It showed an error that random numbers were not available so I installed lcg package. And recompiled. But still no luck. It still shows the static questions. Am I missing a package? Is there a way to share the logfile with you? It is too long to be copy-pasted here.
    – deshmukh
    Commented Oct 4, 2017 at 5:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .