Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow postgame #543

Merged
merged 3 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ServerCore/Pages/Events/FastestSolves.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public async Task OnGetAsync(SortOrder? sort, PuzzleStateFilter? stateFilter)

names.ForEach(t => teamNameLookup[t.ID] = t.Name);

DateTime submissionEnd = Event.AnswerSubmissionEnd;
// get the page data: puzzle, solve count, top three fastest
var puzzlesData = await PuzzleStateHelper.GetSparseQuery(_context, this.Event, null, null)
.Where(s => s.SolvedTime != null && s.Puzzle.IsPuzzle)
.Where(s => s.SolvedTime != null && s.Puzzle.IsPuzzle && s.SolvedTime <= submissionEnd)
.GroupBy(state => state.Puzzle)
.Select(g => new {
Puzzle = g.Key,
Expand Down
3 changes: 2 additions & 1 deletion ServerCore/Pages/Events/Standings.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public async Task OnGetAsync(SortOrder? sort)
.Where(p => p.Event == Event && p.IsPuzzle)
.ToDictionaryAsync(p => p.ID, p => new { p.SolveValue, p.IsCheatCode, p.IsFinalPuzzle });

DateTime submissionEnd = Event.AnswerSubmissionEnd;
var stateData = await PuzzleStateHelper.GetSparseQuery(_context, this.Event, null, null)
.Where(pspt => pspt.SolvedTime != null)
.Where(pspt => pspt.SolvedTime != null && pspt.SolvedTime <= submissionEnd)
.Select(pspt => new { pspt.PuzzleID, pspt.TeamID, pspt.SolvedTime })
.ToListAsync();

Expand Down
55 changes: 34 additions & 21 deletions ServerCore/Pages/Submissions/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
</div>
<br />
}
<div class="row">
<div class="col-md-4">
@if (Model.Puzzle.HasDataConfirmation)
{
<div style="font-style:italic;">
Expand All @@ -72,12 +70,18 @@
<h4>Correct</h4>
<span>Answer: @Model.AnswerToken</span>
</div>

@if (Model.PuzzleState.SolvedTime > Model.Event.AnswerSubmissionEnd)
{
<div class="alert alert-warning" role="alert">
<span>You solved this after the event ended and it did not count toward your ranking.</span>
</div>
}
}
else if (!@Model.Event.IsAnswerSubmissionActive)
else if (DateTime.UtcNow < Model.Event.EventBegin)
{
<div class="col-md-12" style="padding-bottom: 15px;">
<h4>Answer Submission Closed</h4>
<span>No submissions will be accepted at this time.</span>
<h3>This event is not yet in session. No submissions will be accepted at this time.</h3>
</div>
}
else if (Model.PuzzleState.IsEmailOnlyMode)
Expand All @@ -103,30 +107,39 @@
}
else
{
if (Model.DuplicateSubmission)
if (DateTime.UtcNow > @Model.Event.AnswerSubmissionEnd)
{
<div class="alert alert-warning" role="alert">
<h4>The event is over.</h4>
<span>You may check answers, but they will not count toward your ranking.</span>
</div>
}

@if (Model.DuplicateSubmission)
{
<div class="alert alert-danger" role="alert">
<h4>Oops</h4>
<span>You've already submitted @Model.SubmissionText!</span>
</div>
}

<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label class="control-label">Answer</label>
<input autofocus name="submissionText" class="form-control" data-val="true" data-val-required="Your answer cannot be empty" />
<span style="font-size:12px">Submitted answers will automatically be capitalized and stripped of non-alphanumeric characters</span><br />
@Html.ValidationSummary(true)
<span class="text-danger"><span class="field-validation-valid" data-valmsg-for="submissionText" data-valmsg-replace="true"></span></span>
</div>
<div class="form-group">
<input type="submit" value="Submit" class="btn btn-default" />
<div class="row">
morganbr marked this conversation as resolved.
Show resolved Hide resolved
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label class="control-label">Answer</label>
<input name="submissionText" class="form-control" data-val="true" data-val-required="Your answer cannot be empty" />
<span style="font-size:12px">Submitted answers will automatically be capitalized and stripped of non-alphanumeric characters</span><br />
@Html.ValidationSummary(true)
<span class="text-danger"><span class="field-validation-valid" data-valmsg-for="submissionText" data-valmsg-replace="true"></span></span>
</div>
<div class="form-group">
<input type="submit" value="Submit" class="btn btn-default" />
</div>
</form>
</div>
</form>
</div>
}
</div>
</div>

@if (Model.SubmissionViews.Count > 0)
{
Expand Down
6 changes: 3 additions & 3 deletions ServerCore/Pages/Submissions/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public async Task<IActionResult> OnPostAsync(int puzzleId, string submissionText
}

SubmissionText = submissionText;
if (!this.Event.IsAnswerSubmissionActive)
if (DateTime.UtcNow < Event.EventBegin)
{
return Page();
return NotFound("The event hasn't started yet!");
}

await SetupContext(puzzleId);
Expand Down Expand Up @@ -126,7 +126,7 @@ await PuzzleStateHelper.SetSolveStateAsync(_context,

AnswerToken = submission.SubmissionText;
}
else if (submission.Response == null)
else if (submission.Response == null && Event.IsAnswerSubmissionActive)
{
// We also determine if the puzzle should be set to email-only mode.
if (IsPuzzleSubmissionLimitReached(
morganbr marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
14 changes: 11 additions & 3 deletions ServerCore/Pages/Teams/Play.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
ViewData["AuthorRoute"] = "/Puzzles/Index";
// Needs route data - ViewData["PlayRoute"] = "/Teams/Play";

Boolean unsolvedFilter = Model.StateFilter == PlayModel.PuzzleStateFilter.Unsolved;
bool unsolvedFilter = Model.StateFilter == PlayModel.PuzzleStateFilter.Unsolved;
bool canSubmit = DateTime.UtcNow >= Model.Event.EventBegin;
}
<style>
.radioButton {
Expand All @@ -24,6 +25,13 @@
</style>

<h2>Puzzles</h2>
@if (DateTime.UtcNow > @Model.Event.AnswerSubmissionEnd)
{
<div class="alert alert-warning" role="alert">
<h4>The event is over.</h4>
<span>You may check answers, but they will not count toward your ranking.</span>
</div>
}
<div>
<a asp-page="/Teams/Answers" asp-route-teamId="@Model.TeamID">View All Correct Answers</a>
</div>
Expand Down Expand Up @@ -131,13 +139,13 @@
{
<text>Solved on </text>@Html.Raw(Model.LocalTime(item.SolvedTime))
}
else if (@Model.Event.IsAnswerSubmissionActive)
else if (canSubmit)
{
<text>Submit Answer</text>
}
else
{
<text>See past submissions</text>
<text>Not yet available</text>
}
</a>
</td>
Expand Down