From ef42274a393dae7f5d189abf815a506d49a6dc28 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 9 Nov 2023 16:44:43 -0800 Subject: [PATCH 1/4] GRAD2-2394: task is completed. GRAD2-2394: task is completed. --- .../model/report/TranscriptCourse.java | 13 +++++- .../model/report/TranscriptResult.java | 4 ++ .../api/graduation/service/ReportService.java | 23 ++++++++++- api/src/test/resources/json/gradstatus.json | 41 +++++++++++++++++++ 4 files changed, 78 insertions(+), 3 deletions(-) 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..649a614d 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.getCompletedCoursePercentage(); + } + @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 e86b2f3d..6398a6d0 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 @@ -27,6 +27,8 @@ import java.util.*; import java.util.stream.Collectors; +import static java.util.stream.Collectors.*; + @Slf4j @Service public class ReportService { @@ -334,7 +336,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); } } } @@ -357,6 +359,25 @@ private boolean isValidCutOffCourse(List studentCourseList, Stude return false; } + 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()); 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", From 7cd344b652d4045a21ef03f48b38a96c7c088d32 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Fri, 10 Nov 2023 10:46:19 -0800 Subject: [PATCH 2/4] Improved to remove the potential NPE issue in TranscriptResult. Improved to remove the potential NPE issue in TranscriptResult. --- .../gov/educ/api/graduation/model/report/TranscriptResult.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 649a614d..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 @@ -63,7 +63,7 @@ public void setUsedForGrad(String value) { } public Double getCompletedPercentage() { - return this.mark.getCompletedCoursePercentage(); + return this.mark != null? this.mark.getCompletedCoursePercentage() : null; } @Override From c22bcf322ab3a1fe2d36aa1ba5aa3cc8d7e90571 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Fri, 17 Nov 2023 00:43:38 +0530 Subject: [PATCH 3/4] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From d7fa85e01eab12babad0fb53e656a5f760944eb1 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 17 Nov 2023 12:20:23 -0700 Subject: [PATCH 4/4] GRAD2-2392 HD-23020-P3 - GRAD - Service Request - Locally Developed Courses on 2023 Transcripts Missing Parenthesis --- .../ca/bc/gov/educ/api/graduation/service/ReportService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 6398a6d0..028ddb98 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 @@ -27,8 +27,6 @@ import java.util.*; import java.util.stream.Collectors; -import static java.util.stream.Collectors.*; - @Slf4j @Service public class ReportService { @@ -574,7 +572,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);