Skip to content

I1224 point score decimal format#1226

Open
johnbrvc wants to merge 9 commits into
i1006_point_scoringfrom
i1224_point_score_decimal_format
Open

I1224 point score decimal format#1226
johnbrvc wants to merge 9 commits into
i1006_point_scoringfrom
i1224_point_score_decimal_format

Conversation

@johnbrvc
Copy link
Copy Markdown
Collaborator

@johnbrvc johnbrvc commented Feb 17, 2026

Description of what the PR does

Allows configuring of the display format (DecimalFormat) used to format scores from a point scoring contest.

Issue which the PR addresses

Fixes #1224

Environment in which the PR was developed (OS,IDE, Java version, etc.)

Windows 11
Ubuntu 24.04.3

Precise steps for testing the PR (i.e., how to demonstrate that it works correctly)

Load up any point scoring contest that is complete, eg. NAC2026 challenge2024_test, for example. Details of obtaining the completed contest results can be directed to @johnbrvc . Suffice to say, I have tested it with three different apps (pc2admin, pc2board, pc2feeder) all using different pc2v9.ini files with different formats for the point scores, and it appears to work as described in the issue.

The following additional details may also be helpful in testing the PR

  • The "completed scoring contest" mentioned above, which can be used for testing, can be found at this repo location. To use it:
    • Download the NAC2026-Challenge2024-test.zip contest from that link and unzip it.
    • Copy the profiles folder and the profiles.properties file into the PC2 folder where your PC2 distribution (what you are going to test) resides. Be sure you have NOT started the PC2 Server before copying the profiles into PC2.
    • Start the PC2 Server. This will automatically load the NAC2026-Challenge2024-test contest into PC2.
  • Suggested testing steps:
  1. Verify that every Point Score display contains the correct default format, which is 0.000 (at least one whole digit and exactly 3 decimal digits), as follows:
  • Start a PC2 Admin and look at the Run Contest>Scoreboard tab; ensure that the scores all have exactly three decimal places (this is the default).
  • Test that the PC2 scoreboard displays default-formatted scores properly:
    • On the PC2 Admin, check the Configure Contest>Settings tab and make sure the Output HTML dir for Judges and Output Public HTML dir paths point to a valid location on your machine (typically you'd want them pointing to locations under the PC2 distribution you are testing).
    • Start a PC2 Board client and verify that the point scores shown on the Board Client GUI all have exactly three decimal places.
    • In a browser, open the file index_ps.html in the "Judge's HTML" ("secret") folder.
    • Verify that the values in the "Score" column (next to each team name) all have exactly three decimal places.
  • Test that the PC2 Event Feed contains properly-formatted default scores:
    • Start feeder 1 client (pc2ef --login ef1), then press the Start button to start the feeder.
    • From a browser, open https://localhost:50443/contests/nac25chall24practice/scoreboard. When it prompts for user/password, use: administrator1:administrator1, or admin:admin (from the realm.properties file, assuming you have one).
    • Execute the following command from a command line:
         curl -k https://admin:admin@localhost:50443/contests/nac25chall24practice/scoreboard 
      
      (you can also use administrator1:administrator1. If you're using a pc2 account it must have the View Event Feeds permission. )
    • Verify that the "score" values in the resulting Event Feed output which are not integer numbers (e.g. 50.0) have exactly three decimal places. (The CLICS API specifies that scores are numbers, which means that whole numbers will display in the event feed without decimal places.)
  • Test that the WTI displays default-formatted scores properly:
    • In the PC2 projects folder, unzip the WebTeamInterface.zip file.
    • In the resulting WebTeamInterface folder, start the WTI Server (./bin/pc2wti).
    • Open a browser and login to the WTI as a team (e.g. team1 with password decoy-sled-dwarf-idly).
    • On the WTI Runs page, verify that every "Accepted" run has a score containing exactly 3 decimal digits.
    • On the WTI Scoreboard page, verify that:
      • Every green box (indicating an Accepted/Solved problem) has a score that contains exactly 3 decimal digits.
      • Every entry in the rightmost Score column has exactly 3 decimal digits.
  1. Verify that a bad format causes a client to fail to start, as follows:
  • Shut down the PC2 Admin.
  • Edit the pc2v9.ini file in the root PC2 distribution folder by adding the following lines at the end:
    [scoring]
    format=0.00,00
    
    (The comma makes this an illegal format pattern.)
  • Restart the PC2 Admin, and verify that it fails to start and gives an error message that the format is illegal.
  1. Verify that changing to a non-default score format results in every Point Score display containing the correct (specified) format, as follows:
  • Shut down the WTI browser, the WTI Server, and the PC2 Admin, Board, and Event Feed clients.
  • Edit the pc2v9.ini file in the root PC2 distribution folder by adding the following lines at the end:
    [scoring]
    format=0.00000
    
    (This forces the formatting of scores so that they have 5 decimal digits, regardless of the actual numeric value being displayed).
  • Restart the PC2 Admin, Board, and Event Feed clients (as described above), and verify that all the places where scores are displayed (as described above) now show FIVE decimal digits.
  • Edit the pc2v9.ini file under the projects/WebTeamInterface folder in a similar manner, except use format 0.0000 (only four decimal digits).
  • Restart the WTI Server, then re-login to a team.
  • Verify that the Runs and Scoreboard pages now show scores containing exactly four decimal digits.
  1. If you want to really go crazy:
  • Start each of the PC2 Admin, Board, and EF clients in their own separate folder, each with its own pc2v9.ini file containing a different format=x.xxx value, and verify that each client displays its scores according to its own format specification. Most people would consider this "overkill-testing"...

i_1187 Fix wrong argument when setting institution information
PR Change request: Use Double.valueOf() instead of new Double().
Fix EventFeedUtilities.java to ignore zip file names that are empty or are directories (end in a /).
CI: Somewhat related, but do not create a zip file for an API submission source file request with entries that have empty filenames.
Fix errant comment.
Change overrideSubmissionID to default of 0 since a submissions can not have an ID of 0.  A negative submission ID is special and will get converted to a positive number, so -1 is really submission 1.
Added formatScore method to Utilities to format a double according to the configured format [scoring].format.
Change related classes that need to format a score to use the new method.
The default format is set to:  0.0##
@johnbrvc johnbrvc requested a review from clevengr February 17, 2026 17:07
@johnbrvc johnbrvc self-assigned this Feb 17, 2026
Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed src/edu/csus/ecs/pc2/clics/API202306/SubmissionService.java. I don't understand what the changes in this file have to do with the PR to which they are attached. (The changes don't seem unreasonable -- they just appear to be related to a different issue...)

Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed src/edu/csus/ecs/pc2/convert/EventFeedUtilities.java. As with my previous comment, I don't see what the changes in this file have to do with this PR...

Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the changes to src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java. I made a couple of notes: not so much "Request for changes" as "I'm not completely sure about doing this..."

Comment thread src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java
Comment thread src/edu/csus/ecs/pc2/core/scoring/DefaultScoringAlgorithm.java
Comment thread src/edu/csus/ecs/pc2/core/scoring/NewScoringAlgorithm.java
Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed src/edu/csus/ecs/pc2/core/Utilities.java. I think there is important error-handling missing (see my comments).

Comment thread src/edu/csus/ecs/pc2/core/Utilities.java
@clevengr
Copy link
Copy Markdown
Contributor

I've reviewed all the file changes, made comments, and in one case requested change. Moving on now to a runtime test. Noting that the "Steps to test" don't give much detail...

@johnbrvc

This comment was marked as resolved.

@johnbrvc

This comment was marked as resolved.

@johnbrvc
Copy link
Copy Markdown
Collaborator Author

I've reviewed all the file changes, made comments, and in one case requested change. Moving on now to a runtime test. Noting that the "Steps to test" don't give much detail...

I thought the testing procedure was terse, but adequate. You don't have to load a new contest, or make submissions or anything. Just load up a completed contest and look at the scoreboard, reports, event feed, WTI, whatever you want. It's a visual thing. BTW, we did use this at NAC for the WTI scoreboard (recall the "on-the-fly" main.js fix), the pc2admin scoreboards, the pc2board scoreboards and the event feed (resolver) and it appeared to work. So, you could load up something like the NAC2026-Challenge2024-test.zip profile from here: Point Scoring Profiles and just look at the scoreboards and event feed as suggested in the PR, and make changes to the format in the pc2v9.ini files for each and restart the client as suggested in the PR.

If you would like me to supply step-by-step instructions on how to download the zip, unzip it, start the contest, test each app that uses the format stuff, make changes to thepc2v9.inifiles, and repeat, I can surely do that. I just thought a) we did all that "in production" at NAC and b) it's relatively straight forward, that all that detail wasn't necessary. Let me know and I'll be happy to put those steps above.

