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-2222 & GRAD2-2379: tasks are completed. #621

Merged
merged 1 commit into from
Nov 7, 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 @@ -18,6 +18,7 @@
package ca.bc.gov.educ.grad.report.dto.impl;

import ca.bc.gov.educ.grad.report.model.transcript.TranscriptCourse;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;
import java.util.logging.Logger;
Expand Down Expand Up @@ -240,20 +241,17 @@ public boolean courseEquals(final TranscriptCourse compareCourse) {
@Override
public boolean compareCourse(final TranscriptCourse compareCourse) {

final int interimPercentage = getInt(this.getInterimMark());
final int finalPercentage = getInt(this.getFinalPercent());
final int compareFinalPercentage = getInt(compareCourse.getFinalPercent());
final int compareInterimPercentage = getInt(compareCourse.getInterimMark());
// Interim % should only be looked at if the courses do not have a final LG
final int percentage = StringUtils.isBlank(this.getFinalLetterGrade())? getInt(this.getInterimMark()) : getInt(this.getFinalPercent());
final int comparePercentage = StringUtils.isBlank(compareCourse.getFinalLetterGrade())? getInt(compareCourse.getInterimMark()) : getInt(compareCourse.getFinalPercent());

// Removes duplication of courses by comparing and finding course with
//highest percentage.
boolean replaceCourse = ((interimPercentage < compareFinalPercentage
&& finalPercentage < compareFinalPercentage
&& compareFinalPercentage != 0)
|| (finalPercentage < compareInterimPercentage
&& finalPercentage != 0
&& compareInterimPercentage != 0));
return replaceCourse;
// highest percentage.
return percentage <= comparePercentage && comparePercentage != 0;
}

public boolean isCompletedCourseUsedForGrad() {
return StringUtils.isNotBlank(this.finalLetterGrade) && StringUtils.isNotBlank(this.requirement);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,10 @@ public interface TranscriptCourse {
* @return true when compareCourse has highest marks.
*/
boolean compareCourse(final TranscriptCourse compareCourse);

/**
* Check this course is completed and used for graduation
* @return
*/
boolean isCompletedCourseUsedForGrad();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -710,12 +711,13 @@ private List<TranscriptCourse> filterCourses(final List<TranscriptCourse> result
private TranscriptCourse getInterimCourse(
TranscriptCourse course,
final List<TranscriptCourse> results) {
//Check for dulicate courses
//Check for duplicate courses
for (final TranscriptCourse compareCourse : results) {
//Check and compare two courses for duplication and if required
//replace course based on requirement.
if (course.courseEquals(compareCourse)
&& course.compareCourse(compareCourse)) {
&& !course.isCompletedCourseUsedForGrad()
&& course.compareCourse(compareCourse) ) {
course = compareCourse;
}
}
Expand Down
Loading