Example #1
0
        /// <summary>
        ///  Returns a list of JudgeHasScoredTuple which indicates whether or not the judges are done judging this heat
        /// </summary>
        internal static List <JudgeHasScoredTuple> GetJudgeStatusListForCurrentHeat(Tournament t)
        {
            var list  = new List <JudgeHasScoredTuple>();
            var round = t.GetCurrentRound();

            if (round == null)
            {
                return(list);
            }
            var heatNo                 = t.GetRoundCounter().GetHeatNo();
            var runNo                  = t.GetRoundCounter().GetRunNo();
            var heatContestants        = round.GetContestantsInHeat(heatNo);
            int criteriaCount          = t.JudgingCriteria.Count;
            int expectedJudgementCount = criteriaCount * heatContestants.Count();
            var contestantIds          = heatContestants.Select(p => p.Id).ToList();

            foreach (var judge in t.Judges)
            {
                var judgementCount = judge.RunJudgings.Count(p => p.RunNo == runNo && contestantIds.Contains(p.RoundContestantId));
                var tuplet         = new JudgeHasScoredTuple();
                tuplet.IsHeadJudge = judge.IsHeadJudge;
                tuplet.JudgeName   = judge.Name;
                tuplet.HasJudged   = judgementCount == expectedJudgementCount;
                list.Add(tuplet);
            }
            return(list);
        }
Example #2
0
        internal static List <JudgeHasScoredTuple> GetJudgeStatusListFor(Tournament t, RoundContestant rc, int runNo)
        {
            var list = new List <JudgeHasScoredTuple>();

            if (rc != null)
            {
                int criteriaCount = t.JudgingCriteria.Count;
                foreach (var judge in t.Judges)
                {
                    var tuplet = new JudgeHasScoredTuple();
                    tuplet.JudgeName = judge.Name;
                    tuplet.HasJudged = rc.IsJudgedBy(judge, runNo, criteriaCount);
                    list.Add(tuplet);
                }
            }
            return(list);
        }
Example #3
0
        public SpeakerViewModel(Tournament tournament, int?roundNo = null)
        {
            var   m     = this;
            Round round = null;

            if (roundNo != null)
            {
                round = tournament.GetRoundNo(roundNo.Value);
                if (round == null)
                {
                    throw new ArgumentException(String.Format("RoundNo {0} does not exist", roundNo));
                }
            }
            else
            {
                round = tournament.GetCurrentOrDefaultRound();
            }

            if (round == null)
            {
                throw new ArgumentException("Tournament is not started or has no rounds");
            }
            m.Tournament         = tournament;
            m.Round              = round;
            m.CurrentContestants = new List <Contestant>();
            m.JudgeStatus        = new List <JudgeHasScoredTuple>();
            if (round.Status == TournamentStatus.Running)
            {
                m.CurrentHeatNo      = tournament.GetRoundCounter().GetHeatNo();
                m.CurrentRunNo       = tournament.GetRoundCounter().GetRunNo();
                m.CurrentContestants = round.GetContestantsInHeat(m.CurrentHeatNo).Select(p => p.Contestant).ToList();
                m.JudgeStatus        = JudgeHasScoredTuple.GetJudgeStatusListForCurrentHeat(tournament);
            }
            m.Heats                 = HeatViewModel.CreateListFrom(round.GetContestantEntriesOrdered());
            m.ContestantsFlat       = m.Heats.SelectMany(p => p.Contestants).ToList();
            m.DisplayContestantList = m.Round.Status != TournamentStatus.Prestart;
            m.RoundCount            = m.Tournament.Rounds.Count;
            m.DisableStartButton    = m.Round.Status != TournamentStatus.Running;
            m.HasNextRound          = tournament.DoesRoundNoExist(round.RoundNo + 1);
            m.HasPreviousRound      = tournament.DoesRoundNoExist(round.RoundNo - 1);
            m.RunControlModel       = new RunControls(m.Tournament, m.Round);
            m.HasHeats              = m.Heats.Any(p => p.Contestants.Count != 1);
        }