Skip to content

Commit

Permalink
Course Timetabling Solver: Export CSV
Browse files Browse the repository at this point in the history
- corrected Export Solution when the class names include external ids (class suffixes, unitime.solver.showClassSuffixes is true)
- include EXT_ID column with the external id/class suffix
  • Loading branch information
tomas-muller committed Nov 15, 2023
1 parent 1d911aa commit 51e564c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions JavaSource/org/unitime/timetable/solver/TimetableSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ public CSVFile export(boolean useAmPm) {
new CSVField("ITYPE"),
new CSVField("SECTION"),
new CSVField("SUFFIX"),
new CSVField("EXT_ID"),
new CSVField("DATE_PATTERN"),
new CSVField("DAY"),
new CSVField("START_TIME"),
Expand All @@ -1168,14 +1169,21 @@ public CSVFile export(boolean useAmPm) {
Placement placement = currentSolution().getAssignment().getValue(lecture);
String name = lecture.getName();
String itype = ""; String section = "";
String ext = "";
if (name.indexOf(" - ")>0) {
ext = name.substring(name.lastIndexOf(" - ")+3);
name = name.substring(0, name.lastIndexOf(" - ")).trim();
}
if (name.indexOf(' ')>=0) {
section = name.substring(name.lastIndexOf(' ')+1);
name = name.substring(0, name.lastIndexOf(' ')).trim();
}
String suffix="";
while (section.charAt(section.length()-1)>='a' && section.charAt(section.length()-1)<='z') {
suffix = section.charAt(section.length()-1)+suffix;
section = section.substring(0,section.length()-1);
if (suffix.matches("[0-9]+[a-z]+")) {
while (section.charAt(section.length()-1)>='a' && section.charAt(section.length()-1)<='z') {
suffix = section.charAt(section.length()-1)+suffix;
section = section.substring(0,section.length()-1);
}
}
if (name.indexOf(' ')>=0) {
itype = name.substring(name.lastIndexOf(' ')+1);
Expand All @@ -1191,6 +1199,7 @@ public CSVFile export(boolean useAmPm) {
new CSVField(itype),
new CSVField(section),
new CSVField(suffix),
new CSVField(ext),
new CSVField(placement==null?"":placement.getTimeLocation().getDatePatternName()),
new CSVField(placement==null?"":placement.getTimeLocation().getDayHeader()),
new CSVField(placement==null?"":placement.getTimeLocation().getStartTimeHeader(useAmPm)),
Expand Down

0 comments on commit 51e564c

Please sign in to comment.