Help needed to develop a MCQ scoring system development
I am thinking to develop a MCQ scoring system. There will be three mode, easy, intermediate a开发者_StackOverflownd hard. Any new mode may be introduced later. Marking for each correct answer depends on mode. Every mode will have own implementation of marking system. There will be some bonus marking system, for say for three correct answer at once, bonus marks will be added to the total score. intermediate and hard mode will have negative marking system. So that's are my basic structure.
I will use this system in an android application. I'm confused about the design pattern which one is perfect.
so if I get any code sample or structure for it, it will be nice.
Thanks in Advance.
Hmm, there seems to be multiple facets to this question; I will answer your first and primary one:
Whenever I hear the words "There will be X of them, more to be added later", my thoughts immediately turn to the strategy pattern (GoF, google... Easy to find some UML for that), which primarily defines an interface for an algorithm.
In this case you would then implement 3 instances of this interface, and it wouldn't be a problem to define and add another algorithm later - it will just use the same interface.
I picture the method looking something like: public int markPaper(DataStructure mcq)
, if that helps you in any way.
EDIT: Oh, and check out "A singular choice for Multiple choice" by Schwartzbach & Frandsen - it's on google - The neatest way to do fair MCQ marking, and the one I have been suffering under the past year ; )
EDIT2: Ok, so to make this a little more explicit; In your main control flow, you might have a 'markPaper()' method. Since we want this to be modular, we will take all of this functionality, move it into a class implementing an interface for grading algorithms. What you might be inclined to write is this:
main(){
...
if (difficulty == 1){
[elaborate easy algorithm here...]
else if(...){
[slightly harder algorithm here...]
and so on. Instead, make an assisting method, say mark, and pass it an instance of that algorithm instead:
private int mark(GradingAlgorithmInterface algorithm, DataStructure paper){
algorithm.markPaper(paper);
}
main(){
...
if(difficulty == 1){
mark(new ConcreteEasyAlgorithm(), paper);
} else if () {...
And so on. Hope this helps.
精彩评论