Created
March 18, 2013 04:33
-
-
Save mbrowne/5185113 to your computer and use it in GitHub Desktop.
DCI Quiz Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FreeResponseQuizContext | |
{ | |
protected IEnumerable<Question> questions; | |
FreeResponseQuizContext(Student student, QuizTemplate quizTemplate) { | |
IEnumerable<QuestionTemplate> questionTemplates = quizTemplate.getQuestionTemplates(); | |
QuestionGenerator = questionTemplates; | |
AnswerCalculator = questionTemplates; | |
Student = student; | |
} | |
role QuestionGenerator { | |
IEnumerable<Question> generate() { | |
IEnumerable<QuestionTemplate> list = ((IEnumerable<QuestionTemplate>)self); | |
foreach (var questionTemplate in list) { | |
//add each parsed question to the 'questions' context property | |
//we're storing questions as a property of the context since we'll need them again | |
} | |
//return list of questions ready to display to the user | |
return questions; | |
} | |
} | |
role AnswerCalculator { | |
//similar idea to QuestionGenerator; loop through questions, calculate answer for each, | |
//and return the answers | |
IDictionary<Question, Answer> calculateAndReturn() { | |
... | |
} | |
} | |
role ScoreCalculator { | |
... | |
} | |
role Student { | |
//might not need this, it's just an idea | |
void answerQuestions() { | |
... | |
} | |
} | |
interaction IEnumerable<Question> generateQuestions() { | |
return QuestionGenerator.generate(); | |
} | |
interaction IDictionary<Question, Answer> calculateAnswers() { | |
return AnswerCalculator.calculateAndReturn(); | |
} | |
//How well did the student do? | |
interaction int calculateScore() { | |
return ScoreCalculator.calculate(); | |
} | |
} | |
class MultipleChoiceQuizContext | |
{ | |
MultipleChoiceQuizContext(Student student, QuizTemplate quizTemplate) { | |
... | |
} | |
role MultipleChoiceGenerator { | |
... | |
} | |
interaction IDictionary<Question, IEnumerable<Answer>> generateQuestionsAndChoices() { | |
//How to use QuestionGenerator? | |
//Need to use it in conjunction with MultipleChoiceGenerator | |
... | |
} | |
interaction int calculateScore() { | |
//How to use ScoreCalculator? | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment