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

Jessica/unsolved filter #458

Merged
merged 28 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3ba1959
modified hi.md for Jessica
digit01Wave Aug 21, 2018
ebdf64b
merge master
digit01Wave Aug 26, 2018
941578f
branch 'master' of https://github.com/PuzzleServer/mainpuzzleserver
digit01Wave Aug 30, 2018
e540cfa
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Sep 5, 2018
869bcab
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Sep 11, 2018
d621e2d
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Sep 13, 2018
6f568da
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Sep 27, 2018
fbb2665
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Oct 10, 2018
85c7937
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Oct 11, 2018
eaacc29
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Oct 23, 2018
9fac0a6
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Oct 25, 2018
bddd19a
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Nov 6, 2018
feff9fa
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Nov 8, 2018
47af54f
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Nov 8, 2018
9b789b5
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Jan 13, 2019
0a9892b
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Jan 23, 2019
8cc94e6
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Jan 24, 2019
8d5a815
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Jan 25, 2019
6fbc5cf
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Jan 31, 2019
6d448c4
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Feb 27, 2019
cceec70
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Mar 21, 2019
66c855e
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Mar 28, 2019
d0b4687
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Apr 5, 2019
ee78b79
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Apr 10, 2019
7d981d3
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Apr 18, 2019
8ba8289
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave Apr 20, 2019
e3b39ce
Merge branch 'master' of https://github.com/PuzzleServer/mainpuzzlese…
digit01Wave May 16, 2019
39ffa0a
Reorder submissions and add radio button
digit01Wave May 16, 2019
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
10 changes: 5 additions & 5 deletions ServerCore/Pages/Submissions/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,20 @@
</tr>
</thead>
<tbody>
@foreach (var item in Model.Submissions)
@for (int i = Model.Submissions.Count-1; i >= 0; --i)
{
<tr>
<td>
@Html.Raw(Model.LocalTime(item.TimeSubmitted))
@Html.Raw(Model.LocalTime(Model.Submissions[i].TimeSubmitted))
</td>
<td>
@Html.DisplayFor(modelItem => item.Submitter.Name)
@Html.DisplayFor(modelItem => Model.Submissions[i].Submitter.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.SubmissionText)
@Html.DisplayFor(modelItem => Model.Submissions[i].SubmissionText)
</td>
<td>
@(item.Response != null ? item.Response.ResponseText : "Incorrect")
@(Model.Submissions[i].Response != null ? Model.Submissions[i].Response.ResponseText : "Incorrect")
</td>
</tr>
}
Expand Down
138 changes: 82 additions & 56 deletions ServerCore/Pages/Teams/Play.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,47 @@
ViewData["AdminRoute"] = "/Puzzles/Index";
ViewData["AuthorRoute"] = "/Puzzles/Index";
// Needs route data - ViewData["PlayRoute"] = "/Teams/Play";

Boolean unsolvedFilter = Model.StateFilter == PlayModel.PuzzleStateFilter.Unsolved;
}
<style>
.radioButton {
padding: 0px 5px;
color: inherit;
text-decoration: none;
}

.radioButton:hover {
color: inherit;
text-decoration: none;
cursor: pointer;
}
</style>

