Skip to content

Commit

Permalink
Merge branch 'grad-release' into develop/alex-GRAD2-2306
Browse files Browse the repository at this point in the history
  • Loading branch information
arybakov-cgi authored Nov 21, 2023
2 parents 0f85c28 + 72bcadb commit df00275
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-graduation-api</artifactId>
<version>1.8.46</version>
<version>1.8.49</version>
<name>educ-grad-graduation-api</name>
<description>Ministry of Education GRAD GRADUATION API</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private void createCourseListForTranscript(List<StudentCourse> 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);
}
}
}
Expand All @@ -365,6 +365,25 @@ private boolean isValidCutOffCourse(List<StudentCourse> studentCourseList, Stude
}

@Generated
private void addIntoTranscriptList(TranscriptResult transcriptResult, List<TranscriptResult> tList) {
List<TranscriptResult> 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());
Expand Down Expand Up @@ -567,7 +586,7 @@ private void sortOnCourseCode(List<StudentCourse> 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);
Expand Down
41 changes: 41 additions & 0 deletions api/src/test/resources/json/gradstatus.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit df00275

Please sign in to comment.