@clevengr
Copy link
Copy Markdown
Contributor

clevengr commented Apr 25, 2026

I've reviewed all the file changes, made comments, and in one case requested change. Moving on now to a runtime test. Noting that the "Steps to test" don't give much detail...

I thought the testing procedure was terse, but adequate. You don't have to load a new contest, or make submissions or anything. Just load up a completed contest and look at the scoreboard, reports, event feed, WTI, whatever you want. It's a visual thing. BTW, we did use this at NAC for the WTI scoreboard (recall the "on-the-fly" main.js fix), the pc2admin scoreboards, the pc2board scoreboards and the event feed (resolver) and it appeared to work. So, you could load up something like the NAC2026-Challenge2024-test.zip profile from here: Point Scoring Profiles and just look at the scoreboards and event feed as suggested in the PR, and make changes to the format in the pc2v9.ini files for each and restart the client as suggested in the PR.

If you would like me to supply step-by-step instructions on how to download the zip, unzip it, start the contest, test each app that uses the format stuff, make changes to thepc2v9.inifiles, and repeat, I can surely do that. I just thought a) we did all that "in production" at NAC and b) it's relatively straight forward, that all that detail wasn't necessary. Let me know and I'll be happy to put those steps above.

I personally don't need step-by-step details at the level of "how to down the zip, unzip it, start the contest, and so forth" (although it may be that some of our less-experienced testers might find that useful). What I was commenting on was more about Load up any point scoring contest that is complete, eg. NAC2026 challenge2024_test, for example. -- but with no indication of how or where to get that from or how to use it. You've answered the former question (where to get it from), and (implicitly) answered the latter question since what that download provides is a PC2 Profile for an already-run contest. I was also sort of commenting on the fact that there were no instructions at all on what to do once that contest was loaded (in other words, it would have been helpful to point out that the intent was to repeatedly edit the pc2v9.ini file to contain different scroring.format strings and verify that they work as intended. All in all it's no big deal; once you provided a link to the test contest it became obvious.

@clevengr
Copy link
Copy Markdown
Contributor

I have made a run-time test of the PR. It works as expected for changing the pc2v9.ini file with regard to the Admin and Board clients. However, I'm not able to get it to work with the WTI, even when I put

[scoring]
format=0.0

in the WTI's pc2v9.ini file.

Since formatting is now done in the DSA, it is no longer necessary for the angular code to hard-code formats for the score.
@johnbrvc
Copy link
Copy Markdown
Collaborator Author

I have made a run-time test of the PR. It works as expected for changing the pc2v9.ini file with regard to the Admin and Board clients. However, I'm not able to get it to work with the WTI, even when I put

[scoring]
format=0.0

in the WTI's pc2v9.ini file.

This took A WHILE to track down, and, just to be a blame-shifter, it's the fault of the Angular code writer... ;-)

For example, this from /WTI-UI/src/app/modules/scoreboard/components/scoreboard-page/scoreboard-page.component.html:

	<ng-container *ngIf="isPointScoring">
		{{ problem.attempts }}/{{ problem.score | number:'1.3-3' }} <!-- At least one whole digit; exactly 3 fractional digits -->
	</ng-container>

That is not very configurable then, is it?

Evidently, the scoreboard-page component overrides the format (with a lovely comment to that effect). You may have noticed that while the WTI scoreboard had not obeyed the format in the pc2v9.ini file, it DID obey the rounding to one decimal place. This is because the DSA returned the correctly formatted values, eg 63.0 instead of 63.001 or 491.7 instead of 491.675, but the angular code reformatted those as: 63.000 and 491.700.
image

This is why we didn't notice this at NAC since all the clients used a "3 after the decimal" format, which matched what the Angular HTML had. sigh.

As @lane55 was fond of saying, "this is why we test". So, to blame-shift back to the PR author, ahem. I should have checked formats other than "3 after the decimal" in my testing, and I would have seen the issue on the HTML and dealt with it.

I made the change in the HTML angular files (and there were a bunch of those "number:'1.3-3'" formats scattered across several files, and now it works - for the most part:
image

The issue is, since the value is a double NUMBER (not a String), when angular (javascript) goes to display it, it chops off any trailing zeroes as shown above. I'm not sure how "bad" this is? or good perhaps? Hm. I'm not sure how to address this since I don't know anything about how angular does stuff. Maybe the app config file has to change and contain the format string: number:'1.3-3' ? Oh boy. Can of worms. Suggestions welcome from Angular experts.

(BTW I pushed a commit to remove the formatting from the HTML. When you test it, be sure to flush your cache or use incognito mode since, "main.js" is not refreshed by default and it will not load a new one unless explicitly told to do so).

Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request change in the default score pattern, from 0.0## to 0.000, so all scores align.

Comment thread src/edu/csus/ecs/pc2/core/Utilities.java Outdated
Utilities.java - change default scoring format to be 0.000 instead of 0.0## (PR request)
InternalController.java - Add check at startup to test any scoring formats supplied in the INI file so we don't get surprises later.  CI: Fix spelling error of saveConfigurationToDisk in the module.
ContestController.java - Add methods to support "fixing" the scores after the XML is converted to JSON.  The XML class was converting a formatted string (the score) to s double, thereby losing the formatting.  The changeScoresToStrings() method navigates the JSON and changes all double score values to strings and reformats them.
TeamsController.java and RunModel.java - Change the score field to String and format the score   using Utilities.formatScore().
@johnbrvc
Copy link
Copy Markdown
Collaborator Author

This comment may be thought of as an addendum to the description of the PR.

It was determined that the WTI did not correctly format scores for scoring contests. This was because during the conversion of XML to JSON in XML.toJSONObject(), the score property was converted to double, thereby losing any formatting done by the DSA. Code was added (changeScoresToStrings()) to examine the generated JSON after the conversion from XML, and change all score properties (in TeamStandings and ProblemSummaryInfo objects) to strings instead of numbers. To do this conversion, the score had to be again formatted using the correct format (Utilities.formatScore()). Yes, this is somewhat of a duplication of effort since the score WAS formatted properly by the DSA when generating the XML. There was no reasonable way to preserve this information during the conversion to JSON without writing or using a different XML converter. It was decided to post-process the JSON and undo the conversion of score to double. This necessitated reformatting the value.

In addition, the "Runs" table on the WTI web page improperly showed the score for problems as well. They used to be hardcode formatted as 1.3-3 (three after the decimal), and that was not configurable. When the fixed formatting was removed, default Java formatting of the double value was performed leading to scores with many places after the decimal. This was addressed by changing the RunModel class to make the type of the score property be String instead of double. Then, in the WTI-API, the value was formatted using Utilities.formatScore() (just like the DSA and RunsTablePane in PC^2 do). This newly formatted value was then set to the String score property in the RunModel (constructor changed). No other modules appear to use the score property besides the Run table so this was safe to change the type of score.

The changes described above appear to fix the issues related to formatting scores in the WTI.

Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the changes to projects/WTI-API/src/main/controllers/ContestController.java. I noted two areas where I think extra error-catching code is warranted/needed.

Comment thread projects/WTI-API/src/main/controllers/ContestController.java
Comment thread projects/WTI-API/src/main/controllers/ContestController.java
Comment thread projects/WTI-API/src/main/controllers/ContestController.java
Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed all the changed files and don't have any further issues with them. I ran a pretty comprehensive runtime test. I verified that formatting changes are properly handled in the PC2 Admin Scoreboards, the PC2 Board client and the HTML scoreboards it generates, and the WTI. I was not able to figure out exactly how to verify that formatting changes are properly reflected in the Event Feed (there's no Scoreboard data in the Admin's Event Feed JSON report or the EF Client View Event Feed operation, and for some reason I couldn't connect to/login to the contest using a browser to hit the /event-feed endpoint myself.

My failure is undoubtedly my own fault, but I'd like to finish that EF verification - if I can get some help understanding how to do it. Once I've done that I'm ready to approve the PR.

(Note: since I like to create "Test Procedure" documents to help myself keep track of how I'm testing, I took the liberty of going ahead and adding my own steps to the "How to Test the PR" section... Hopefully it might help someone else approve the PR more quickly...)

@johnbrvc
Copy link
Copy Markdown
Collaborator Author

I reviewed all the changed files and don't have any further issues with them. I ran a pretty comprehensive runtime test. I verified that formatting changes are properly handled in the PC2 Admin Scoreboards, the PC2 Board client and the HTML scoreboards it generates, and the WTI. I was not able to figure out exactly how to verify that formatting changes are properly reflected in the Event Feed (there's no Scoreboard data in the Admin's Event Feed JSON report or the EF Client View Event Feed operation, and for some reason I couldn't connect to/login to the contest using a browser to hit the /event-feed endpoint myself.

My failure is undoubtedly my own fault, but I'd like to finish that EF verification - if I can get some help understanding how to do it. Once I've done that I'm ready to approve the PR.

(Note: since I like to create "Test Procedure" documents to help myself keep track of how I'm testing, I took the liberty of going ahead and adding my own steps to the "How to Test the PR" section... Hopefully it might help someone else approve the PR more quickly...)

Remember, when testing the event feed, keep in mind the CLICS spec says that the "score" values are numbers, meaning, they are not strings. The formatting is not preserved, of course. However, the rounding is observed since it works kind of the same was as the WTI did. XML standings are created and the scores are formatted according to the [scoring].format in the event feeder's pc2v9.ini. When converted to JSON for the event feed endpoints, that formatted string is converted to a number. So, for example, "100.0" will show up as 100 on the scoreboard endpoint. That being said, I'm not sure exactly how you tested the Event Feed scoreboard endpoint But here's the procedure:

  1. Start feeder 1 client (pc2ef --login ef1), the press the Start button to start the feeder.
  2. From a browser: https://localhost:50443/contests/nac25chall24practice/scoreboard when it prompts for user/password, use: adminsitrator1:administrator1, or admin:admin (from the realm.properties file, assuming you have one).
  3. From the command line curl: curl -k https://admin:admin@localhost:50443/contests/nac25chall24practice/scoreboard
    (you can also use administrator1:administrator1. If you're using a pc2 account it must have the View Event Feeds permission. )

@clevengr
Copy link
Copy Markdown
Contributor

Remember, when testing the event feed, keep in mind the CLICS spec says that the "score" values are numbers, meaning, they are not strings. The formatting is not preserved, of course. However, the rounding is observed since it works kind of the same was as the WTI did. XML standings are created and the scores are formatted according to the [scoring].format in the event feeder's pc2v9.ini. When converted to JSON for the event feed endpoints, that formatted string is converted to a number. So, for example, "100.0" will show up as 100 on the scoreboard endpoint. That being said, I'm not sure exactly how you tested the Event Feed scoreboard endpoint But here's the procedure:

  1. Start feeder 1 client (pc2ef --login ef1), the press the Start button to start the feeder.
  2. From a browser: https://localhost:50443/contests/nac25chall24practice/scoreboard when it prompts for user/password, use: adminsitrator1:administrator1, or admin:admin (from the realm.properties file, assuming you have one).
  3. From the command line curl: curl -k https://admin:admin@localhost:50443/contests/nac25chall24practice/scoreboard
    (you can also use administrator1:administrator1. If you're using a pc2 account it must have the View Event Feeds permission. )

Thanks. I'm not quite sure why the URL contains nac25chall24practice when the Contest Title is 2026 ICPC NAC Challenge 2024 Test, but I do see that it works as described.

Copy link
Copy Markdown
Contributor

@clevengr clevengr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now verified that the Event Feed contains scores in the expected format, so as far as I can see everying in the PR works as intended. I approve the PR.

@johnbrvc
Copy link
Copy Markdown
Collaborator Author

Remember, when testing the event feed, keep in mind the CLICS spec says that the "score" values are numbers, meaning, they are not strings. The formatting is not preserved, of course. However, the rounding is observed since it works kind of the same was as the WTI did. XML standings are created and the scores are formatted according to the [scoring].format in the event feeder's pc2v9.ini. When converted to JSON for the event feed endpoints, that formatted string is converted to a number. So, for example, "100.0" will show up as 100 on the scoreboard endpoint. That being said, I'm not sure exactly how you tested the Event Feed scoreboard endpoint But here's the procedure:

  1. Start feeder 1 client (pc2ef --login ef1), the press the Start button to start the feeder.
  2. From a browser: https://localhost:50443/contests/nac25chall24practice/scoreboard when it prompts for user/password, use: adminsitrator1:administrator1, or admin:admin (from the realm.properties file, assuming you have one).
  3. From the command line curl: curl -k https://admin:admin@localhost:50443/contests/nac25chall24practice/scoreboard
    (you can also use administrator1:administrator1. If you're using a pc2 account it must have the View Event Feeds permission. )

Thanks. I'm not quite sure why the URL contains nac25chall24practice when the Contest Title is 2026 ICPC NAC Challenge 2024 Test, but I do see that it works as described.

Ugh... Yeah, when I first created the "nac25chall24practice" it was in January (21) 2026. I guess my mind was still on "2025" so when I created the contest.yaml with the contest id, I put in nac25chall24practice. It's one of those "historical" mistakes that never got corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants