public void ProcessAnswer(Answer answer)
        {
            QuizzerStrategyContext strategyContext = new QuizzerStrategyContext();

            strategyContext.SetContext(answer.GetAnswerType());
            string correspondingSymptom           = answer.GetCorrespondingSympton();
            IList <QuSignature> removedSignatures = new List <QuSignature>();


            foreach (var signature in symptomToSignatures[correspondingSymptom])
            {
                if (!strategyContext.GetStrategy().ApplyAnswerToSignature(signature, correspondingSymptom, answer))
                {
                    double percentage = (double)signature.currentScore / (double)signature.initialScore;
                    if (percentage < minValidPercentage)
                    {
                        removedSignatures.Add(signature);
                    }
                }
            }

            foreach (QuSignature signature in removedSignatures)
            {
                foreach (var symptom in signature.symptoms)
                {
                    symptomToSignatures[symptom.Key].Remove(signature);
                }
                signatures.Remove(signature);
            }
        }
Exemple #2
0
 public bool ProcessAnswer(Answer answer)
 {
     if (quizState != QUIZ_STATE.ANSWERING || answer.GetAnswerType() != currentQuestionType)
     {
         return(false);
     }
     symptomsHolder.ProcessAnswer(answer);
     answers.Add(answer);
     currentQuestionNumber++;
     quizState = QUIZ_STATE.ANSWERED;
     return(true);
 }