public Question(string symptomName, string questionText, Answer.QUESTION_TYPE questionType) { QuizzerStrategyContext quizzerStrategyContext = new QuizzerStrategyContext(); quizzerStrategyContext.SetContext(questionType); this.questionText = questionText; this.questionType = questionType; this.correspondingSymptom = symptomName; }
private Answer InitAnswer(SymptomContext context) { Quiz currentQuiz = quizHandler.GetQuizById(context.id); Answer.QUESTION_TYPE answerType = currentQuiz.GetCurrentQuestionType(); Answer answer = new Answer(answerType, currentQuiz.GetCurrentSymptom()); switch (answerType) { case Answer.QUESTION_TYPE.QUESTION_BOOLEAN: if (context.status > 0) { answer.SetAnswerBoolean(Answer.QUESTION_BOOLEAN.TRUE); } else { answer.SetAnswerBoolean(Answer.QUESTION_BOOLEAN.FALSE); } break; case Answer.QUESTION_TYPE.QUESTION_NUMBER: answer.SetAnswerNumeric(context.status); break; case Answer.QUESTION_TYPE.QUESTION_SICKNESS_LEVEL: switch (context.status) { case 0: answer.SetAnswerSicknessLevel(Answer.QUESTION_SICKNESS_LEVEL.ABSENT); break; case 1: answer.SetAnswerSicknessLevel(Answer.QUESTION_SICKNESS_LEVEL.LITTLE); break; case 2: answer.SetAnswerSicknessLevel(Answer.QUESTION_SICKNESS_LEVEL.MEDIUM); break; case 3: answer.SetAnswerSicknessLevel(Answer.QUESTION_SICKNESS_LEVEL.HIGH); break; } break; } return(answer); }
public void SetContext(Answer.QUESTION_TYPE questionType) { switch (questionType) { case Answer.QUESTION_TYPE.QUESTION_SICKNESS_LEVEL: quizzerStrategy = new QuestionSicknessLevelStrategy(); break; case Answer.QUESTION_TYPE.QUESTION_BOOLEAN: quizzerStrategy = new QuestionBooleanStrategy(); break; case Answer.QUESTION_TYPE.QUESTION_NUMBER: quizzerStrategy = new QuestionNumberStrategy(); break; } }
public Question GetNextQuestion() { if (quizState != QUIZ_STATE.ANSWERED) { return(null); } if (askedQuestions.Count >= maxQuestionCount || symptomsHolder.GetSignaturesCount() <= finalSignatureCount) { quizState = QUIZ_STATE.FINISHED; return(null); } quizState = QUIZ_STATE.ANSWERING; Question nextQuestion = symptomsHolder.GetNextQuestion(); currentQuestionType = nextQuestion.GetQuestionType(); currentSymptomType = nextQuestion.GetCorrespondingSymptom(); return(nextQuestion); }