Skip to content

Commit 058467e

Browse files
committed
Fixed problem with ordering the columns in the results page (Fixes #467)
1 parent c84ca20 commit 058467e

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

Open Judge System/Web/OJS.Web/Areas/Administration/Controllers/ContestsExportController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ public FileResult Results(int id, bool compete)
4848
{
4949
Id = problem.Id,
5050
ProblemName = problem.Name,
51+
ProblemOrderBy = problem.OrderBy,
5152
ShowResult = problem.ShowResults,
5253
BestSubmission = problem.Submissions
5354
.Where(z => z.ParticipantId == participant.Id)
5455
.OrderByDescending(z => z.Points).ThenByDescending(z => z.Id)
5556
.Select(z => new { Id = z.Id, Points = z.Points })
5657
.FirstOrDefault()
5758
})
58-
.OrderBy(res => res.ProblemName),
59+
.OrderBy(res => res.ProblemOrderBy).ThenBy(res => res.ProblemName),
5960
})
6061
.ToList()
6162
.Select(x => new { Data = x, Total = x.ProblemResults.Where(y => y.ShowResult).Sum(y => y.BestSubmission == null ? 0 : y.BestSubmission.Points) })

Open Judge System/Web/OJS.Web/Areas/Contests/Controllers/ResultsController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,15 @@ public ActionResult Simple(int id, bool official, int? page)
117117
{
118118
Id = problem.Id,
119119
ProblemName = problem.Name,
120+
ProblemOrderBy = problem.OrderBy,
120121
ShowResult = problem.ShowResults,
121122
BestSubmission = problem.Submissions
122123
.Where(z => z.ParticipantId == participant.Id && !z.IsDeleted)
123124
.OrderByDescending(z => z.Points).ThenByDescending(z => z.Id)
124125
.Select(z => new BestSubmissionViewModel { Id = z.Id, Points = z.Points })
125126
.FirstOrDefault()
126127
})
127-
.OrderBy(res => res.ProblemName)
128+
.OrderBy(res => res.ProblemOrderBy).ThenBy(res => res.ProblemName)
128129
})
129130
.ToList()
130131
.OrderByDescending(x => x.Total)
@@ -164,7 +165,6 @@ public ActionResult Simple(int id, bool official, int? page)
164165
return this.View(contestModel);
165166
}
166167

167-
// TODO: Implement
168168
// TODO: Unit test
169169
[Authorize(Roles = GlobalConstants.AdministratorRoleName)]
170170
public ActionResult Full(int id, bool official)
@@ -193,14 +193,15 @@ public ActionResult Full(int id, bool official)
193193
{
194194
Id = problem.Id,
195195
ProblemName = problem.Name,
196+
ProblemOrderBy = problem.OrderBy,
196197
MaximumPoints = problem.MaximumPoints,
197198
BestSubmission = problem.Submissions.AsQueryable()
198199
.Where(submission => submission.ParticipantId == participant.Id && !submission.IsDeleted)
199200
.OrderByDescending(z => z.Points).ThenByDescending(z => z.Id)
200201
.Select(SubmissionFullResultsViewModel.FromSubmission)
201202
.FirstOrDefault(),
202203
})
203-
.OrderBy(res => res.ProblemName)
204+
.OrderBy(res => res.ProblemOrderBy).ThenBy(res => res.ProblemName)
204205
})
205206
.ToList()
206207
.OrderByDescending(x => x.Total).ThenBy(x => x.ParticipantName)

Open Judge System/Web/OJS.Web/Areas/Contests/ViewModels/Results/ProblemFullResultViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public class ProblemFullResultViewModel
66

77
public string ProblemName { get; set; }
88

9+
public int ProblemOrderBy { get; set; }
10+
911
public SubmissionFullResultsViewModel BestSubmission { get; set; }
1012

1113
public int MaximumPoints { get; set; }

Open Judge System/Web/OJS.Web/Areas/Contests/ViewModels/Results/ProblemResultPairViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public class ProblemResultPairViewModel
99
public BestSubmissionViewModel BestSubmission { get; set; }
1010

1111
public string ProblemName { get; set; }
12+
13+
public int ProblemOrderBy { get; set; }
1214
}
1315
}

0 commit comments

Comments
 (0)