Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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);
        }