Ejemplo n.º 1
0
        private IEnumerable <EvaluatedAnswer> KeyToEvaluatedAnswers(IEnumerable <KeyEntity> keyEntities, TestEntity testEntity)
        {
            var orderedAnswerOptions = testEntity.TestAnswerOptions
                                       .Select(tao => new { tao.Order, tao.AnswerOptionId });

            foreach (var keyEntity in keyEntities)
            {
                var currentQuestion = testEntity.Questions
                                      .Single(qe => qe.Id == keyEntity.QuestionId);

                if (testEntity.AreAnswerOptionsUnique)
                {
                    orderedAnswerOptions = currentQuestion
                                           .QuestionAnswerOptions
                                           .Select(qao => new { qao.Order, qao.AnswerOptionId });
                }
                int answerOptionIndex = orderedAnswerOptions
                                        .Single(oao => oao.AnswerOptionId == keyEntity.AnswerId)
                                        .Order;

                yield return(new EvaluatedAnswer
                {
                    AnswerIndex = answerOptionIndex,
                    QuestionIndex = currentQuestion.Order,
                    Points = keyEntity.Points
                });
            }
        }
Ejemplo n.º 2
0
 public TestWithScales(TestEntity testEntity) : base(testEntity)
 {
     Scales = testEntity.GetScales()
              .Select(se => new Scale(se, testEntity))
              .OrderBy(scale => scale.Name);
 }