use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ProblemService method updateSelective.
public void updateSelective(long problemId, Problem p, String requestLocale) {
Problem problem = problemMapper.findOne(problemId, requestLocale);
if (problem == null) {
throw new BusinessException(BusinessCode.PROBLEM_NOT_FOUND, problemId);
}
String locale = convert(requestLocale);
if (locale != null) {
problemMapper.touchI18n(problemId, locale);
}
p.setModifiedTime(Instant.now());
problemMapper.updateSelective(problemId, p, locale);
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestProblemController method status.
@GetMapping(value = "{pid}/status", produces = TEXT_HTML_VALUE)
public String status(@PathVariable("contestId") long contestId, @PathVariable("pid") int problemNum, @PageableDefault(size = 20, sort = { "time", "memory", "code_length" }) Pageable pageable, Model model, Authentication authentication, HttpServletRequest request) {
// check if problem exists and not disabled
contestService.findOneByIdAndNotDisabled(contestId);
Problem problem = contestService.getProblem(contestId, problemNum, null);
Page<Submission> page = submissionService.bestSubmission(contestId, problem.getOrigin(), 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.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("contestId", contestId);
request.setAttribute("canView", canView);
request.setAttribute("authentication", authentication);
return "contests/problems-status";
}
use of cn.edu.zjnu.acm.judge.domain.Problem in project judge by zjnu-acm.
the class ContestServiceImpl method getContestAndProblemsNotDisabled.
@Nonnull
@Override
public Contest getContestAndProblemsNotDisabled(long contestId, @Nullable String userId, Locale locale) {
Contest contest = getEnabledContest(contestId);
List<Problem> problems = contestProblemMapper.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 ContestServiceImpl method getProblemsMap.
@Override
public Map<Long, long[]> getProblemsMap(long id) {
List<Problem> problems = contestProblemMapper.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 ShowProblemController method showProblem.
@GetMapping("showproblem")
public String showProblem(Model model, @RequestParam("problem_id") long problemId, @Nullable Locale locale) {
Problem problem = getProblem(problemId, locale);
model.addAttribute("problem", problem);
model.addAttribute("isSpecial", systemService.isSpecialJudge(problemId));
String title1 = problemId + " -- " + problem.getTitle();
String title2 = problem.getTitle();
model.addAttribute("title1", title1);
model.addAttribute("title2", title2);
return "problems/view";
}
Aggregations