diff --git a/api/pom.xml b/api/pom.xml
index ae5859c8..62a869c7 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-graduation-api
- 1.8.46
+ 1.8.49
educ-grad-graduation-api
Ministry of Education GRAD GRADUATION API
diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptCourse.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptCourse.java
index 78a366da..aa82bb63 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptCourse.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptCourse.java
@@ -159,16 +159,25 @@ public void setFineArtsAppliedSkills(String fineArtsAppliedSkills) {
this.fineArtsAppliedSkills = fineArtsAppliedSkills;
}
+ public boolean isDuplicate(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ TranscriptCourse that = (TranscriptCourse) o;
+ return Objects.equals(getCode(), that.getCode()) && Objects.equals(getLevel(), that.getLevel());
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TranscriptCourse that = (TranscriptCourse) o;
- return Objects.equals(code, that.code);
+ return Objects.equals(getCode(), that.getCode()) && Objects.equals(getLevel(), that.getLevel()) && Objects.equals(getSessionDate(), that.getSessionDate());
+
}
@Override
public int hashCode() {
- return Objects.hash(code);
+ return Objects.hash(getCode(), getLevel(), getSessionDate());
}
+
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptResult.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptResult.java
index 93fd95a9..4eb73b18 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptResult.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/TranscriptResult.java
@@ -62,6 +62,10 @@ public void setUsedForGrad(String value) {
this.usedForGrad = value;
}
+ public Double getCompletedPercentage() {
+ return this.mark != null? this.mark.getCompletedCoursePercentage() : null;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java
index 2ca9f570..e8ac5eed 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java
@@ -340,7 +340,7 @@ private void createCourseListForTranscript(List studentCourseList
}
result.setUsedForGrad(sc.getCreditsUsedForGrad() != null ? sc.getCreditsUsedForGrad().toString() : "");
result.setEquivalency(sc.getSpecialCase() != null && sc.getSpecialCase().compareTo("C") == 0 ? "C" : equivOrChallenge);
- tList.add(result);
+ addIntoTranscriptList(result, tList);
}
}
}
@@ -365,6 +365,25 @@ private boolean isValidCutOffCourse(List studentCourseList, Stude
}
@Generated
+ private void addIntoTranscriptList(TranscriptResult transcriptResult, List tList) {
+ List dups = tList.stream().filter(tr -> tr.getCourse().isDuplicate(transcriptResult.getCourse()) &&
+ !tr.getCourse().equals(transcriptResult.getCourse())
+ ).sorted(Comparator.comparing(TranscriptResult::getCompletedPercentage, Comparator.nullsLast(Double::compareTo)).reversed()).toList();
+
+ // Handling duplicates
+ if (!dups.isEmpty()) {
+ TranscriptResult tr = dups.get(0);
+ // GRAD2-2394: only if a course taken previously was not used for grad(= requirementMet is blank), then the highest course will be taken
+ if (StringUtils.isBlank(tr.getRequirement()) && tr.getCompletedPercentage() < transcriptResult.getCompletedPercentage()) {
+ // replace
+ tList.remove(tr);
+ tList.add(transcriptResult);
+ return;
+ }
+ }
+ tList.add(transcriptResult);
+ }
+
private TranscriptCourse setCourseObjForTranscript(StudentCourse sc, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus) {
TranscriptCourse crse = new TranscriptCourse();
crse.setCode(sc.getCourseCode());
@@ -567,7 +586,7 @@ private void sortOnCourseCode(List cList) {
}
private String getCredits(String program, String courseCode, Integer totalCredits, boolean isRestricted) {
- if (((program.contains("2004") || program.contains("2018")) && (courseCode.startsWith("X") || courseCode.startsWith("CP"))) || isRestricted) {
+ if (((program.contains("2004") || program.contains("2018") || program.contains("2023")) && (courseCode.startsWith("X") || courseCode.startsWith("CP"))) || isRestricted) {
return String.format("(%s)", totalCredits);
}
return String.valueOf(totalCredits);
diff --git a/api/src/test/resources/json/gradstatus.json b/api/src/test/resources/json/gradstatus.json
index 973ccc5c..d3c678a6 100644
--- a/api/src/test/resources/json/gradstatus.json
+++ b/api/src/test/resources/json/gradstatus.json
@@ -1371,6 +1371,47 @@
"careerPrep": false,
"restricted": false
},
+ {
+ "pen": "111111111",
+ "courseCode": "PH",
+ "courseName": "PHYSICS 12",
+ "courseLevel": "11",
+ "sessionDate": "2020/06",
+ "customizedCourseName": "",
+ "gradReqMet": "",
+ "gradReqMetDetail": "",
+ "completedCoursePercentage": 57.0,
+ "completedCourseLetterGrade": "C",
+ "interimPercent": 0.0,
+ "interimLetterGrade": "",
+ "bestSchoolPercent": null,
+ "bestExamPercent": null,
+ "equivOrChallenge": "",
+ "fineArtsAppliedSkills": "",
+ "metLitNumRequirement": null,
+ "credits": 4,
+ "creditsUsedForGrad": 0,
+ "relatedCourse": "",
+ "relatedCourseName": null,
+ "relatedLevel": "",
+ "hasRelatedCourse": "N",
+ "genericCourseType": "",
+ "language": "",
+ "workExpFlag": null,
+ "provExamCourse": "N",
+ "notEligibleForElective": false,
+ "locallyDeveloped": false,
+ "independentDirectedStudies": false,
+ "boardAuthorityAuthorized": false,
+ "failed": false,
+ "duplicate": false,
+ "projected": false,
+ "notCompleted": false,
+ "used": false,
+ "careerPrep": false,
+ "restricted": false,
+ "cutOffCourse": false
+ },
{
"pen": "111111111",
"courseCode": "PH",