use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestServiceImpl method getContestAndProblems.
@Nonnull
@Override
public Contest getContestAndProblems(long contestId, Locale locale) {
Contest contest = checkedGet(contestId);
List<Problem> problems = contestProblemMapper.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 SubmissionServiceImpl method contestSubmit.
@Override
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, true);
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestService method getContestAndProblemsNotDisabled.
@Nonnull
public Contest getContestAndProblemsNotDisabled(long contestId, String userId, Locale locale) {
Contest contest = getEnabledContest(contestId);
List<Problem> problems = contestMapper.getProblems(contestId, userId, 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 ContestService method getProblemsMap.
public Map<Long, long[]> getProblemsMap(long id) {
List<Problem> problems = contestMapper.getProblems(id, null, null);
AtomicInteger atomic = new AtomicInteger();
return problems.stream().collect(ImmutableMap.toImmutableMap(Problem::getOrigin, problem -> new long[] { atomic.getAndIncrement(), problem.getId() }));
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class JudgeService method toCompletableFuture.
CompletableFuture<?> toCompletableFuture(Executor executor, long submissionId) {
return CompletableFuture.runAsync(() -> {
Submission submission = submissionMapper.findOne(submissionId);
if (submission == null) {
throw new BusinessException(BusinessCode.SUBMISSION_NOT_FOUND);
}
Problem problem = problemService.findOneNoI18n(submission.getProblem());
RunRecord runRecord = RunRecord.builder().submissionId(submission.getId()).language(languageService.getAvailableLanguage(submission.getLanguage())).problemId(submission.getProblem()).userId(submission.getUser()).source(submissionMapper.findSourceById(submissionId)).memoryLimit(problem.getMemoryLimit()).timeLimit(problem.getTimeLimit()).build();
judgeInternal(runRecord);
}, executor);
}
Aggregations