Search in sources :

Example 1 with Problem

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);
}
Also used : Problem(cn.edu.zjnu.acm.judge.domain.Problem) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Problem

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);
}
Also used : BusinessException(cn.edu.zjnu.acm.judge.exception.BusinessException) Problem(cn.edu.zjnu.acm.judge.domain.Problem) Contest(cn.edu.zjnu.acm.judge.domain.Contest)

Example 3 with Problem

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;
}
Also used : Problem(cn.edu.zjnu.acm.judge.domain.Problem) Contest(cn.edu.zjnu.acm.judge.domain.Contest) Nonnull(javax.annotation.Nonnull)

Example 4 with Problem

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";
}
Also used : Submission(cn.edu.zjnu.acm.judge.domain.Submission) ArrayList(java.util.ArrayList) ScoreCount(cn.edu.zjnu.acm.judge.data.dto.ScoreCount) PageRequest(org.springframework.data.domain.PageRequest) Problem(cn.edu.zjnu.acm.judge.domain.Problem) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with Problem

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);
}
Also used : Problem(cn.edu.zjnu.acm.judge.domain.Problem) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Problem (cn.edu.zjnu.acm.judge.domain.Problem)26 Contest (cn.edu.zjnu.acm.judge.domain.Contest)10 BusinessException (cn.edu.zjnu.acm.judge.exception.BusinessException)10 Nonnull (javax.annotation.Nonnull)7 Submission (cn.edu.zjnu.acm.judge.domain.Submission)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 ArrayList (java.util.ArrayList)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 ScoreCount (cn.edu.zjnu.acm.judge.data.dto.ScoreCount)4 Test (org.junit.jupiter.api.Test)4 BusinessCode (cn.edu.zjnu.acm.judge.exception.BusinessCode)3 IOException (java.io.IOException)3 Transactional (org.springframework.transaction.annotation.Transactional)3 BestSubmissionForm (cn.edu.zjnu.acm.judge.data.form.BestSubmissionForm)2 ContestForm (cn.edu.zjnu.acm.judge.data.form.ContestForm)2 ContestStatus (cn.edu.zjnu.acm.judge.data.form.ContestStatus)2 ContestMapper (cn.edu.zjnu.acm.judge.mapper.ContestMapper)2 SubmissionMapper (cn.edu.zjnu.acm.judge.mapper.SubmissionMapper)2 EnumUtils (cn.edu.zjnu.acm.judge.util.EnumUtils)2 SpecialCall (cn.edu.zjnu.acm.judge.util.SpecialCall)2