Beispiel #1
0
        public string Validate(int id, string answer, string userName)
        {
            IQuestionDAL questionDal = QuestionFactory.GetQuestionDAL();
            Question     question    = questionDal.GetQuestion(id);

            if (!questionDal.QuestionIsAlreadyAnswered(userName, id))
            {
                if (answer == question.CorrectAnswer)
                {
                    IAccountDAL accountDAL = AccountFactory.GetAccountDAL();
                    Account     account    = accountDAL.GetAccount(userName);
                    accountDAL.AddScore(account, 10);
                    questionDal.QuestionAnswered(userName, id);
                    return("Question answered correctly");
                }
                else
                {
                    questionDal.QuestionAnswered(userName, id);
                    return("Question answered incorrectly");
                }
            }
            else
            {
                return("Question already answered");
            }

            // id = 2
            // answer = 'correct'
        }