I am trying to create a database of maths questions and answers in TeX form. The idea is that a simple command such as \getfromDB{101} will pull the text from the database of the question numbered 101. The solutions should be included in the text source with the question. Hence a typical entry in the database is:
What is the answer? \solution{This is it!}
A user can simply put the \getfromDB{101} text in their document as they like: say, within a list/enumerate/theorem, numbered whichever way they want. Now if all questions were like this, then I think that there are all sorts of options and packages available that can redefine the \solution macro the way any user would like.
But some questions come in parts:
This question has two parts:
\begin{parts}
\item Part one \solution{Part 1 answer}
\item Part two \solution{Part 2 answer}
\end{parts}
Again the idea is that the user can define the parts environment the way they like, but so far I haven't found a suitable package that can help with a suitable redefinition of the \solution macro.
I have looked at the following packages and so far I haven't been smart enough to solve my problem: answers and exsheets. Can anyone point me in an appropriate direction?

\getfromDB. – cgnieder Oct 24 '12 at 07:49exheetsneeds every solution after the question it belongs to. But my linked answer shows a way around that! – cgnieder Oct 24 '12 at 07:50