From a94a9f9045590c6001178eaab70f29a2a12b66a8 Mon Sep 17 00:00:00 2001 From: John Buck Date: Mon, 10 Aug 2026 11:27:28 -0400 Subject: [PATCH] i_1287 Use correct value for scoreboard type enum Do not use the enum member name for the value of the enum, rather, use the getType() method to return the correct string. Previously, the toString() method was used and this returned the enum member name, not its value. These calls were changed to getType(). --- .../pc2/clics/API202306/CLICSContestInfo.java | 4 +-- .../core/scoring/DefaultScoringAlgorithm.java | 31 +++++++++---------- .../pc2/core/scoring/NewScoringAlgorithm.java | 7 ++--- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/edu/csus/ecs/pc2/clics/API202306/CLICSContestInfo.java b/src/edu/csus/ecs/pc2/clics/API202306/CLICSContestInfo.java index 6a5f1cbef..e6d7f00c8 100644 --- a/src/edu/csus/ecs/pc2/clics/API202306/CLICSContestInfo.java +++ b/src/edu/csus/ecs/pc2/clics/API202306/CLICSContestInfo.java @@ -1,4 +1,4 @@ -// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. +// Copyright (C) 1989-2026 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. package edu.csus.ecs.pc2.clics.API202306; import java.util.Calendar; @@ -110,7 +110,7 @@ public CLICSContestInfo(IInternalContest model, ContestInformation ci) { if(ci.getThawed() != null) { scoreboard_thaw_time = Utilities.getIso8601formatterWithMS().format(ci.getThawed()); } - scoreboard_type = ci.getScoreboardType().toString().toLowerCase(); + scoreboard_type = ci.getScoreboardType().getType().toLowerCase(); } public String toJSON() { diff --git a/src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java b/src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java index 0c4338f76..5f45f3622 100644 --- a/src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java +++ b/src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java @@ -1,9 +1,8 @@ -// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. +// Copyright (C) 1989-2026 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. package edu.csus.ecs.pc2.core.scoring; import java.io.IOException; import java.security.InvalidParameterException; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -469,7 +468,7 @@ public String getStandings(IInternalContest theContest, Run[] runs, Integer divi Problem[] allProblems = theContest.getProblems(); Hashtable problemsIndexHash = new Hashtable(); int p2 = 0; - + //if divisionNumber!=null it means we're using Division filtering, in which case divisionNumber is 1 or 2. //if wantedGroups!=null it means the caller has specified a set of groups it wants to filter on. //if the caller HASN'T specified any groups, we need to add to the wantedGroups list the groups for the specified division. @@ -478,21 +477,21 @@ public String getStandings(IInternalContest theContest, Run[] runs, Integer divi // (this is because if wantedGroups is null it causes method canView(wantedGroups) to always return "yes"). wantedGroups = new ArrayList(); } - + for (int p=1; p <= allProblems.length ; p++) { Problem prob = allProblems[p-1]; - + if (divisionNumber!=null) { //we are filtering on divisions so we need to update "wantedGroups" with the "division" groups // in the problem which match the desired division. for (Group probGroup : prob.getGroups()) { //Note: getGroupId() returns the "CMS external id". if (probGroup.getGroupId()==divisionNumber) { - wantedGroups.add(probGroup); + wantedGroups.add(probGroup); } } } - + if (prob.isActive() && prob.canView(wantedGroups)) { p2++; problemsIndexHash.put(prob.getElementId(), new Integer(p2)); @@ -507,10 +506,10 @@ public String getStandings(IInternalContest theContest, Run[] runs, Integer divi } summaryMemento.putLong("problemCount", problems.length); - + Site[] sites = theContest.getSites(); summaryMemento.putInteger("siteCount", sites.length); - + Group[] groups = theContest.getGroups(); boolean bGroupsExcluded = false; if (groups != null) { @@ -522,7 +521,7 @@ public String getStandings(IInternalContest theContest, Run[] runs, Integer divi //Note also that generateSummaryTotalsForProblem() already existed and was inserting MOST of that information in the output already; // the "colorList" processing code which used to be here was simply added to that method instead (adding internalId, letter, and // url to the elements), avoiding duplication of problem description data in the output XML. - + if (runs == null) { // Note: we do not deal with divisionNumber here since // 1) it is being deprecated @@ -1170,7 +1169,7 @@ private void generateSummaryTotalsForProblem(Problem[] problems, Hashtable-capitalizeFirstLetter(shortname), in a PDF file named the same but with ".pdf" added. String basename = problems[i].getLetter().toUpperCase() + "-" + capitalizeFirstLetter(problems[i].getShortName()); String filename = basename + ".pdf"; problemMemento.putString("url", "problems/" + basename + "/" + filename); - + problemMemento.putLong("attempts", problemAttempts[id]); if (problemAttempts[id] > 0) { grandTotalProblemAttempts++; @@ -1218,12 +1217,12 @@ private String capitalizeFirstLetter(String input) { if (input == null || input.isEmpty()) { return input; // Return as-is if null or empty } - + char firstChar = input.charAt(0); if (!Character.isLetter(firstChar)) { return input; // Return unchanged if first char is not a letter } - + return Character.toUpperCase(firstChar) + input.substring(1); } @@ -1406,7 +1405,7 @@ private IMemento createSummaryMemento(IInternalContest contest, XMLMemento memen memento.putString("systemVersion", versionInfo.getVersionNumber() + " build " + versionInfo.getBuildNumber()); memento.putString("systemURL", versionInfo.getSystemURL()); //TODO: fix this to return the proper URL (not a CSUS URL) memento.putString("currentDate", new Date().toString()); - memento.putString("scoreType", contestInformation.getScoreboardType().toString().toLowerCase()); + memento.putString("scoreType", contestInformation.getScoreboardType().getType().toLowerCase()); memento.putString("generatorId", "$Id$"); // bug 1540 String value = "Live (unfrozen) scoreboard"; diff --git a/src/edu/csus/ecs/pc2/core/scoring/NewScoringAlgorithm.java b/src/edu/csus/ecs/pc2/core/scoring/NewScoringAlgorithm.java index 38ae74fe0..6ae78c424 100644 --- a/src/edu/csus/ecs/pc2/core/scoring/NewScoringAlgorithm.java +++ b/src/edu/csus/ecs/pc2/core/scoring/NewScoringAlgorithm.java @@ -1,8 +1,7 @@ -// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. +// Copyright (C) 1989-2026 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. package edu.csus.ecs.pc2.core.scoring; import java.io.IOException; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -67,7 +66,7 @@ public class NewScoringAlgorithm extends Plugin implements INewScoringAlgorithm private PermissionList permissionList = new PermissionList(); private boolean isPointScoring = false; - + /** * Return a list of regional winners. * @@ -1075,7 +1074,7 @@ private IMemento createSummaryMomento(ContestInformation contestInformation, XML memento.putString("systemVersion", versionInfo.getVersionNumber() + " build " + versionInfo.getBuildNumber()); memento.putString("systemURL", versionInfo.getSystemURL()); memento.putString("currentDate", new Date().toString()); - memento.putString("scoreType", contestInformation.getScoreboardType().toString().toLowerCase()); + memento.putString("scoreType", contestInformation.getScoreboardType().getType().toLowerCase()); memento.putString("generatorId", "$Id$"); return memento;