Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.60 KB | None | 0 0
  1. /// <summary>
  2.         /// Checks if student completes a certain course taken requirement. The requirement is completed if the HistoricalCodeId of the required course is the same as
  3.         /// a the HistoricalCodeId of an element from the studentCourses taken list. Or if current course registration period is preregistation and the HistoricalCodeId of the
  4.         /// required coruse is the same as the HistoricalCodeId of an element from coursesInProgress list.
  5.         /// </summary>
  6.         /// <param name="requirement">The requirement entity.</param>
  7.         /// <param name="studentCoursesTaken">All student taken courses.</param>
  8.         /// <param name="currentRegPeriod">Current registration period.</param>
  9.         /// <param name="coursesInProgress">All student courses INPROGRESS.</param>
  10.         /// <returns> TRUE if the requirement is completed and FALSE if the requirement is not completed.</returns>
  11.         private bool CheckIfCourseTakenRequirementIsCompleted(view_courseTakenRegReqs requirement, List<view_studentCoursesTaken> studentCoursesTaken, CourseRegPeriods currentRegPeriod, IEnumerable<view_studentCoursesTaken> coursesInProgress)
  12.         {
  13.             //1. Get the required course, the required grade and the required course code.
  14.             var requiredCourseId = requirement.RequiredCourseId;
  15.             var requiredGrade = requirement.MinimalGrade;
  16.             var requiredHistoricalCodeId = requirement.RequiredHistoricalCodeId;
  17.  
  18.             //2. All possible at AUBG
  19.             var possibleGrades = new List<string>
  20.             {
  21.                 "F", "D", "D+", "C-", "C", "C+", "B-", "B", "B+", "A-", "A"
  22.             };
  23.  
  24.             //3. Check if student has taken the course
  25.             foreach (var studentCourseTaken in studentCoursesTaken)
  26.             {
  27.                 //3.1. Does the requirement include a grade.
  28.                 bool checkForGrade = (requiredGrade != String.Empty) ? true : false;
  29.  
  30.                 //TODO: Ask registrars about the different bases and grade requirement
  31.                 if (!checkForGrade)
  32.                 {
  33.                     //TODO-Lazov - what about pass-fail
  34.                     if ((requiredHistoricalCodeId == studentCourseTaken.HistoricalCodeId) && ((CourseBases)studentCourseTaken.BasisId == CourseBases.Credit))
  35.                     {
  36.                         return true;
  37.                     }
  38.                 }
  39.                 else
  40.                 {
  41.                     var requiredGradePosition = possibleGrades.IndexOf(requiredGrade);
  42.                     var achievedGradePosition = possibleGrades.IndexOf(studentCourseTaken.Grade);
  43.  
  44.                     if ((requiredHistoricalCodeId == studentCourseTaken.HistoricalCodeId) && (requiredGradePosition <= achievedGradePosition) && ((CourseBases)studentCourseTaken.BasisId == CourseBases.Credit))
  45.                     {
  46.                         return true;
  47.                     }
  48.                 }
  49.             }
  50.  
  51.             //TODO-Lazov There was another requirement about course allowing to be counted as taken if it's been currently been taken
  52.             // If during pre-registration, then check if the student is not taking the course now
  53.             if ((currentRegPeriod == CourseRegPeriods.PreRegistration) && (requirement.CountCoursesInProgress == true))
  54.             {
  55.                 foreach (var course in coursesInProgress)
  56.                 {
  57.                     if ((requiredHistoricalCodeId == course.HistoricalCodeId))
  58.                     {
  59.                         return true;
  60.                     }
  61.                 }
  62.             }
  63.  
  64.             return false;
  65.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement