I am about to start prototyping a 'quiz'-like web application that tests test-scoring methodologies, and I have an interesting architectural question.
Each quiz given to a user needs to use a set methodology to score it (e.g. Formula Scoring, Number Right Scoring, Negative Marking, etc.). A quiz consists of a series of questions, asked one by one, whose score is calculated after each question answered. The user's quiz score, among other things, is used to select the next question of appropriate difficulty for the user's progress so far, from a pool of theoretically infinite questions.
Beyond the scoring methodologies used to calculate the score, the 'next question' aspect of the program will be quite complex; it is tightly coupled with the structure of the data (e.g. a user will have to answer a medium
-difficulty question from X
topic... and more criteria).
I would like to separate out the logic of the scoring methodologies and 'next question' aspect of the application in order to keep the web application simple. The library could accept a set of inputs (e.g. the set of questions answered by the user), and the methodology to be used, in order to calculate the running score as well as select the next question. If I make changes to the library code that affects score calculation, the database would have incorrect data. I could re-calculate all scores after affecting such a change, but that could cause confusion to users who already got their final scores (this is just speculation, I don't know how 'open' of a project this will be).
The problem is that the logic is, as far as I have mapped it out thus far, tightly coupled to the structure of the data (e.g. a question has a list of topics, which could be used to choose the next question). Not only that, but the results given by the library need to be stored by the database for in-progress, as well as completed quizzes.
I would also like to make the logic of the application open source for academic purposes, so separating it out into a dependency would make this quite a bit easier (I don't necessarily want to open source the web application).
How can I decouple this data from the logic of the components so that I can separate it out as a dependency?
If necessary, I can whiteboard out the overall structure and goals of the application and update my question to make the description of my problem more clear.