Ejemplo n.º 1
0
        public override bool Perform()
        {
            List<Slots> missing = CourseConstructor.ContainsScheduledCourseData(Semantics);

             if (missing.Count > 0)
             {
            PromptForMissing(Semantics, missing);
            return false;
             }

             Course = CourseConstructor.ContructScheduledCourse(Semantics);

             if (Course == null)
             {
            correctCourse();
            return false;
             }
             else
             {
            List<IFilter<Course>> missingClasses = Student.Schedule.GetMissingPreReqs(Course);

            if (missingClasses.Count > 0)
            {
               DialogManager.Instance.InformPreReqs(Course, missingClasses);
               return false;
            }
            else
            {
               if (!CourseConstructor.IsSemesterValid(Course.Semester, Course.Year)) {
                  RecoManager.Instance.Say("That semester is past your graduation date! Please install a flux capacitor and accelerate to 88 miles per hour.");
                  return false;
               }

               switch (Course.Semester)
               {
                  case Semester.Fall:
                     if (!Course.Course.fall)
                     {
                        DialogManager.Instance.notOffered(Semantics, Course.Semester);
                        return false;
                     }
                     break;
                  case Semester.Spring:
                     if (!Course.Course.spring)
                     {
                        DialogManager.Instance.notOffered(Semantics, Course.Semester);
                        return false;
                     }
                     break;
                  default:
                     return false;

               }

               Student.AddCourse(Course);
               Student.RemoveBookmark(Course.Course);
               return true;
            }
             }
        }
Ejemplo n.º 2
0
        public List<ScheduledCourse> GetBeforeClass(ScheduledCourse course)
        {
            List<ScheduledCourse> beforeCourses = new List<ScheduledCourse>();

             foreach(ScheduledCourse c in Courses){
            if(course.isPreviousCourse(c)){
               beforeCourses.Add(c);
            }
             }
             return beforeCourses;
        }
Ejemplo n.º 3
0
        public MissingPrereqArgs(ScheduledCourse course, List<IFilter<Course>> prereqs)
        {
            this.prereqs = course.Course.GetAllPrereqs().Distinct().ToList();
             this.prereqs.Sort();

             List<IFilter<Course>> missing = new List<IFilter<Course>>();
             //TODO: BrianR get prereqs using course requirements and registered courses
             foreach (var prereq in prereqs)
             {
            int count = (from c in DialogManager.Instance.CurrStudent.Schedule.Courses
                         where prereq.Matches(c.Course)
                         select c.Course).Count();
            if (count == 0)
            {
               missing.Add(prereq);
            }
             }

             this.prereqs = missing;
             this.Course = course;
        }
Ejemplo n.º 4
0
        public List<IFilter<Course>> GetMissingPreReqs(ScheduledCourse course)
        {
            List<IFilter<Course>> missing = new List<IFilter<Course>>();
             List<ScheduledCourse> previousCourses = this.GetBeforeClass(course);

             System.Console.WriteLine("PreviousCourses");
             foreach (ScheduledCourse c in previousCourses)
             {
            System.Console.WriteLine("Previous: " + c.Course.DeptAbv + c.Course.Number);
             }
             //TODO: BrianR get prereqs using course requirements and registered courses
             foreach (var prereq in course.Course.Prerequisites)
             {
            int count = (from c in previousCourses
                         where prereq.Matches(c.Course)
                         select c.Course).Count();
            if (count == 0)
            {
               missing.Add(prereq);
            }
             }

             return missing;
        }
Ejemplo n.º 5
0
 private void OnMissingPreReqs(ScheduledCourse course, List<IFilter<Course>> missing)
 {
     var evt = missingPrereqs;
      if (evt != null)
     evt(this, new MissingPrereqArgs(course, missing));
 }
Ejemplo n.º 6
0
        public void InformPreReqs(ScheduledCourse course, List<IFilter<Course>> missing)
        {
            OnMissingPreReqs(course, missing);
             List<IFilter<Course>> scheduledTooLate = new List<IFilter<Course>>();
             foreach (var prereq in missing)
             {
            int count = (from c in CurrStudent.Schedule.Courses
                         where prereq.Matches(c.Course)
                         select c.Course).Count();
            if (count > 0)
            {
               scheduledTooLate.Add(prereq);
            }
             }

             if (scheduledTooLate.Count == 0)
             {
            RecoManager.Instance.Say("You are missing prerequisites for " + course.Course.ToString());
             }
             else {
            string str = "";
            foreach (IFilter<Course> filter in scheduledTooLate)
            {
               str += Filter<Course>.toSpokenString(filter) + " ";
            }

            RecoManager.Instance.Say("You must schedule " + course.Course.ToString() + " after " + str);
             }
        }
Ejemplo n.º 7
0
 public void AddCourse(ScheduledCourse course)
 {
     Schedule.Courses.Add(course);
      foreach (DegreeRequirement req in Degree.Requirements.Where(c => c.Fulfillment == null))
      {
     if (req.CourseRequirement.Matches(course.Course))
     {
        req.Fulfillment = course;
        break;
     }
      }
      OnScheduleChanged();
 }
Ejemplo n.º 8
0
        public ScheduledCourse MoveCourse(ScheduledCourse course)
        {
            //Remove existing course then add the new course
             //Return exiting course for undo
             ScheduledCourse existing = FindCourse(course.Course);

             if (existing != null)
             {
            RemoveCourse(existing.Course);
             }

             AddCourse(course);

             OnScheduleChanged();
             return existing;
        }
Ejemplo n.º 9
0
 public void LoadSchedule(String filepath)
 {
     using (StreamReader readFile = new StreamReader(filepath))
      {
     string line;
     string[] data;
     while ((line = readFile.ReadLine()) != null)
     {
        data = line.Split(',');
        if (data.Length >= 4)
        {
           Department dept = CourseCatalog.Instance.GetDepartment(data[0]);
           bool success = dept != null;
           int number;
           success &= int.TryParse(data[1], out number);
           Semester sem;
           success &= Enum.TryParse(data[2], out sem);
           int year;
           success &= int.TryParse(data[3], out year);
           if (success)
           {
              Course course = CourseCatalog.Instance.GetCourse(dept, number);
              ScheduledCourse scheduled_course = new ScheduledCourse(course, sem, year);
              AddCourse(scheduled_course);
           }
        }
     }
      }
 }
Ejemplo n.º 10
0
        public Boolean isPreviousCourse(ScheduledCourse otherCourse)
        {
            //Returns true of otherCourse has been finished before this starts.

             if (this.Year > otherCourse.Year) {
            return true;
             }
             else if (this.Year == otherCourse.Year)
             {
            return (this.Semester == Semester.Fall && otherCourse.Semester == Semester.Spring);
             }
             else
             {
            return false;
             }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Contructs the scheduled course, will get the year and semester from the ActionManager
        /// if they are not part of the semantic value
        /// </summary>
        /// <param name="semantics">The semantics.</param>
        /// <returns></returns>
        public static ScheduledCourse ContructScheduledCourse(SemanticValueDict semantics)
        {
            Course course = ContructCourse(semantics);
             if (course == null)
             {
            return null;
             }
             Semester? sem = GetSemester(semantics, DialogManager.Instance.CurrentSemester);
             int? year = GetYear(semantics, DialogManager.Instance.CurrentYear);

             if (year == null)
            throw new InvalidOperationException("Should not be call without valid year information");
             if (sem == null)
            throw new InvalidOperationException("Should not be called without semester information");

             ScheduledCourse sCourse = new ScheduledCourse(course, sem.Value, year.Value);
             return sCourse;
        }