private static StudentGradeContainer GetMatchingStudentGradeContainer(StudentGradeContainer needle, IEnumerable <StudentGradeContainer> haystack) { StudentGradeContainer primaryChoice = null; StudentGradeContainer secondaryChoice = null; foreach (var item in haystack) { if (item.StudentGrade.StudentSection == needle.StudentGrade.StudentSection) { primaryChoice = item; } else if (secondaryChoice == null && item.StudentGrade.StudentSection.CourseTitle == needle.StudentGrade.StudentSection.CourseTitle) { secondaryChoice = item; } } return(primaryChoice ?? secondaryChoice); }
private static void CalculateMetricComponentTrend(StudentGradeContainer studentGradeContainer, StudentCourseGradingPeriodCalculation previousGradingPeriodData) { if (previousGradingPeriodData == null) { return; } var StudentSection = studentGradeContainer.StudentGrade.StudentSection; if (StudentSection == null) { return; } var matchedPreviousGrade = GetMatchingStudentGradeContainer(studentGradeContainer, previousGradingPeriodData.StudentGrades); if (matchedPreviousGrade == null) { return; } var currentRank = studentGradeContainer.StudentGrade.GradeRank; var previousRank = matchedPreviousGrade.StudentGrade.GradeRank; if (currentRank == previousRank) { studentGradeContainer.Trend = 0; } else if (currentRank > previousRank) { // the trend on the metric component for this metric is calculated as the opposite of the trend // for the metric calculation, but both end up as the same result: // TrendInterpretation is -1, which means that a TrendDirection of -1 means 'doing better'. studentGradeContainer.Trend = -1; } else { studentGradeContainer.Trend = 1; } }