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?

  • 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 – clemens Sep 15 '17 at 12:44
  • I might have something but I don't have much time left... I will post a solution with xsim this weekend… – clemens Sep 15 '17 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 Sep 18 '17 at 11:34
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).

  • 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 Sep 20 '17 at 5:37
  • @deshmukh I sent the version to CTAN, the update should be available in a few days – clemens Sep 20 '17 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 Sep 27 '17 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! – clemens Sep 27 '17 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 Oct 4 '17 at 5:19

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.