Skip to content

Commit

Permalink
Grad release 1.11.0
Browse files Browse the repository at this point in the history
Grad release 1.11.0
  • Loading branch information
kamal-mohammed authored Dec 7, 2023
2 parents 8ad6950 + d2fd2f5 commit 47edf5b
Show file tree
Hide file tree
Showing 40 changed files with 168 additions and 131 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-rule-engine-api</artifactId>
<version>1.8.52</version>
<version>1.8.53</version>
<name>educ-grad-rule-engine-api</name>
<description>Rule Engine API for GRAD team</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class RuleProcessorData implements RuleData {
private List<ProgramAlgorithmRule> algorithmRules;
private List<ProgramRequirement> gradProgramRules;
private Map<String,OptionalProgramRuleProcessor> mapOptional;
private Map<String,Integer> map1996Crse;
private List<StudentCourse> studentCourses;
private List<StudentCourse> excludedCourses;
private List<StudentAssessment> excludedAssessments;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.api.ruleengine.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -59,10 +60,14 @@ public class StudentCourse implements Serializable {
private boolean isRestricted;
private boolean isNotEligibleForElective;
private boolean isUsedInMatchRule;

private boolean isLessCreditCourse;
private boolean isValidationCourse;
private boolean isCutOffCourse;
private boolean isGrade10Course;
@JsonIgnore
private boolean isUsedInMinCreditRule;
@JsonIgnore
private Integer leftOverCredits;

public Integer getCreditsUsedForGrad() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private void handleFailedRules(OptionalProgramRuleProcessor obj, List<OptionalPr

if (failedRules.isEmpty()) {
logger.debug("All the failed assessment match rules met the assessment equivalency requirement for optional program!");
obj.setOptionalProgramGraduated(true);
} else {
// no need to add the failed one into requirementsNotMet as it was processed as failed before in assessment related rule processors
logger.debug("One or more Match rules did not meet the assessment equivalency requirement for optional program!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ public RuleData fire() {
courseList.sort(Comparator.comparing(StudentCourse::getCourseLevel).reversed()
.thenComparing(StudentCourse::getCompletedCoursePercentage).reversed());

List<ProgramRequirement> gradProgramRulesMatch = ruleProcessorData.getGradProgramRules()
.stream()
.filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0
&& "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0
&& "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0)
.collect(Collectors.toList());
List<ProgramRequirement> gradProgramRulesMatch = RuleEngineApiUtils.getMatchProgramRules(ruleProcessorData.getGradProgramRules());

if (courseList.isEmpty()) {
logger.warn("!!!Empty list sent to Match Credit 1986 Rule for processing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public RuleData fire() {

List<GradRequirement> requirementsMet = new ArrayList<>();
List<GradRequirement> requirementsNotMet = new ArrayList<>();
Map<String,Integer> map1996 = new HashMap<>();

List<StudentCourse> fineArtsCourseList = RuleProcessorRuleUtils
.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected())
Expand All @@ -52,37 +51,27 @@ public RuleData fire() {
List<StudentCourse> courseList = RuleProcessorRuleUtils
.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected())
.stream().filter(studentCourse -> studentCourse.getFineArtsAppliedSkills() == null
|| studentCourse.getFineArtsAppliedSkills().length() <= 0)
|| studentCourse.getFineArtsAppliedSkills().length() == 0)
.collect(Collectors.toList());
courseList.sort(Comparator.comparing(StudentCourse::getCourseLevel)
.thenComparing(StudentCourse::getCompletedCoursePercentage, Comparator.reverseOrder()));

List<ProgramRequirement> gradProgramRulesMatch = ruleProcessorData.getGradProgramRules()
.stream()
.filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0
&& "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0
&& "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0)
.collect(Collectors.toList());

if (courseList.isEmpty()) {
logger.warn("!!!Empty list sent to Match Credit 1996 Rule for processing");
return ruleProcessorData;
}

List<CourseRequirement> courseRequirements = ruleProcessorData.getCourseRequirements();
if(courseRequirements == null) {
courseRequirements = new ArrayList<>();
}
List<CourseRequirement> courseRequirements = ruleProcessorData.getCourseRequirements() == null? new ArrayList<>() : ruleProcessorData.getCourseRequirements();
List<CourseRequirement> originalCourseRequirements = new ArrayList<>(courseRequirements);

List<ProgramRequirement> gradProgramRulesMatch = RuleEngineApiUtils.getMatchProgramRules(ruleProcessorData.getGradProgramRules());
logger.debug("#### Match Program Rule size: {}",gradProgramRulesMatch.size());

List<StudentCourse> finalCourseList = new ArrayList<>();
List<ProgramRequirement> finalProgramRulesList = new ArrayList<>();


for (StudentCourse tempCourse : fineArtsCourseList) {
logger.debug("Processing Course: Code= {} Level = {}", tempCourse.getCourseCode(), tempCourse.getCourseLevel());
logger.debug("Processing FineArts Course: Code= {} Level = {}", tempCourse.getCourseCode(), tempCourse.getCourseLevel());
logger.debug("Course Requirements size: {}", courseRequirements.size());

List<CourseRequirement> tempCourseRequirements = courseRequirements.stream()
Expand Down Expand Up @@ -118,18 +107,18 @@ && isFineArtsOrAppliedSkillsRule(pr.getProgramRequirementCode().getProReqCode())
if (tempProgramRule != null
&& tempCourse.getCredits() > Integer.parseInt(tempProgramRule.getProgramRequirementCode().getRequiredCredits())) {
int extraCredits = tempCourse.getCredits() - Integer.parseInt(tempProgramRule.getProgramRequirementCode().getRequiredCredits());
map1996.put(tempCourse.getCourseCode(), extraCredits);
tempCourse.setLeftOverCredits(extraCredits);
}
}
}
}
logger.debug("Temp Program Rule: {}", tempProgramRule);
processCourse(tempCourse, tempCourseRequirements, tempProgramRule, requirementsMet, gradProgramRulesMatch, map1996);
logger.debug("Temp Program Rule for FineArts Course: {}", tempProgramRule);
processCourse(tempCourse, tempCourseRequirements, tempProgramRule, requirementsMet, gradProgramRulesMatch);

AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList);
AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList);
}
logger.debug("Final Program rules list: {}",finalProgramRulesList);
logger.debug("Final Program rules list for FineArts Course: {}",finalProgramRulesList);
processReqMet(finalProgramRulesList,finalCourseList,originalCourseRequirements,requirementsMet,gradProgramRulesMatch);

