Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I983 custom honors solved count #1001

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.list;

import java.io.Serializable;
import java.util.Comparator;
import java.text.Normalizer;

/**
* Compare the name of one team with another, ignoring case.
Expand Down Expand Up @@ -44,6 +45,12 @@ public int compare(String displayNameOne, String displayNameTwo) {
}
}
}

/**
* strip accents off string to make them accent insensitive
*/
displayNameOne = Normalizer.normalize(displayNameOne, Normalizer.Form.NFD);
displayNameTwo = Normalizer.normalize(displayNameTwo, Normalizer.Form.NFD);
/*
* Perform quick check to see if the 2 strings have a chance of being in the same ballpark
*/
Expand Down
10 changes: 9 additions & 1 deletion src/edu/csus/ecs/pc2/core/list/AccountNameComparator.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.list;

import java.io.Serializable;
import java.util.Comparator;
import java.text.Normalizer;

/**
* Compare the name of one team with another.
Expand Down Expand Up @@ -44,6 +45,13 @@ public int compare(String displayNameOne, String displayNameTwo) {
}
}
}

/**
* strip accents off string to make them accent insensitive
*/
displayNameOne = Normalizer.normalize(displayNameOne, Normalizer.Form.NFD);
displayNameTwo = Normalizer.normalize(displayNameTwo, Normalizer.Form.NFD);

if (displayNameOne.charAt(0) != displayNameTwo.charAt(0)) {
// if first character different then just regular sort
return displayNameOne.compareTo(displayNameTwo);
Expand Down
66 changes: 66 additions & 0 deletions src/edu/csus/ecs/pc2/core/model/FinalizeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public class FinalizeData implements Serializable {

private boolean useWFGroupRanking = true;

private boolean customizeHonorsSolvedCount = false;

private int highestHonorSolvedCount = 0;

private int highHonorSolvedCount = 0;

private int honorSolvedCount = 0;

/**
* @return last rank for gold.
*/
Expand Down Expand Up @@ -133,4 +141,62 @@ public void setUseWFGroupRanking(boolean useWFGroupRanking) {
public boolean isUseWFGroupRanking() {
return useWFGroupRanking;
}

/**
* Set whether to customize the minimum number of problems solved for each Honors field
*
* @param customizeHonorsSolvedCount
*/
public void setCustomizeHonorsSolvedCount(boolean customizeHonorsSolvedCount) {
this.customizeHonorsSolvedCount = customizeHonorsSolvedCount;
}

/**
* Return whether or not minimum problems solved for honors fields is to be customized or not
*
* @return true if WF group rankings are to be used
SamanwaySadhu marked this conversation as resolved.
Show resolved Hide resolved
*/
public boolean isCustomizeHonorsSolvedCount() {
return customizeHonorsSolvedCount;
}

/**
* Set the customized values of minimum number of problems solved for Highest Honors, High Honors and Honors fields
*
* @param highestHonorSolvedCount
* @param highHonorSolvedCount
* @param honorSolvedCount
*/
public void setHonorsSolvedCount(int highestHonorSolvedCount, int highHonorSolvedCount, int honorSolvedCount) {
this.highestHonorSolvedCount = highestHonorSolvedCount;
this.highHonorSolvedCount = highHonorSolvedCount;
this.honorSolvedCount = honorSolvedCount;
}

/**
* Return the customized minimum problems required to solve to be Highest Honors
*
* @return the customized minimum problems required to solve to be Highest Honors
*/
public int getHighestHonorSolvedCount() {
return highestHonorSolvedCount;
}

/**
* Return the customized minimum problems required to solve to be High Honors
*
* @return the customized minimum problems required to solve to be High Honors
*/
public int getHighHonorSolvedCount() {
return highHonorSolvedCount;
}

/**
* Return the customized minimum problems required to solve to be Honors
*
* @return the customized minimum problems required to solve to be Honors
*/
public int getHonorSolvedCount() {
return honorSolvedCount;
}
}
65 changes: 65 additions & 0 deletions src/edu/csus/ecs/pc2/core/report/ResultsCSVReport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.report;

import java.io.PrintWriter;

import edu.csus.ecs.pc2.core.log.Log;
import edu.csus.ecs.pc2.core.model.Filter;
import edu.csus.ecs.pc2.exports.ccs.ResultsFile;

public class ResultsCSVReport extends AbstractReport {

/**
* Generates the results.csv report
*
* @author Samanway Sadhu
*/
private static final long serialVersionUID = -6988627277661871941L;

private ResultsFile resultsFile = new ResultsFile();

@Override
public String getReportTitle() {
return "results.csv report";
}

@Override
public String[] createReport(Filter filter) {
return resultsFile.createCSVFileLines(getContest());
}

@Override
public String getPluginTitle() {
return "results.csv";
}

public void writeReport(PrintWriter printWriter) {

printWriter.println();

try {

printHeader(printWriter);

try {

String[] lines = resultsFile.createCSVFileLines(getContest());

for (String line : lines) {
printWriter.println(line);
}
} catch (Exception e) {
printWriter.println("Exception in report: " + e.getMessage());
e.printStackTrace(printWriter);
}

printFooter(printWriter);

printWriter.close();
printWriter = null;

} catch (Exception e) {
log.log(Log.INFO, "Exception writing report", e);
}
}
}
1 change: 1 addition & 0 deletions src/edu/csus/ecs/pc2/core/report/ResultsTSVReport.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.report;

import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Comparator;

import edu.csus.ecs.pc2.core.list.AccountList;
import edu.csus.ecs.pc2.core.list.AccountNameComparator;
import edu.csus.ecs.pc2.core.list.AccountNameCaseComparator;
import edu.csus.ecs.pc2.core.model.Account;

/**
Expand All @@ -23,7 +23,7 @@ public class FinalsStandingsRecordComparator implements Serializable, Comparator
*/
private static final long serialVersionUID = 2417425534254224622L;

private AccountNameComparator accountNameComparator = new AccountNameComparator();
private AccountNameCaseComparator accountNameCaseComparator = new AccountNameCaseComparator();

private AccountList cachedAccountList;

Expand Down Expand Up @@ -89,7 +89,7 @@ public int compare(StandingsRecord o1, StandingsRecord o2) {
nameB = accountB.getDisplayName();
b5 = teamB.getClientId().hashCode();
// nameComparison = nameA.toLowerCase().compareTo(nameB.toLowerCase());
nameComparison = accountNameComparator.compare(nameA, nameB);
nameComparison = accountNameCaseComparator.compare(nameA, nameB);

//
// Primary Sort = number of solved problems (high to low)
Expand Down
Loading
Loading