Search in sources :

Example 1 with RankList

use of cn.edu.zju.acm.onlinejudge.util.RankList in project zoj by licheng.

the class ShowRankListAction method execute.

/**
     * ShowRankListAction.
     * 
     * @param mapping
     *            action mapping
     * @param form
     *            action form
     * @param request
     *            http servlet request
     * @param response
     *            http servlet response
     * 
     * @return action forward instance
     * 
     * @throws Exception
     *             any errors happened
     */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    // check contest
    boolean isProblemset = context.getRequest().getRequestURI().endsWith("showRankList.do");
    ActionForward forward = this.checkContestViewPermission(mapping, context, isProblemset, true);
    if (forward != null) {
        return forward;
    }
    AbstractContest contest = context.getContest();
    if (!isProblemset) {
        List<Problem> problems = context.getProblems();
        context.setAttribute("problems", problems);
        long roleId = Utility.parseLong(context.getRequest().getParameter("roleId"));
        RankList ranklist = StatisticsManager.getInstance().getRankList(contest.getId(), roleId);
        String export = context.getRequest().getParameter("export");
        if ("txt".equalsIgnoreCase(export)) {
            return this.export(context, contest, problems, ranklist, export);
        } else if ("xls".equalsIgnoreCase(export)) {
            return this.export(context, contest, problems, ranklist, export);
        }
        context.setAttribute("RankList", ranklist);
    } else {
        int from = Utility.parseInt(context.getRequest().getParameter("from"));
        if (from < 0) {
            from = 0;
        }
        int count = 30;
        String sort = context.getRequest().getParameter("order");
        if (sort == null || !sort.equalsIgnoreCase("submit")) {
            sort = "ac";
        }
        ProblemsetRankList ranklist = StatisticsManager.getInstance().getProblemsetRankList(contest.getId(), from, count, sort);
        if (from > 0) {
            context.setAttribute("previousFrom", from - count > 0 ? from - count : 0);
        }
        if (ranklist.getSolved().length == count) {
            context.setAttribute("nextFrom", from + count);
        }
        context.setAttribute("RankList", ranklist);
    }
    return this.handleSuccess(mapping, context, "success");
}
Also used : AbstractContest(cn.edu.zju.acm.onlinejudge.bean.AbstractContest) ProblemsetRankList(cn.edu.zju.acm.onlinejudge.util.ProblemsetRankList) RankList(cn.edu.zju.acm.onlinejudge.util.RankList) Problem(cn.edu.zju.acm.onlinejudge.bean.Problem) ProblemsetRankList(cn.edu.zju.acm.onlinejudge.util.ProblemsetRankList) ActionForward(org.apache.struts.action.ActionForward)

Aggregations

AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)1 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)1 ProblemsetRankList (cn.edu.zju.acm.onlinejudge.util.ProblemsetRankList)1 RankList (cn.edu.zju.acm.onlinejudge.util.RankList)1 ActionForward (org.apache.struts.action.ActionForward)1