2

I have some questions in Database.tex (6 questions).

\documentclass{article}
\usepackage{fouriernc}
\usepackage[paperwidth=17cm, paperheight=24cm, left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{exsheets}
\SetupExSheets{
  counter-within = subsection ,
  counter-format = \thesection.qu.,
  headings=runin
}
\SetupExSheets[question]{type=exam, name=Problem}
\begin{document}
\section{Random}
\subsection{The first way}
\includequestions[random={2}]{Database_English.tex}
\subsection{Second way}
\subsection{Odd label}
\includequestions[IDs={q1,q3,q5}]{Database_English.tex}
\subsection{Even label}
\includequestions[IDs={q2,q4,q6}]{Database_English.tex}
\section{Solutions}
\printsolutions
\end{document} 

Database.tex

\begin{question}[ID=q1]
The question was labeled q1.
\end{question}
\begin{solution}
Solution.
\end{solution}
\begin{question}[ID=q2]
The question was labeled q2.
\end{question}
\begin{question}[ID=q3]
The question was labeled q3.
\end{question}

\begin{question}[ID=q4]
The question was labeled q4.
\end{question}

\begin{question}[ID=q5]
The question was labeled q5.
\end{question}

\begin{question}[ID=q6]
The question was labeled q6.
\end{question}

Now I select random with following rules.

  1. The questions were labeled with odd numbers. I tried

    \includequestions[IDs={q1,q3,q5}]{Database.tex}

  2. The questions were labeled with even numbers. I tried

    \includequestions[IDs={q2,q4,q6}]{Database.tex}

  3. selected 2 questions

    \includequestions[random={2}]{Database.tex}

enter image description here

My problem is If I have 100 questions. How can I select

  1. Questions 1, 3, 5, ..., 99?
  2. Questions 2, 4, 6, ..., 100?
  3. Questions 3, 6, 9, ..., 3k?
  4. Questions from 1 to 30?
1
  • The ranges you ask at the bottom of your question are not random at all... – Skillmon Jul 19 '17 at 18:13
3

I didn't solve my problem with exsheets. I tried with xsim.

\documentclass{article}
\usepackage[paperwidth=17cm, paperheight=24cm, left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{fouriernc}
\usepackage{xsim,pgffor}
\usepackage{needspace}
\DeclareExerciseEnvironmentTemplate{runin}
{%
\par\vspace{\baselineskip}
\Needspace * {2\baselineskip}
\noindent
\textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}%
\GetExercisePropertyT{subtitle}{ \textit{#1}} %
\GetExercisePropertyT{points}{%
\marginpar{%
\PropertyValue
\GetExercisePropertyT{bonus-points}{+\PropertyValue}%
\,\IfExerciseGoalSingularTF{points}
 {\XSIMtranslate{point}}
{\XSIMtranslate{points}}%
 }%
 }%
 }
 {}
\xsimsetup{
exercise/within=section ,
exercise/template=runin,
solution/template=runin,
solution/print = true,
exercise/the-counter = \thesection.\arabic{exercise}.}
\DeclareExerciseCollection{exam}

\begin{document}

\collectexercises{exam}
\begin{exercise}[ID=q1]
  1
\end{exercise}
\begin{solution}
  1
\end{solution}
\begin{exercise}[ID=q2]
  2
\end{exercise}
\begin{exercise}[ID=q3]
  3
\end{exercise}
\begin{exercise}[ID=q4]
  4
\end{exercise}
\begin{exercise}[ID=q5]
  5
\end{exercise}
\begin{exercise}[ID=q6]
  6
\end{exercise}
\begin{exercise}[ID=q7]
  7
\end{exercise}
\begin{exercise}[ID=q8]
  8
\end{exercise}
\begin{exercise}[ID=q9]
  9
\end{exercise}

\begin{exercise}[ID=q10]
  10
\end{exercise}
\collectexercisesstop{exam}

\section{All labels}
\foreach \x in {1,2,...,10}{
  \XSIMexpandcode{\printexercise{exercise}{\x}}
}

\section{Some labels}
\subsection{Type 1}
\foreach \x in {3,4,...,10}{
  \XSIMexpandcode{\printexercise{exercise}{\x}}
}
\subsection{Type 2, any order}
\foreach \x in {9,7,6,3}{
  \XSIMexpandcode{\printexercise{exercise}{\x}}
}
\section{Odd labels}
\foreach \x in {1,3,...,10}{
  \XSIMexpandcode{\printexercise{exercise}{\x}}
}
\section{Even labels}
\foreach \x in {2,4,...,10}{
  \XSIMexpandcode{\printexercise{exercise}{\x}}
}
\section{Random}
\subsection{Firt time}
\printrandomexercises[collection=exam]{2}
\subsection{Second time}
\printrandomexercises[collection=exam]{2}
\section{Answers}
\printsolutions
\end{document} 

enter image description here

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.