Skip to content

Commit

Permalink
Merge pull request #621 from bcgov/feature/GRAD2-2222,2379
Browse files Browse the repository at this point in the history
GRAD2-2222 & GRAD2-2379: tasks are completed.
  • Loading branch information
kamal-mohammed authored Nov 7, 2023
2 parents 3e7257f + 8c906c1 commit fe358d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
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

0 comments on commit fe358d1

Please sign in to comment.