for (StudentCourse tempCourse : courseList) {
Expand Down Expand Up @@ -165,26 +154,25 @@ && isFineArtsOrAppliedSkillsRule(pr.getProgramRequirementCode().getProReqCode())

if (tempProgramRule != null && tempCourse.getCredits() > Integer.parseInt(tempProgramRule.getProgramRequirementCode().getRequiredCredits())) {
int extraCredits = tempCourse.getCredits() - Integer.parseInt(tempProgramRule.getProgramRequirementCode().getRequiredCredits());
map1996.put(tempCourse.getCourseCode(), extraCredits);
tempCourse.setLeftOverCredits(extraCredits);
}
}
}
}
logger.debug("Temp Program Rule: {}", tempProgramRule);
processCourse(tempCourse, tempCourseRequirements, tempProgramRule, requirementsMet, gradProgramRulesMatch, map1996);
processCourse(tempCourse, tempCourseRequirements, tempProgramRule, requirementsMet, gradProgramRulesMatch);

AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList);
AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList);
}

logger.debug("Final Program rules list: {}",finalProgramRulesList);
processReqMetAndNotMet(finalProgramRulesList,requirementsNotMet,finalCourseList,originalCourseRequirements,requirementsMet,gradProgramRulesMatch);
ruleProcessorData.setMap1996Crse(map1996);
checkAppliedScienceAndFineArtsCondition(ruleProcessorData.getStudentCourses(),ruleProcessorData.getRequirementsMet(),ruleProcessorData.getNonGradReasons(),ruleProcessorData.getMap1996Crse());
checkAppliedScienceAndFineArtsCondition(ruleProcessorData.getStudentCourses(),ruleProcessorData.getRequirementsMet(),ruleProcessorData.getNonGradReasons());
return ruleProcessorData;
}

