Search in sources :

Example 1 with Submission

use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.

the class SubmissionMapperTest method testFindAllByCriteria.

/**
 * Test of findAllByCriteria method, of class SubmissionMapper.
 */
@Test
public void testFindAllByCriteria() {
    log.info("findAllByCriteria");
    SubmissionQueryForm submissionCriteria = SubmissionQueryForm.builder().contest(1058L).problem(1449L).size(50).build();
    List<Submission> result = instance.findAllByCriteria(submissionCriteria);
    log.info("{}", result.size());
}
Also used : Submission(cn.edu.zjnu.acm.judge.domain.Submission) SubmissionQueryForm(cn.edu.zjnu.acm.judge.data.form.SubmissionQueryForm) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Submission

use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.

the class ShowCompileInfoControllerTest method testShowCompileInfo.

/**
 * Test of showCompileInfo method, of class ShowCompileInfoController.
 *
 * @see ShowCompileInfoController#showCompileInfo(long, Model,
 * Authentication)
 */
@Test
public void testShowCompileInfo() throws Exception {
    log.info("showCompileInfo");
    Submission submission = mockDataService.submission();
    MvcResult result = mvc.perform(get("/showcompileinfo").with(user(submission.getUser())).param("solution_id", Long.toString(submission.getId()))).andExpect(status().isOk()).andExpect(view().name("showcompileinfo")).andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)).andReturn();
}
Also used : Submission(cn.edu.zjnu.acm.judge.domain.Submission) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with Submission

use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.

the class SubmissionService method submit0.

private CompletableFuture<?> submit0(Submission.Builder builder, String source, String userId, int languageId) {
    Instant now = Instant.now();
    Submission submission = builder.user(userId).inDate(now).sourceLength(source.length()).language(languageId).score(ResultType.QUEUING).build();
    // 插入solution数据库表
    submissionMapper.save(submission);
    long submissionId = submission.getId();
    problemMapper.setInDate(submission.getProblem(), now);
    // 插入source_code表
    submissionMapper.saveSource(submissionId, source);
    userPerferenceMapper.setLanguage(userId, languageId);
    return judgePool.add(submissionId);
}
Also used : Submission(cn.edu.zjnu.acm.judge.domain.Submission) Instant(java.time.Instant)

Example 4 with Submission

use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.

the class SubmissionService method bestSubmission.

public Page<Submission> bestSubmission(Long contestId, long problemId, Pageable pageable, long total) {
    BestSubmissionForm form = BestSubmissionForm.builder().contestId(contestId).problemId(problemId).build();
    List<Submission> bestSubmissions = submissionMapper.bestSubmission(form, pageable);
    return new PageImpl<>(bestSubmissions, pageable, total);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) Submission(cn.edu.zjnu.acm.judge.domain.Submission) BestSubmissionForm(cn.edu.zjnu.acm.judge.data.form.BestSubmissionForm)

Example 5 with Submission

use of cn.edu.zjnu.acm.judge.domain.Submission 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)

Aggregations

Submission (cn.edu.zjnu.acm.judge.domain.Submission)13 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Problem (cn.edu.zjnu.acm.judge.domain.Problem)3 BusinessException (cn.edu.zjnu.acm.judge.exception.BusinessException)3 MvcResult (org.springframework.test.web.servlet.MvcResult)3 ScoreCount (cn.edu.zjnu.acm.judge.data.dto.ScoreCount)2 SubmissionQueryForm (cn.edu.zjnu.acm.judge.data.form.SubmissionQueryForm)2 MessageException (cn.edu.zjnu.acm.judge.exception.MessageException)2 Instant (java.time.Instant)2 ArrayList (java.util.ArrayList)2 RunRecord (cn.edu.zjnu.acm.judge.data.dto.RunRecord)1 SubmissionDetail (cn.edu.zjnu.acm.judge.data.dto.SubmissionDetail)1 BestSubmissionForm (cn.edu.zjnu.acm.judge.data.form.BestSubmissionForm)1 Contest (cn.edu.zjnu.acm.judge.domain.Contest)1 Language (cn.edu.zjnu.acm.judge.domain.Language)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 DecimalFormat (java.text.DecimalFormat)1