Ejemplo n.º 1
0
        /// <summary>
        /// Gets the percentage of entrants.
        /// </summary>
        /// <param name="answer">
        /// The possible answer.
        /// </param>
        /// <returns>
        /// The percentage of entrants for a given answer.
        /// </returns>
        public decimal GetPercentageOfEntrants(CompetitionAnswer answer)
        {
            if (ValidEntrants.Any())
            {
                return((decimal)ValidEntrants.Count(e => e.Answer == answer) / ValidEntrants.Count() * 100);
            }

            return(0);
        }
Ejemplo n.º 2
0
        public void SetCompetitionAnswer(CompetitionAnswer answer)
        {
            var participant = answer.CompetitionParticipant;

            ParticipantNo.Text = participant.No.ToString();
            RightCount.Text    = participant.AnsweredCorrect.ToString();
            WrongCount.Text    = (participant.AnsweredIncorrect + participant.Unanswered).ToString();
            Score.Text         = answer.Score.ToString("0.#");
            TotalScore.Text    = participant.Score.ToString("0.#");
            Rank.Text          = participant.Rank.ToString();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Asserts the answer count.
        /// </summary>
        /// <param name="answer">The answer.</param>
        /// <param name="expectedCount">The expected count.</param>
        private static void AssertAnswerCount(CompetitionAnswer answer, int expectedCount)
        {
            // Arrange
            Competition competition = Stubs.StubCompetition();

            // Act
            int count = competition.GetNumberOfEntrants(answer);

            // Assert
            Assert.AreEqual(expectedCount, count);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Asserts the answer percentage.
        /// </summary>
        /// <param name="answer">The answer.</param>
        /// <param name="expectedPercentage">The expected percentage.</param>
        private static void AssertAnswerPercentage(CompetitionAnswer answer, decimal expectedPercentage)
        {
            // Arrange
            Competition competition = Stubs.StubCompetition();

            // Act
            decimal percentage = competition.GetPercentageOfEntrants(answer);

            // Assert
            Assert.AreEqual(expectedPercentage, decimal.Round(percentage, 2));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the percentage of entrants.
        /// </summary>
        /// <param name="answer">
        /// The possible answer.
        /// </param>
        /// <returns>
        /// The percentage of entrants for a given answer.
        /// </returns>
        public decimal GetPercentageOfEntrants(CompetitionAnswer answer)
        {
            if (ValidEntrants.Any())
            {
                return (decimal)ValidEntrants.Count(e => e.Answer == answer) / ValidEntrants.Count() * 100;
            }

            return 0;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets the number of entrants.
 /// </summary>
 /// <param name="answer">
 /// The answer.
 /// </param>
 /// <returns>
 /// The number of entrants for a given answer.
 /// </returns>
 public int GetNumberOfEntrants(CompetitionAnswer answer)
 {
     return ValidEntrants.Any() ? ValidEntrants.Count(e => e.Answer == answer) : 0;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PossibleAnswer" /> class.
 /// </summary>
 /// <param name="isCorrectAnswer">if set to <c>true</c> [is correct answer].</param>
 /// <param name="answerKey">The answer key.</param>
 /// <param name="answerText">The answer text.</param>
 public PossibleAnswer(bool isCorrectAnswer, CompetitionAnswer answerKey, string answerText)
 {
     IsCorrectAnswer = isCorrectAnswer;
     AnswerKey = answerKey;
     AnswerText = answerText;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PossibleAnswer" /> class.
 /// </summary>
 /// <param name="answerKey">The answer key.</param>
 public PossibleAnswer(CompetitionAnswer answerKey)
 {
     IsCorrectAnswer = false;
     AnswerKey = answerKey;
     AnswerText = string.Empty;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Gets the number of entrants.
 /// </summary>
 /// <param name="answer">
 /// The answer.
 /// </param>
 /// <returns>
 /// The number of entrants for a given answer.
 /// </returns>
 public int GetNumberOfEntrants(CompetitionAnswer answer)
 {
     return(ValidEntrants.Any() ? ValidEntrants.Count(e => e.Answer == answer) : 0);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds the specified answer.
 /// </summary>
 /// <param name="answer">
 /// The answer.
 /// </param>
 /// <param name="description">
 /// The description.
 /// </param>
 /// <param name="isCorrectAnswer">
 /// if set to <c>true</c> [is correct answer].
 /// </param>
 public void Add(CompetitionAnswer answer, string description, bool isCorrectAnswer = false)
 {
     Add(new PossibleAnswer(isCorrectAnswer, answer, description));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PossibleAnswer"/> class.
 /// </summary>
 /// <param name="answerKey">
 /// The answer key.
 /// </param>
 public PossibleAnswer(CompetitionAnswer answerKey)
 {
     IsCorrectAnswer = false;
     AnswerKey       = answerKey;
     AnswerText      = string.Empty;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PossibleAnswer"/> class.
 /// </summary>
 /// <param name="isCorrectAnswer">
 /// if set to <c>true</c> [is correct answer].
 /// </param>
 /// <param name="answerKey">
 /// The answer key.
 /// </param>
 /// <param name="answerText">
 /// The answer text.
 /// </param>
 public PossibleAnswer(bool isCorrectAnswer, CompetitionAnswer answerKey, string answerText)
 {
     IsCorrectAnswer = isCorrectAnswer;
     AnswerKey       = answerKey;
     AnswerText      = answerText;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Adds the specified answer.
 /// </summary>
 /// <param name="answer">
 /// The answer.
 /// </param>
 /// <param name="description">
 /// The description.
 /// </param>
 /// <param name="isCorrectAnswer">
 /// if set to <c>true</c> [is correct answer].
 /// </param>
 public void Add(CompetitionAnswer answer, string description, bool isCorrectAnswer = false)
 {
     Add(new PossibleAnswer(isCorrectAnswer, answer, description));
 }