[Tex/LaTex] Questions on designing a dynamic database of exercises

automationexercisesexsheetsprobsoln

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?

Best Answer

Sorry (again) for un-digging a (very) old topic.

If I may add something to the previous answer, there are (at least) two programs who were designed to do that (opensource, with a GUI). So, this answers the "other approach" part, not the "pure LaTeX" one.

Basically, it will go recursively through one specific folder to find your .tex files and all your exercises in them. You can then click on a file containing exercises and it will compile it on-the-fly to show you the exercises : add the ones you want to your final document and then export it (to a tex or a pdf).

  • TeXoMaker (disclaimer: I am not the author ;))

This one works almost like the previous one except that you first have to create a database of exercises and only then can you use it.

In both softwares you have a "search" functionnality so you can use metadata if you want and, for example, display only difficult exercises.

At least in TeXamator you can add randomly selected exercises (maybe in TeXoMaker also, but I can't say for sure).

Hope this helps !