Ejemplo n.º 1
0
        protected virtual IQuestion Generate(XMLResource xmlTemplate, Model model)
        {
            var unresolvedQuestionContent = xmlTemplate.GetQuestionContent();
            var resolvedQuestionContent   = _textResolver.Resolve(unresolvedQuestionContent, model);
            var layout = _layoutConverter.ConvertLayout(resolvedQuestionContent);

            var question = new Question();

            question.Model            = model;
            question.Content          = layout;
            question.CorrectAnswers   = CalculateCorrectAnswers(xmlTemplate, model);
            question.IncorrectAnswers = CalculateIncorrectAnswers(xmlTemplate, model);
            question.Hints            = GenerateHints(xmlTemplate, model);

            return(question);
        }
Ejemplo n.º 2
0
        protected virtual IList <IHint> GenerateHints(XMLResource xmlTemplate, Model model)
        {
            var hints         = new List <IHint>();
            var numberOfHints = xmlTemplate.GetNumberOfHints();

            for (var a = 0; a < numberOfHints; a++)
            {
                var unresolvedQuestionContent = xmlTemplate.GetHintContent(a + 1);
                var layout = _layoutConverter.ConvertLayout(unresolvedQuestionContent);

                var hint = new Hint();

                hint.Content = layout;

                hints.Add(hint);
            }

            return(hints);
        }
Ejemplo n.º 3
0
        protected virtual IList <IAnswer> CalculateIncorrectAnswers(XMLResource xmlTemplate, Model model)
        {
            var incorrectAnswers         = new List <IAnswer>();
            var numberOfIncorrectAnswers = xmlTemplate.GetNumberOfIncorrectAnswers();

            for (var a = 0; a < numberOfIncorrectAnswers; a++)
            {
                var unresolvedAnswerContent = xmlTemplate.GetIncorrectAnswerContent(a + 1);
                var resolvedAnswerContent   = _textResolver.Resolve(unresolvedAnswerContent, model);
                var layout = _layoutConverter.ConvertLayout(resolvedAnswerContent);

                var incorrectAnswer = new Answer();

                incorrectAnswer.Type    = AnswerType.Expression;
                incorrectAnswer.Content = layout;

                incorrectAnswers.Add(incorrectAnswer);
            }

            return(incorrectAnswers);
        }