use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestMapperTest method testGetProblem.
/**
* Test of getProblem method, of class ContestMapper.
*/
@Test
public void testGetProblem() {
log.info("getProblem");
long contestId = 0L;
long problemOrder = 0L;
Problem expResult = null;
Problem result = instance.getProblem(contestId, problemOrder, locale.toLanguageTag());
assertEquals(expResult, result);
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class SubmissionService method contestSubmit.
public CompletableFuture<?> contestSubmit(int languageId, String source, String userId, String ip, long contestId, long problemNum) {
check(languageId, source, userId);
Contest contest = contestService.findOneByIdAndNotDisabled(contestId);
// contest not started yet, can't submit the problem.
if (!contest.isStarted()) {
throw new BusinessException(BusinessCode.CONTEST_PROBLEM_NOT_FOUND, contestId, problemNum);
}
Problem problem = contestService.getProblem(contestId, problemNum, null);
return submit0(Submission.builder().contest(contest.isEnded() ? null : contestId).problem(problem.getOrigin()).ip(ip), source, userId, languageId);
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestService method getContestAndProblems.
@Nonnull
public Contest getContestAndProblems(long contestId, Locale locale) {
Contest contest = checkedGet(contestId);
List<Problem> problems = contestMapper.getProblems(contestId, null, localeService.resolve(locale));
contest.setProblems(problems);
return contest;
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ProblemStatusController method status.
@GetMapping("/problemstatus")
@SuppressWarnings("AssignmentToMethodParameter")
public String status(HttpServletRequest request, @RequestParam("problem_id") long id, @PageableDefault(size = 20, sort = { "time", "memory", "code_length" }) Pageable pageable, Authentication authentication) {
log.debug("{}", pageable);
if (pageable.getPageSize() > 500) {
pageable = new PageRequest(pageable.getPageNumber(), 500, pageable.getSort());
}
Problem problem = problemService.findOneNoI18n(id);
List<ScoreCount> list = submissionMapper.groupByScore(null, id);
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?problem_id=" + id + "&score=" + score);
}
Page<Submission> page = submissionService.bestSubmission(null, id, pageable, problem.getSubmitUser());
boolean isAdmin = UserDetailsServiceImpl.isAdminLoginned(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", URLBuilder.fromRequest(request).replaceQueryParam("page").toString());
request.setAttribute("canView", canView);
request.setAttribute("authentication", authentication);
return "problems/status";
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestProblemMapperTest method testGetProblem.
/**
* Test of getProblem method, of class ContestProblemMapper.
*/
@Test
public void testGetProblem() {
log.info("getProblem");
long contestId = 0L;
long problemOrder = 0L;
Problem expResult = null;
Problem result = instance.getProblem(contestId, problemOrder, locale.toLanguageTag());
assertThat(result).isEqualTo(expResult);
}
Aggregations