示例#1
0
        public bool PreSelectPossibleAnswer(string text)
        {
            var answer = PossibleAnswers.FirstOrDefault(a => a.AnswerText == text);

            if (answer != null)
            {
                answer.IsSelected = true;
                IsPreSelected     = true;
            }

            return(answer != null);
        }
        /// <summary>
        /// Converts possible answers from request object to domain entity.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The <see cref="PossibleAnswers"/>.
        /// </returns>
        public PossibleAnswers Convert(ResolutionContext context)
        {
            var from = (IEnumerable <PossibleAnswerItem>)context.SourceValue;
            var pa   = new PossibleAnswers();

            for (int i = 0; i < from.Count(); i++)
            {
                var item = from.ElementAt(i);
                pa.Add(new PossibleAnswer(item.IsCorrectAnswer, (CompetitionAnswer)item.AnswerKey, item.AnswerText));
            }

            return(pa);
        }
        private ServiceModel.Questionnaire.Question LocalizeServiceCategoryQuestion(string locale, QuestionCategory c)
        {
            var questionsRes      = new Questions();
            var posibleAnswersRes = new PossibleAnswers();

            ServiceModel.Questionnaire.Question question = questionsRes.GetLocalizedQuestion(locale, c.CategoryQuestion.Description,
                                                                                             c.CategoryQuestion.Help, c.CategoryQuestion.QuestionId);
            c.CategoryQuestion.PossivbleAnswers.ForEach(pa => LocalizePosibleAnswer(locale, posibleAnswersRes, pa));

            question.PossivbleAnswers = posibleAnswersRes.PossivbleAnswersList;

            return(question);
        }
示例#4
0
        public void addTwoAnswerOptions()
        {
            PossibleAnswers.Add(Answer.Name);

            while (PossibleAnswers.Count < 3)
            {
                string friend = randomizeFriend().Name;
                if (!PossibleAnswers.Contains(friend))
                {
                    PossibleAnswers.Add(friend);
                }
            }

            PossibleAnswers.Shuffle();
        }
示例#5
0
        public override List <string> DisplayQuestion()
        {
            var returnList = new List <string>()
            {
                QuestionString,
                string.Empty
            };

            for (var i = 0; i < PossibleAnswers.Count(); i++)
            {
                returnList.Add(item: i + ". " + PossibleAnswers[i]);
            }

            return(returnList);
        }
示例#6
0
        public void NoAnswerSetAsCorrectIsNotValid()
        {
            // Arrange
            var possibleAnswers = new PossibleAnswers();

            possibleAnswers.Add(CompetitionAnswer.A, "Darth Vader");
            possibleAnswers.Add(CompetitionAnswer.B, "Obi Wan Kenobi");
            possibleAnswers.Add(CompetitionAnswer.C, "George Lucas");
            possibleAnswers.Add(CompetitionAnswer.D, "Walt Disney");

            // Act
            bool isValid = possibleAnswers.IsValid;

            // Assert
            Assert.IsFalse(isValid);
        }
示例#7
0
        public void PossibleAnswersIsValid()
        {
            // Arrange
            var possibleAnswers = new PossibleAnswers();

            possibleAnswers.Add(CompetitionAnswer.A, "Darth Vader", isCorrectAnswer: true);
            possibleAnswers.Add(CompetitionAnswer.B, "Obi Wan Kenobi");
            possibleAnswers.Add(CompetitionAnswer.C, "George Lucas");
            possibleAnswers.Add(CompetitionAnswer.D, "Walt Disney");

            // Act
            bool isValid = possibleAnswers.IsValid;

            // Assert
            Assert.IsTrue(isValid);
        }
        public PossibleAnswers IsHierarchic()
        {
            if (path != "")
            {
                d = FromMatrixToDegrees();
            }
            CalcParams();
            List <List <int> > p      = Polynom();
            PossibleAnswers    answer = Process(p);

            if (answer == PossibleAnswers.GraphicalBlockHierarchic)
            {
                MatrixToFile(BlockHierarchicMatrix(p));
            }
            return(answer);
        }
示例#9
0
        /// <summary>
        /// The get possible answers.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="PossibleAnswers"/>.
        /// </returns>
        private PossibleAnswers GetPossibleAnswers(Guid id)
        {
            var possibleAnswers = new PossibleAnswers();

            using (IDbConnection cn = Connection)
            {
                cn.Open();
                var result = cn.Query("SELECT * FROM PossibleAnswers WHERE CompetitionID=@CompetitionID", new { CompetitionID = id }).ToList();

                foreach (var row in result)
                {
                    possibleAnswers.Add(new PossibleAnswer(row.IsCorrectAnswer, (CompetitionAnswer)row.AnswerKey, row.AnswerText));
                }
            }

            return(possibleAnswers);
        }
示例#10
0
        public bool Equals(Question other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            var returned = Id == other.Id &&
                           QuestionText == other.QuestionText &&
                           State == other.State &&
                           Type == other.Type;

            returned = returned && PossibleAnswers.Aggregate(returned, (current, answer) => current && other.PossibleAnswers.Contains(answer));
            return(returned);
        }
示例#11
0
        public override QuestionDefinitionId?GetNextQuestionId(QuestionBase question)
        {
            var q = question as SingleSelectQuestionBase;

            if (q == null)
            {
                return(base.GetNextQuestionId(question));
            }

            var selectedAbswer = PossibleAnswers.Find(a => a.AnswerId == q.SelectedAnswer);

            QuestionDefinitionId?result = null;

            if (selectedAbswer != null)
            {
                result = selectedAbswer.NextQuestion;
            }

            return(result ?? base.GetNextQuestionId(question));
        }
示例#12
0
 public SurveyAnswer FindPossibleAnswer(string text)
 {
     return(PossibleAnswers.FirstOrDefault(a => a.AnswerText == text));
 }
 private void LocalizePosibleAnswer(string locale, PossibleAnswers posibleAnswersRes, PossivbleAnswer pa)
 {
     posibleAnswersRes.AddItem(locale, pa.Description, pa.Value, pa.Id);
 }
示例#14
0
 public override void AddChild(BaseEntity childToAdd)
 {
     PossibleAnswers.Add((PossibleAnswer)childToAdd);
 }
示例#15
0
 public void AddPossibleAnswer(AnswerDO variant)
 {
     PossibleAnswers.Add(variant);
 }
示例#16
0
文件: Task.cs 项目: 742PM/Quiz
 public bool Equals(Task other) =>
 string.Equals(Text, other.Text) && PossibleAnswers.SequenceEqual(other.PossibleAnswers) &&
 string.Equals(Question, other.Question) && Hints.SequenceEqual(other.Hints) &&
 string.Equals(Answer, other.Answer) && ParentGeneratorId.Equals(other.ParentGeneratorId);