protected BoardViewModel(int cid, IRankingStrategy rule, ProblemCollection problems, IContestTime time) { ContestId = cid; RankingStrategy = (rule as IRankingStrategyV2) ?? NullRank.Instance; Problems = problems; ContestTime = time; }
/// <summary> /// Initialize an time only model from existing time. /// </summary> public TimeOnlyModel(IContestTime time) { StartTime = time.StartTime; EndTime = time.EndTime; FreezeTime = time.FreezeTime; UnfreezeTime = time.UnfreezeTime; }
public ScoreboardModel( int cid, IReadOnlyDictionary <int, IScoreboardRow> data, IReadOnlyDictionary <int, Category> categories, IReadOnlyDictionary <int, Affiliation> affiliations, ProblemCollection problems, IContestTime time, IRankingStrategy rankingStrategy) : this( cid, rankingStrategy, time, data, categories, affiliations, problems, new SortOrderLookup(categories, data, true, rankingStrategy), new SortOrderLookup(categories, data, false, rankingStrategy)) { }
public ScoreboardModel( int cid, IRankingStrategy rule, IContestTime time, IReadOnlyDictionary <int, IScoreboardRow> data, IReadOnlyDictionary <int, Category> categories, IReadOnlyDictionary <int, Affiliation> affiliations, ProblemCollection problems, SortOrderLookup @public, SortOrderLookup restricted) { ContestId = cid; RankingStrategy = rule; Data = data; RefreshTime = DateTimeOffset.Now; Categories = categories; Affiliations = affiliations; Public = @public; Restricted = restricted; Problems = problems; ContestTime = time; }
public Statistics(ProblemStatisticsModel[] model, IRankingStrategyV2 rule, ProblemCollection problems, IContestTime time) => (_model, _rule, _problems, _time) = (model, rule, problems, time);
/// <summary> /// Gets the state of contest. /// </summary> /// <param name="time">The contest time.</param> /// <param name="nowTime">The current datetime.</param> /// <returns>The state of contest.</returns> public static ContestState GetState(IContestTime time, DateTimeOffset?nowTime = null) { // The implementation cannot depend on IContestTime.GetState(). var now = nowTime ?? DateTimeOffset.Now; DateTimeOffset?start = time.StartTime; if (!start.HasValue) { return(ContestState.NotScheduled); } if (start.Value > now) { // not started yet return(ContestState.ScheduledToStart); } TimeSpan?end = time.EndTime, freeze = time.FreezeTime, unfreeze = time.UnfreezeTime; if (!end.HasValue) { // This is a special state. Usually this field // should not be null. But in some cases (like // problemset types), this may be null. return(ContestState.Started); } var timeSpan = now - start.Value; if (freeze.HasValue) { // unfreezed if (unfreeze.HasValue && unfreeze.Value <= timeSpan) { return(ContestState.Finalized); } // ended, but not freezed if (end.Value <= timeSpan) { return(ContestState.Ended); } // freezed, but not ended if (freeze.Value <= timeSpan) { return(ContestState.Frozen); } // This contest may freeze later return(ContestState.Started); } else if (end.Value <= timeSpan) { return(ContestState.Finalized); } else { return(ContestState.Started); } }