# Questions on designing a dynamic database of exercises

Almost all packages to handle exercises allow us to attach/retrieve meta-data to/from each exercise.

Some things one might want when handling exercises are:

• Filter exercises according to their meta-data.
• Select random exercises from an external file.
• Have dynamic data associated to each exercise.

The first and second things are already addressed by the packages exsheets and prob­soln.

What I'm referring to by "dynamic data" is data that can change with time. For example a key tused to store the number of times an exercise have been used in past documents.

As far as I know, this have not been covered yet.

Now, let me be more specific:

# The problems to solve

Say I want to use the exsheets package to handle the questions for my exams. So I do something like \DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}, where lsused/lyused are last semester/year the question have been used and tused is as explained above.

I can choose random questions by topic (by putting them in separate external files). So I have one file for each topic, and in each file questions like

\begin{question}[ID=L1]
\SetQuestionProperties{difficulty=hard,topic=logic,lsused=1,lyused=2011,tused=3}
Proof that this is not our first very hard question.
\end{question}


I need to see the IDs of the questions in order to decide which to keep and which to discard. Let's call this the "selection stage". Say my exam must have 9 questions, so I do something like:

\documentclass{article}
\usepackage{exsheets}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}
\DebugExSheets{true}

\begin{document}
\includequestions[random=3,difficulty=easy]{logic}
\includequestions[random=3,difficulty=medium]{arithmetic}
\includequestions[random=3,difficulty=hard]{geometry}
\end{document}


Notice that if I compile this file many times I'll probably get a different set of questions each time.

Here is where the first problem arises: I'm not sure if we can filter questions according user-defined properties. It will be useful to avoid questions by ID, for example some:

\includequestions[random=3,difficulty=easy,noIDs={L5,L6}]{logic}


And, even if we can do so, it would be better to have some way to enter in a "preliminary stage" which allow us to keep the exercises obtained in the last compilation (say by storing their IDs and the topic/file they belong to in an external file) on the "selection stage" and just change the questions we do not want.

Suppose that the package which solves all this problems is called upackage. And that it provides ways to say which stage we are in. Suppose all the unknown commands that appear hereafter are provided by this package. So in the first stage I do something like:

\documentclass{article}

\usepackage{exsheets}
\usepackage{upackage}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}
\DebugExSheets{true}

\begin{document}
\setstage{selection}
\includequestions[random=3,difficulty=easy]{logic}
\includequestions[random=3,difficulty=medium]{arithmetic}
\includequestions[random=3,difficulty=hard]{geometry}
\end{document}


Suppose that after compile this, I like all the questions except the second geometry question. So I do:

\documentclass{article}

\usepackage{exsheets}
\usepackage{upackage}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}
\DebugExSheets{true}

\begin{document}
\setstage{preliminary}
\changequestion{number=2,topic=geometry}
\end{document}


What I expect from this is, the same set of questions I got before but with a different second geometry question. And if still do not like it, I just compile again. This is a bit complex since it must keep track of the unwanted questions list. Here I assuming that file names and topics are the same.

Once I decide that the 9 questions are fine, then I just do:

\documentclass{article}

\usepackage{exsheets}
\usepackage{upackage}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}

\begin{document}
\setstage{final}
\end{document}


And I get the questions this time without displaying their IDs. And here is where the other problem comes. Suppose that the package allow us to set \currentsemester and \currentyear (which by default must be \year). I would like that when the document is marked as final, the properties lsused, lyused get updated in the corresponding questions, as well as the tused which must be incremented in one. This will be useful to set, say, a \tolerance. For example if I set \tolerance{2} and I'm in the first semester of 2013, this will avoid including questions used in the past year.

So the process to build an exam should be, in short:

Selection:

\documentclass{article}
\usepackage{exsheets}
\usepackage{upackage}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}
\DebugExSheets{true}

\currentsemester{1}
\currentyear{2013}
\tolerance{2}

\begin{document}
\setstage{selection}
\includequestions[random=3,difficulty=easy]{logic}
\includequestions[random=3,difficulty=medium]{arithmetic}
\includequestions[random=3,difficulty=hard]{geometry}
\end{document}


Preliminary:

\documentclass{article}

\usepackage{exsheets}
\usepackage{upackage}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}
\DebugExSheets{true}

\currentsemester{1}
\currentyear{2013}
\tolerance{2}

\begin{document}
\setstage{preliminary}
\changequestion{number=2,topic=geometry}
\end{document}


until the second geometry question is acceptable.

Final:

\documentclass{article}

\usepackage{exsheets}
\usepackage{upackage}

\DeclareQuestionProperty{difficulty,topic,lsused,lyused,tused}
\DebugExSheets{true}

\currentsemester{1}
\currentyear{2013}
\tolerance{2}

\begin{document}
\setstage{final}
\end{document}


# Questions

My questions, is it plausible to achieve things like this with TeX/LaTeX? Is there some other approach? How to solve these problems?

-
Just found SQLTeX! – leo Mar 2 at 2:52
It's not possible to filter questions by properties with exsheets. But it shouldn't be too complicated to add... If I find the time I'll try to add something – cgnieder Mar 2 at 13:43
@cgnieder that sounds great! :-) If you find the time, please consider to add the feature to exclude exercises also. For example something like \includequestions[noIDs={L5,L6}]{logic} would include all the questions except those with ID L5and L6. – leo Mar 2 at 14:42
this should also be doable – cgnieder Mar 2 at 14:45
I just uploaded v0.8 to CTAN. It adresses at least the exsheets related issues of your question. – cgnieder Mar 10 at 11:13