Skip to content

Commit

Permalink
Merge pull request #496 from bcgov/feature/GRAD2-2394
Browse files Browse the repository at this point in the history
GRAD2-2394: task is completed.
  • Loading branch information
infstar authored Nov 10, 2023
2 parents ed4934a + 7cd344b commit 8259233
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
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 @@ -27,6 +27,8 @@
import java.util.*;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.*;

@Slf4j
@Service
public class ReportService {
Expand Down Expand Up @@ -334,7 +336,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 @@ -357,6 +359,25 @@ private boolean isValidCutOffCourse(List<StudentCourse> studentCourseList, Stude
return false;
}

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
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 8259233

Please sign in to comment.