private void checkAppliedScienceAndFineArtsCondition(List<StudentCourse> studentCourses, List<GradRequirement> requirementsMet, List<GradRequirement> nonGradReasons, Map<String, Integer> map1996Crse) {
private void checkAppliedScienceAndFineArtsCondition(List<StudentCourse> studentCourses, List<GradRequirement> requirementsMet, List<GradRequirement> nonGradReasons) {
boolean reqmtSatisfied = false;
int counter = 0; //counter to keep track of fine arts and applied science rule codes
for(GradRequirement gR:requirementsMet) {
Expand Down Expand Up @@ -213,15 +201,15 @@ private void checkAppliedScienceAndFineArtsCondition(List<StudentCourse> student
sc.setUsed(false);
sc.setUsedInMatchRule(false);

if(map1996Crse.get(sc.getCourseCode()) != null) {
map1996Crse.remove(sc.getCourseCode());
if (sc.getLeftOverCredits() != null && sc.getLeftOverCredits() > 0) {
sc.setLeftOverCredits(null);
}
}
}
}
}

private void processCourse(StudentCourse tempCourse, List<CourseRequirement> tempCourseRequirements, ProgramRequirement tempProgramRule, List<GradRequirement> requirementsMet, List<ProgramRequirement> gradProgramRulesMatch, Map<String,Integer> map1996) {
private void processCourse(StudentCourse tempCourse, List<CourseRequirement> tempCourseRequirements, ProgramRequirement tempProgramRule, List<GradRequirement> requirementsMet, List<ProgramRequirement> gradProgramRulesMatch) {
if (!tempCourseRequirements.isEmpty() && tempProgramRule != null) {
ProgramRequirement finalTempProgramRule = tempProgramRule;
if (requirementsMet.stream()
Expand Down Expand Up @@ -252,7 +240,7 @@ private void processCourse(StudentCourse tempCourse, List<CourseRequirement> tem
if (tempProgramRule != null) {
if(tempCourse.getCredits() > Integer.parseInt(tempProgramRule.getProgramRequirementCode().getRequiredCredits())) {
int extraCredits = tempCourse.getCredits() - Integer.parseInt(tempProgramRule.getProgramRequirementCode().getRequiredCredits());
map1996.put(tempCourse.getCourseCode(),extraCredits);
tempCourse.setLeftOverCredits(extraCredits);
}
setDetailsForCourses(tempCourse, tempProgramRule, requirementsMet);
}
Expand Down Expand Up @@ -339,9 +327,9 @@ public void processReqMetAndNotMet(List<ProgramRequirement> finalProgramRulesLis
}

public void setDetailsForCourses(StudentCourse tempCourse, ProgramRequirement tempProgramRule, List<GradRequirement> requirementsMet) {
tempCourse.setUsed(true);
tempCourse.setUsed(true);
tempCourse.setUsedInMatchRule(true);
tempCourse.setCreditsUsedForGrad(tempCourse.getCredits());
tempCourse.setCreditsUsedForGrad(tempCourse.getLeftOverCredits() != null && tempCourse.getLeftOverCredits() > 0? tempCourse.getLeftOverCredits():tempCourse.getCredits());
AlgorithmSupportRule.setGradReqMet(tempCourse,tempProgramRule);
tempProgramRule.getProgramRequirementCode().setPassed(true);
requirementsMet.add(new GradRequirement(tempProgramRule.getProgramRequirementCode().getTraxReqNumber(), tempProgramRule.getProgramRequirementCode().getLabel(),tempProgramRule.getProgramRequirementCode().getProReqCode()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -31,14 +32,15 @@ public RuleData fire() {

List<StudentCourse> tempStudentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(
ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected());
List<StudentCourse> studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).collect(Collectors.toList());

List<StudentCourse> studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule() || (sc.getLeftOverCredits() != null && sc.getLeftOverCredits() > 0)).collect(Collectors.toList());
studentCourses.sort(Comparator.comparing(StudentCourse::getCourseLevel, Comparator.reverseOrder())
.thenComparing(StudentCourse::getCompletedCoursePercentage, Comparator.reverseOrder()));
List<ProgramRequirement> gradProgramRules = ruleProcessorData.getGradProgramRules()
.stream()
.filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0
&& "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0
&& "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0)
.collect(Collectors.toList());
.distinct().toList();

if (tempStudentCourseList.isEmpty()) {
logger.warn("!!!Empty list sent to Min Credits Rule for processing");
Expand Down Expand Up @@ -96,7 +98,7 @@ public RuleData fire() {
logger.debug("Min Credits -> Required: {} Has : {}",requiredCredits,totalCredits);
}

studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).collect(Collectors.toList()));
studentCourses.addAll(tempStudentCourseList.stream().filter(sc -> sc.isUsedInMatchRule() && sc.getLeftOverCredits() == null).collect(Collectors.toList()));
ruleProcessorData.setStudentCourses(studentCourses);
return ruleProcessorData;
}
Expand All @@ -107,17 +109,22 @@ private void setCoursesReqMet(List<StudentCourse> studentCourses, ProgramRequire
for(StudentCourse sc:studentCourses) {
if(sc.getCourseLevel().contains(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim()) && !sc.getCourseCode().startsWith("X")) {
tC += sc.getCredits();
processReqMet(sc,gradProgramRule);
processReqMet(sc,gradProgramRule, tC, requiredCredits);
if (tC > requiredCredits) {
break;
}

}
}
}

public void processReqMet(StudentCourse sc, ProgramRequirement gradProgramRule) {
public void processReqMet(StudentCourse sc, ProgramRequirement gradProgramRule, int totalCredits, int requiredCredits) {
sc.setUsed(true);
sc.setUsedInMinCreditRule(true);
if (totalCredits > requiredCredits) {
int leftOverCredit = totalCredits - requiredCredits;
sc.setCreditsUsedForGrad(sc.getCredits() - leftOverCredit);
sc.setLeftOverCredits(leftOverCredit);
}
AlgorithmSupportRule.setGradReqMet(sc,gradProgramRule);
}

Expand Down
Loading

0 comments on commit 47edf5b

Please sign in to comment.