Package bg.smoc.model

Examples of bg.smoc.model.AccumulatedGrade


        }
        return res;
    }

    public final AccumulatedGrade getResult(String contestId, String login, Task task) {
        AccumulatedGrade gradeResult = getAccumulatedResult(contestId, task, login);
        if (handleTestCasesResize(task, gradeResult) || handleTestGroupsResize(task, gradeResult)) {
            recalculateGroups(contestId, login, task, gradeResult);
        }
        return gradeResult;
    }
View Full Code Here


        return true;
    }

    private void updateAccumulatedResult(String contestId, Task task, String userid,
            GradeResult gradeResult) {
        AccumulatedGrade accumulatedGrade = getAccumulatedResult(contestId, task, userid);
        if (handleTestCasesResize(task, accumulatedGrade)
                || handleTestGroupsResize(task, accumulatedGrade)) {
            // Should never happen
            Syslog
                    .log("This should never happen. A resize has been called on GraderManager#updateAccumulatedResult");
        }
        for (int i = 0; i < gradeResult.getTestIndexesCount(); ++i) {
            int testIndex = gradeResult.getTestIndexes(i) - 1;
            if (testIndex < 0 || testIndex >= task.getNumberOfTests()) {
                continue;
            }
            accumulatedGrade.getTestCases().set(testIndex, gradeResult.getResult(i));
        }
        recalculateGroups(contestId, userid, task, accumulatedGrade);
    }
View Full Code Here

        Map<String, AccumulatedGrade> taskResult = contestResult.get(task.getName());
        if (taskResult == null) {
            taskResult = new HashMap<String, AccumulatedGrade>();
            contestResult.put(task.getName(), taskResult);
        }
        AccumulatedGrade gradeResult = taskResult.get(login);
        if (gradeResult != null) {
            return gradeResult;
        }
        gradeResult = parseAccumulatedResult(contestId, task, login);
        if (gradeResult == null) {
View Full Code Here

            e.printStackTrace();
        }
    }

    private AccumulatedGrade buildNewAccumulatedGrade(Task task) {
        AccumulatedGrade accumulated = new AccumulatedGrade();
        for (int i = 0; i < task.getNumberOfTests(); ++i) {
            accumulated.getTestCases().add("-");
        }
        for (int i = 0; i < task.getTestGroups().size(); ++i) {
            accumulated.getTestGroups().add("-");
        }
        accumulated.setTotal("0");
        return accumulated;
    }
View Full Code Here

        BigDecimal totalPoints = BigDecimal.ZERO;

        ResultsRow row = new ResultsRow();
        row.addCell(login);
        for (Task task : contest.getTasks()) {
            AccumulatedGrade testResults = graderManager.getResult(contest.getId(), login, task);
            if (includeTestGroupResults) {
                for (int i = 0; i < testResults.getTestGroups().size(); ++i) {
                    ResultsCell cell = new ResultsCell("-");
                    if (testResults != null) {
                        cell.setValue(testResults.getTestGroups().get(i));
                        if (task.getType() == Task.PROBLEM_TYPE_OUTPUT) {
                            cell.setHref("?contestId="
                                    + contest.getId()
                                    + "&login="
                                    + login
                                    + "&taskId="
                                    + task.getNameForTest(i + 1));
                        }
                    }
                    row.addCell(cell);
                }
            }
            if (testResults != null) {
                totalPoints = totalPoints.add(new BigDecimal(testResults.getTotal()));
            }
            ResultsCell cell = new ResultsCell(testResults != null ? testResults.getTotal()
                    : BigDecimal.ZERO.toString());
            if (task.getType() != Task.PROBLEM_TYPE_OUTPUT) {
                cell.setHref("?contestId="
                        + contest.getId()
                        + "&login="
View Full Code Here

        printProperty(report, "Login", account.getLogin());
        report.append("\n\n");
        printDelimiter(report);

        for (Task task : contest.getTasks()) {
            AccumulatedGrade testResults = graderManager.getResult(contest.getId(), account
                    .getLogin(), task);
            report.append(String.format("Task %-10s %#3s out of 100\n",
                    task.getName() + ":",
                    testResults.getTotal()));
        }
        report.append("-------------------------------\n");
        BigDecimal totalScore = calculateTotalScore(account);
        report.append(String.format("Total score:    %#3s out of %#3s\n", totalScore, contest
                .getTasks().size() * 100));
        printDelimiter(report);

        report.append("\n\n\nLegend:\n"
                + "TL - Time Limit Exceeded\n"
                + "RE - Run-time Error (including limit violation)\n"
                + "WA - Wrong Answer\n"
                + "PC - Partial Credit\n"
                + "OK - Correct\n");

        for (Task task : contest.getTasks()) {
            AccumulatedGrade testResults = graderManager.getResult(contest.getId(), account
                    .getLogin(), task);

            report.append("\n\n\n");
            printDelimiter(report);
            printName(report, person);
            printProperty(report, "Task", task.getName());
            report.append("\n");
            if (task.getType() != Task.PROBLEM_TYPE_OUTPUT
                    && "-".equals(testResults.getTestCases().get(0))) {
                report.append("No valid submission.\n");
                printDelimiter(report);
                continue;
            }

            report.append("Test group | Score | Max Score | Individual test results\n");
            report.append("-----------+-------+-----------+-------------------------\n");

            List<TestGroup> testGroups = task.getTestGroups();
            for (int index = 0; index < testGroups.size(); index++) {
                report.append(String.format("%#6s     |", index + 1));
                TestGroup group = testGroups.get(index);
                List<String> testCases = testResults.getTestCases();
                report.append(String.format(" %#3s   |", getNumericValue(testResults
                        .getTestGroups().get(index))));
                report.append(String.format("    %#3s    |", group.getPoints()));
                for (int testIndex : group.getTestCases()) {
                    report.append(" ");
                    report.append(toTwoLetterCode(testCases.get(testIndex - 1), group.getPoints()));
                    report.append(" ");
                }
                report.append("\n");
            }
            report.append("-----------+-------+-----------+-------------------------\n");
            report.append(String.format("   TOTAL   | %#3s   |    100    |\n", testResults
                    .getTotal()));
            printDelimiter(report);
        }

        report.append("\n\n");
View Full Code Here

    }

    private BigDecimal calculateTotalScore(UserAccount account) {
        BigDecimal totalScore = BigDecimal.ZERO;
        for (Task task : contest.getTasks()) {
            AccumulatedGrade testResults = graderManager.getResult(contest.getId(), account
                    .getLogin(), task);
            try {
                BigDecimal taskScore = new BigDecimal(testResults.getTotal());
                totalScore = totalScore.add(taskScore);
            } catch (NumberFormatException e) {
            }
        }
        return totalScore;
View Full Code Here

TOP

Related Classes of bg.smoc.model.AccumulatedGrade

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.