use of cn.edu.zjnu.acm.judge.data.form.BestSubmissionForm in project judge by zjnu-acm.
the class ContestProblemController method status.
@GetMapping("{pid}/status")
public String status(@PathVariable("contestId") long contestId, @PathVariable("pid") int problemNum, @RequestParam(value = "language", required = false) Integer language, @PageableDefault(size = 20, sort = { "time", "memory", "code_length" }) Pageable pageable, Model model, HttpServletRequest request) {
// check if problem exists and not disabled
contestService.findOneByIdAndNotDisabled(contestId);
Problem problem = contestService.getProblem(contestId, problemNum, null);
BestSubmissionForm form = BestSubmissionForm.builder().contestId(contestId).problemId(problem.getOrigin()).language(language).build();
Page<Submission> page = submissionService.bestSubmission(form, pageable, problem.getSubmitUser());
model.addAttribute("page", page);
List<ScoreCount> list = submissionMapper.groupByScore(contestId, problem.getOrigin());
ArrayList<String> scores = new ArrayList<>(list.size());
ArrayList<Long> counts = new ArrayList<>(list.size());
ArrayList<String> urls = new ArrayList<>(list.size());
for (ScoreCount scoreCount : list) {
int score = scoreCount.getScore();
scores.add(ResultType.getShowSourceString(score));
counts.add(scoreCount.getCount());
urls.add(request.getContextPath() + "/status?contest_id=" + contestId + "&problem_id=" + problem.getOrigin() + "&score=" + score);
}
boolean isAdmin = UserDetailsServiceImpl.isAdministrator(request);
boolean isSourceBrowser = UserDetailsServiceImpl.isSourceBrowser(request);
boolean canView = isAdmin || isSourceBrowser;
request.setAttribute("page", page);
request.setAttribute("sa", Arrays.asList(counts, scores, urls));
request.setAttribute("problem", problem);
request.setAttribute("url", URIBuilder.fromRequest(request).replaceQueryParam("page").toString());
request.setAttribute("contestId", contestId);
request.setAttribute("canView", canView);
request.setAttribute("currentUserId", SecurityUtils.getUserId());
return "contests/problems-status";
}
Aggregations