<h2>Puzzles</h2>
<div>
<a asp-page="/Teams/Answers" asp-route-teamId="@Model.TeamID">View All Correct Answers</a>
</div>
<br/>
<div>
<a class="radioButton" asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@Model.Sort" asp-route-stateFilter="@PlayModel.PuzzleStateFilter.All">
<input id="StateFilter" name="StateFilter" value="All" type="radio" @(unsolvedFilter ? "" : "checked")> All
</a>
<a class="radioButton" asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@Model.Sort" asp-route-stateFilter="@PlayModel.PuzzleStateFilter.Unsolved">
<input id="StateFilter" name="StateFilter" value="Unsolved" type="radio" @(unsolvedFilter ? "checked" : "")> Unsolved
</a>
</div>
<br/>
<table class="table">
<thead>
<tr>
<th>
<a asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@(Model.SortForColumnLink(PlayModel.SortOrder.GroupAscending, PlayModel.SortOrder.GroupDescending))">
<a asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@(Model.SortForColumnLink(PlayModel.SortOrder.GroupAscending, PlayModel.SortOrder.GroupDescending))" asp-route-stateFilter="@Model.StateFilter">
@Html.DisplayNameFor(model => model.PuzzleViews[0].Group)
</a>
</th>
<th>
<a asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@(Model.SortForColumnLink(PlayModel.SortOrder.PuzzleAscending, PlayModel.SortOrder.PuzzleDescending))">
<a asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@(Model.SortForColumnLink(PlayModel.SortOrder.PuzzleAscending, PlayModel.SortOrder.PuzzleDescending))" asp-route-stateFilter="@Model.StateFilter">
Puzzle
</a>
</th>
Expand All @@ -32,7 +57,7 @@
</th>
}
<th>
<a asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@(Model.SortForColumnLink(PlayModel.SortOrder.SolveAscending, PlayModel.SortOrder.SolveDescending))">
<a asp-page="./Play" asp-route-teamId="@Model.TeamID" asp-route-sort="@(Model.SortForColumnLink(PlayModel.SortOrder.SolveAscending, PlayModel.SortOrder.SolveDescending))" asp-route-stateFilter="@Model.StateFilter">
Solve
</a>
</th>
Expand All @@ -41,73 +66,74 @@
</th>
@if (Model.AllowFeedback)
{
<th>
Feedback
</th>
<th>
Feedback
</th>
}
</tr>
</thead>
<tbody>
@foreach (var item in Model.PuzzleViews) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Group)
</td>
<td>
@if (!string.IsNullOrWhiteSpace(item.Errata))
{
<text>&#x26A0; </text>
}

@if (item.CustomUrl != null)
{
<a href="@ServerCore.Helpers.PuzzleHelper.GetFormattedUrl(item.CustomUrl, item.ID, Model.Event.ID)" target="_blank">@item.Name</a>
}
else if (item.Content != null)
{
@Html.ActionLink(item.Name, "Index", "Files", new { eventId = Model.Event.ID, filename = item.Content.ShortName }, new { target = "_blank" })
}
else
{
@Html.DisplayFor(modelItem => item.Name)
}
</td>
@if (Model.ShowAnswers)
{
@foreach (var item in Model.PuzzleViews)
{
<tr>
<td>
@if (item.Answer != null)
@Html.DisplayFor(modelItem => item.Group)
</td>
<td>
@if (!string.IsNullOrWhiteSpace(item.Errata))
{
@Html.ActionLink("View answer", "Index", "Files", new { eventId = Model.Event.ID, filename = item.Answer.ShortName }, new { target = "_blank" })
<text>&#x26A0; </text>
}
</td>
}
<td>
<a asp-page="/Submissions/Index" asp-route-puzzleId="@item.ID">
@if (item.SolvedTime != null)

@if (item.CustomUrl != null)
{
<text>Solved on </text>@Html.Raw(Model.LocalTime(item.SolvedTime))
<a href="@ServerCore.Helpers.PuzzleHelper.GetFormattedUrl(item.CustomUrl, item.ID, Model.Event.ID)" target="_blank">@item.Name</a>
}
else if (@Model.Event.IsAnswerSubmissionActive)
else if (item.Content != null)
{
<text>Submit Answer</text>
@Html.ActionLink(item.Name, "Index", "Files", new { eventId = Model.Event.ID, filename = item.Content.ShortName }, new { target = "_blank" })
}
else
{
<text>See past submissions</text>
@Html.DisplayFor(modelItem => item.Name)
}
</a>
</td>
<td>
<a asp-page="./Hints" asp-route-puzzleid="@item.ID" asp-route-teamId="@Model.TeamID">Hints</a>
</td>
@if (Model.AllowFeedback)
{
<td>
<a asp-Page="/Puzzles/SubmitFeedback" asp-route-puzzleid="@item.ID">Submit feedback</a>
</td>
}
</tr>
}
</td>
@if (Model.ShowAnswers)
{
<td>
@if (item.Answer != null)
{
@Html.ActionLink("View answer", "Index", "Files", new { eventId = Model.Event.ID, filename = item.Answer.ShortName }, new { target = "_blank" })
}
</td>
}
<td>
<a asp-page="/Submissions/Index" asp-route-puzzleId="@item.ID">
@if (item.SolvedTime != null)
{
<text>Solved on </text>@Html.Raw(Model.LocalTime(item.SolvedTime))
}
else if (@Model.Event.IsAnswerSubmissionActive)
{
<text>Submit Answer</text>
}
else
{
<text>See past submissions</text>
}
</a>
</td>
<td>
<a asp-page="./Hints" asp-route-puzzleid="@item.ID" asp-route-teamId="@Model.TeamID">Hints</a>
</td>
@if (Model.AllowFeedback)
{
<td>
<a asp-Page="/Puzzles/SubmitFeedback" asp-route-puzzleid="@item.ID">Submit feedback</a>
</td>
}
</tr>
}
</tbody>
</table>

