Package cn.edu.zju.acm.onlinejudge.util

Examples of cn.edu.zju.acm.onlinejudge.util.ContestStatistics


        if (forward != null) {
            return forward;
        }
        AbstractContest contest = context.getContest();

        ContestStatistics statistics = StatisticsManager.getInstance().getContestStatistics(contest.getId());
        context.setAttribute("ContestStatistics", statistics);

        return this.handleSuccess(mapping, context, "success");

    }
View Full Code Here


        return conn.prepareStatement(queryString);
    }

    public ContestStatistics getContestStatistics(List<Problem> problems) throws PersistenceException {
        Connection conn = null;
        ContestStatistics statistics = new ContestStatistics(problems);
        if (problems.size() == 0) {
            return statistics;
        }
        try {
            conn = Database.createConnection();
            List<Long> problemIds = new ArrayList<Long>();
            for (Problem problem : problems) {
                problemIds.add(new Long(((Problem) problem).getId()));
            }
            String inProblemIds = Database.createNumberValues(problemIds);
            String query =
                    "SELECT problem_id, judge_reply_id, count(*) FROM submission " + "WHERE problem_id IN " +
                        inProblemIds + " GROUP BY problem_id, judge_reply_id";
            /*
             * String query = "SELECT problem_id, judge_reply_id, count FROM problem_statistics " +
             * "WHERE problem_id IN " + inProblemIds;
             */
            PreparedStatement ps = null;
            try {
                ps = conn.prepareStatement(query);
                ResultSet rs = ps.executeQuery();
                while (rs.next()) {
                    long problemId = rs.getLong(1);
                    long judgeReplyId = rs.getLong(2);
                    int value = rs.getInt(3);
                    statistics.setCount(problemId, judgeReplyId, value);
                }
                return statistics;
            } finally {
                Database.dispose(ps);
            }
View Full Code Here

                                                                (int) problemsPerPage);
        List<Problem> problems=new ArrayList<Problem>();
        problems.addAll(oproblems);


        ContestStatistics contestStatistics = null;
        contestStatistics =
                StatisticsManager.getInstance().getContestStatistics(contest.getId(),
                                                                     (int) ((pageNumber - 1) * problemsPerPage),
                                                                     (int) problemsPerPage);
        for(int i=0;i<problems.size();++i)
        {
            Problem p = (Problem)problems.get(i);
            int ac = contestStatistics.getCount(i, 0);
            int total = contestStatistics.getProblemCount(i);
            p.setTotal(total);
            p.setAC(ac);
            if(total==0)
            {
                p.setRatio(0);
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.util.ContestStatistics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.