public Task <IActionResult> Scoreboard(int cid, [FromQuery(Name = "affiliations[]")] int[] affiliations, [FromQuery(Name = "categories[]")] int[] categories, [FromQuery(Name = "clear")] string clear = "") => ScoreboardView( isPublic: Contest.GetState() < ContestState.Finalized, isJury: false, clear == "clear", affiliations, categories);
public async Task <IActionResult> ChangeTime( [FromRoute] int cid, [FromForm] DateTimeOffset?start_time) { var now = DateTimeOffset.Now; var newTime = start_time ?? (now + TimeSpan.FromSeconds(30)); var oldtime = Contest.StartTime.Value; if (Contest.GetState(now) >= Xylab.Contesting.Entities.ContestState.Started) { return(StatusCode(403)); // contest is started } if (newTime < now + TimeSpan.FromSeconds(29.5)) { return(StatusCode(403)); // new start time is in the past or within 30s } if (now + TimeSpan.FromSeconds(30) > oldtime) { return(StatusCode(403)); // left time } await Context.UpdateContestAsync( _ => new() { StartTime = newTime, }); await HttpContext.AuditAsync("changed time", $"{Contest.Id}", "via ccs-api"); return(Ok()); }
public async Task <IActionResult> SystemTest() { if (!CcsDefaults.SupportsRating || Contest.RankingStrategy != CcsDefaults.RuleCodeforces || Contest.Kind != CcsDefaults.KindDom) { return(NotFound()); } if (Contest.GetState() < ContestState.Ended) { return(Message("Launch system test", "Precheck failed. Contest should be over.", BootstrapColor.danger)); } if (Contest.Settings.SystemTestRejudgingId is int rejudgingid) { return(RedirectToAction(nameof(Detail), new { rejudgingid })); } var prevs = await Context.ListAsync(); var non_close = prevs.Where(r => !r.Applied.HasValue).Select(r => $"r{r.Id}").ToList(); if (non_close.Count > 0) { return(Message("Launch system test", $"Precheck failed. Rejudgings {string.Join(',', non_close)} are not closed.", BootstrapColor.danger)); } return(AskPost( title: "Launch system test", message: "Are you sure to run system test? This will cause heavy system load.", type: BootstrapColor.warning)); }
public async Task <IActionResult> Scoreboard(int cid) { ViewBag.Members = await Facade.Teams.ListMembersAsync(cid); return(await ScoreboardView( isPublic : Contest.GetState() < ContestState.Finalized, isJury : false, true, null, null)); }
async Task <CheckResult <Rejudging> > IRejudgingContext.SystemTestAsync(int uid) { if (Contest.GetState() < Entities.ContestState.Ended) { return(CheckResult <Rejudging> .Fail("Contest should be ended first.")); } if (Contest.Settings.SystemTestRejudgingId != null) { var rej = await Polygon.Rejudgings.FindAsync(Contest.Id, Contest.Settings.SystemTestRejudgingId.Value); return(rej != null ? CheckResult <Rejudging> .Succeed(rej) : CheckResult <Rejudging> .Fail($"Rejudging {Contest.Settings.SystemTestRejudgingId.Value} not found.")); } if (await Polygon.Rejudgings.CountUndoneAsync(Contest.Id) != 0) { return(CheckResult <Rejudging> .Fail("There's pending rejudgings.")); } var rejudging = new Rejudging { ContestId = Contest.Id, Reason = "System Test", StartTime = DateTimeOffset.Now, EndTime = DateTimeOffset.Now, IssuedBy = uid, OperatedBy = uid, Applied = true, }; rejudging = await Polygon.Rejudgings.CreateAsync(rejudging); var settings = Contest.Settings.Clone(); settings.SystemTestRejudgingId = rejudging.Id; var settingsJson = settings.ToJson(); await UpdateContestAsync(c => new Entities.Contest { SettingsJson = settingsJson }); var startTime = Contest.StartTime !.Value; var endTime = (Contest.StartTime + Contest.EndTime) !.Value; int count = await Polygon.Rejudgings.BatchRejudgeAsync( (s, j) => j.Status == Verdict.Accepted && s.Time >= startTime && s.Time <= endTime, rejudging, immediateApply : true, stageAsRunning : true); if (count == 0) { await Polygon.Rejudgings.DeleteAsync(rejudging); return(CheckResult <Rejudging> .Fail("There's no accepted submissions in this contest.")); } await Mediator.Publish(new Events.ScoreboardRefreshEvent(this)); await Db.Judgings .Where(j => j.RejudgingId == rejudging.Id) .BatchUpdateAsync(j => new Judging { Status = Verdict.Pending }); return(CheckResult <Rejudging> .Succeed(rejudging)); }