Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2393 & GRAD2-2252: task is complete. #492

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,16 @@ private Transcript getTranscriptData(ca.bc.gov.educ.api.graduation.model.dto.Gra
private void createCourseListForTranscript(List<StudentCourse> studentCourseList, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, List<TranscriptResult> tList, String provincially, boolean xml) {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"), Locale.CANADA);
String today = EducGraduationApiUtils.formatDate(cal.getTime(), EducGraduationApiConstants.DEFAULT_DATE_FORMAT);

for (StudentCourse sc : studentCourseList) {
Date sessionDate = EducGraduationApiUtils.parseDate(sc.getSessionDate() + "/01", EducGraduationApiConstants.SECONDARY_DATE_FORMAT);
String sDate = EducGraduationApiUtils.formatDate(sessionDate, EducGraduationApiConstants.DEFAULT_DATE_FORMAT);
int diff = EducGraduationApiUtils.getDifferenceInMonths(sDate, today);
boolean notCompletedCourse = xml && diff <= 0;
if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && !sc.isCutOffCourse() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) {
if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) {
if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc)) {
continue;
}
TranscriptResult result = new TranscriptResult();
String equivOrChallenge = "";
if (sc.getEquivOrChallenge() != null) {
Expand All @@ -335,6 +339,24 @@ private void createCourseListForTranscript(List<StudentCourse> studentCourseList
}
}

/**
* check if the given cutoff course is the highest mark among the same courses, then it should be in transcript even though it is duplicate
* @param studentCourseList
* @param cutOffCourse
* @return
*/
private boolean isValidCutOffCourse(List<StudentCourse> studentCourseList, StudentCourse cutOffCourse) {
List<StudentCourse> dups = studentCourseList.stream().filter(sc ->
StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel())
).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).toList();

if (!dups.isEmpty()) {
StudentCourse topMarkCourse = dups.get(0);
return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate());
}
return false;
}

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 @@ -489,7 +511,7 @@ public List<StudentAssessment> removeDuplicatedAssessmentsForTranscript(List<Stu
.map((StudentAssessment studentAssessment) -> new StudentAssessmentDuplicatesWrapper(studentAssessment, xml))
.distinct()
.map(StudentAssessmentDuplicatesWrapper::getStudentAssessment)
.collect(Collectors.toList());
.toList();
}

private List<TranscriptResult> getTranscriptResults(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, boolean xml, String accessToken) {
Expand Down Expand Up @@ -805,11 +827,11 @@ private void getStudentCoursesAssessmentsNExams(ReportData data, ca.bc.gov.educ.
List<StudentCourse> studentExamList = sCList
.stream()
.filter(sc -> "Y".compareTo(sc.getProvExamCourse()) == 0)
.collect(Collectors.toList());
.toList();
List<StudentCourse> studentCourseList = sCList
.stream()
.filter(sc -> "N".compareTo(sc.getProvExamCourse()) == 0)
.collect(Collectors.toList());
.toList();
List<StudentAssessment> studentAssessmentList = graduationDataStatus.getStudentAssessments().getStudentAssessmentList();
List<AchievementCourse> sCourseList = new ArrayList<>();
List<Exam> sExamList = new ArrayList<>();
Expand Down Expand Up @@ -1025,12 +1047,10 @@ public ReportData prepareCertificateData(GraduationStudentRecord gradResponse,
data.setUpdateDate(EducGraduationApiUtils.formatDateForReportJasper(gradResponse.getUpdateDate().toString()));
data.setCertificate(getCertificateData(gradResponse, certType));
data.getStudent().setGraduationData(graduationData);
switch (certType.getCertificateTypeCode()) {
case "F", "SCF", "S":
data.getStudent().setFrenchCert(certType.getCertificateTypeCode());
break;
default:
data.getStudent().setEnglishCert(certType.getCertificateTypeCode());
if (certType.getCertificateTypeCode().equals("F") || certType.getCertificateTypeCode().equals("SCF") || certType.getCertificateTypeCode().equals("S")) {
data.getStudent().setFrenchCert(certType.getCertificateTypeCode());
} else {
data.getStudent().setEnglishCert(certType.getCertificateTypeCode());
}
return data;
}
Expand Down Expand Up @@ -1182,7 +1202,7 @@ private List<GradRequirement> getRequirementsMetAchvReport(List<ca.bc.gov.educ.a
List<StudentCourse> scList = optionalStudentCourses.getStudentCourseList()
.stream()
.filter(sc -> gr.getTranscriptRule() != null && sc.getGradReqMet().contains(gr.getTranscriptRule()))
.collect(Collectors.toList());
.toList();
List<AchievementCourse> cdList = new ArrayList<>();
scList.forEach(sc -> {
AchievementCourse cD = new AchievementCourse();
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 @@ -1370,6 +1370,47 @@
"used": false,
"careerPrep": false,
"restricted": false
},
{
"pen": "111111111",
"courseCode": "PH",
"courseName": "PHYSICS 12",
"courseLevel": "11",
"sessionDate": "2023/06",
"customizedCourseName": "",
"gradReqMet": "",
"gradReqMetDetail": "",
"completedCoursePercentage": 67.0,
"completedCourseLetterGrade": "C+",
"interimPercent": 67.0,
"interimLetterGrade": "C+",
"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": true
}
]
},
Expand Down
Loading