Expand Down
22 changes: 18 additions & 4 deletions ServerCore/Pages/Teams/Play.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public PlayModel(PuzzleServerContext serverContext, UserManager<IdentityUser> us

public IList<PuzzleView> PuzzleViews { get; set; }

public PuzzleStateFilter? StateFilter { get; set; }

public int TeamID { get; set; }

public SortOrder? Sort { get; set; }
Expand All @@ -35,7 +37,7 @@ public PlayModel(PuzzleServerContext serverContext, UserManager<IdentityUser> us

public bool AllowFeedback { get; set; }

public async Task OnGetAsync(SortOrder? sort, int teamId)
public async Task OnGetAsync(SortOrder? sort, int teamId, PuzzleStateFilter? stateFilter)
{
TeamID = teamId;
Team myTeam = await UserEventHelper.GetTeamForPlayer(_context, Event, LoggedInUser);
Expand All @@ -49,6 +51,7 @@ public async Task OnGetAsync(SortOrder? sort, int teamId)
throw new Exception("Not currently registered for a team");
}
this.Sort = sort;
this.StateFilter = stateFilter;

ShowAnswers = Event.AnswersAvailableBegin <= DateTime.UtcNow;
AllowFeedback = Event.AllowFeedback;
Expand Down Expand Up @@ -97,13 +100,18 @@ join PuzzleStatePerTeam pspt in stateForTeamQ on puzzle.ID equals pspt.PuzzleID
throw new ArgumentException($"unknown sort: {sort}");
}

if (this.StateFilter == PuzzleStateFilter.Unsolved)
{
visiblePuzzlesQ = visiblePuzzlesQ.Where(puzzles => puzzles.SolvedTime == null);
}

PuzzleViews = await visiblePuzzlesQ.ToListAsync();

Dictionary<int, ContentFile> files = await (from file in _context.ContentFiles
where file.Event == Event && file.FileType == ContentFileType.Puzzle
select file).ToDictionaryAsync(file => file.PuzzleID);

foreach(var puzzleView in PuzzleViews)
foreach (var puzzleView in PuzzleViews)
{
files.TryGetValue(puzzleView.ID, out ContentFile content);
puzzleView.Content = content;
Expand All @@ -112,8 +120,8 @@ join PuzzleStatePerTeam pspt in stateForTeamQ on puzzle.ID equals pspt.PuzzleID
if (ShowAnswers)
{
Dictionary<int, ContentFile> answers = await (from file in _context.ContentFiles
where file.Event == Event && file.FileType == ContentFileType.Answer
select file).ToDictionaryAsync(file => file.PuzzleID);
where file.Event == Event && file.FileType == ContentFileType.Answer
select file).ToDictionaryAsync(file => file.PuzzleID);

foreach (var puzzleView in PuzzleViews)
{
Expand Down Expand Up @@ -162,5 +170,11 @@ public enum SortOrder
SolveAscending,
SolveDescending
}

public enum PuzzleStateFilter
{
All,
Unsolved
}
}
}