Esempio n. 1
0
        public ActionResult BuildTimetable(int?TermId)
        {
            if (TermId == null)
            {
                return(RedirectToAction("ChooseTermForTimetable"));
            }

            int termId    = TermId.Value;
            int studentId = ((Student)Session["student"]).StudentId;

            if (!CanEnroll(studentId, termId))
            {
                return(RedirectToAction("RegistrationStatus"));
            }

            List <EnrollmentOption> enrollmentOptions = dao.GetEnrollmentOptions(studentId, termId);

            List <TermDisplay> terms = new List <TermDisplay>();
            TermDisplay        currentTerm = null;
            CourseDisplay      currentCourse = null;
            int prevTermId = 0, prevCourseId = 0;

            foreach (EnrollmentOption o in enrollmentOptions)
            {
                if (prevTermId != o.ProgramSemesterId)
                {
                    // new term, new course
                    prevTermId   = o.ProgramSemesterId;
                    prevCourseId = o.CourseId;
                    currentTerm  = new TermDisplay()
                    {
                        ProgramSemesterName = o.ProgramSemesterName,
                        Courses             = new List <CourseDisplay>(),
                        Electives           = new List <ElectiveDisplay>()
                    };
                    terms.Add(currentTerm);

                    currentCourse = AddCourseToTerm(o, currentTerm);
                }
                else if (prevCourseId != o.CourseId)
                {
                    // same term, new course
                    prevCourseId  = o.CourseId;
                    currentCourse = AddCourseToTerm(o, currentTerm);
                }
                else
                {
                    // same course, another section
                    AddSectionToCourse(o, currentCourse);
                }
            }

            ViewBag.JSONString = JsonConvert.SerializeObject(enrollmentOptions);
            TimetableBuilder timetableBuilder = new TimetableBuilder()
            {
                Terms = terms, TermId = termId
            };

            return(View(timetableBuilder));
        }
Esempio n. 2
0
 private void AddSectionToCourse(EnrollmentOption o, CourseDisplay currentCourse)
 {
     if (!currentCourse.CourseIsOffered)
     {
         return;
     }
     currentCourse.Sections.Add(new SectionDisplay
     {
         SectionId         = o.SectionId,
         SectionNum        = o.SectionNum,
         SectionIsSelected = o.SectionIsSelected,
         Classes           = o.Classes.Select(c => ConvertToClassDisplay(c)).ToList()
     });
 }
Esempio n. 3
0
        private CourseDisplay AddCourseToTerm(EnrollmentOption o, TermDisplay currentTerm)
        {
            CourseDisplay currentCourse = new CourseDisplay
            {
                CourseIsOffered   = o.CourseIsOffered,
                CourseIsCompleted = o.courseIsCompleted,
                CourseId          = o.CourseId,
                CourseCode        = o.CourseCode,
                CourseTitle       = o.CourseTitle,
                CourseCredits     = o.CourseCredits,
                IsAcademic        = o.IsAcademic,
                Prereqs           = o.Prereqs.Select(p => new PrereqDisplay {
                    CourseCode = $"{p.courseSubject}{p.courseNum}"
                }).ToList(),
                Sections = new List <SectionDisplay>()
            };

            if (o.IsMandatory)
            {
                currentTerm.Courses.Add(currentCourse);
            }
            else
            {
                bool electiveAdded = false;
                foreach (ElectiveDisplay e in currentTerm.Electives)
                {
                    if (e.IsTechnicalElective == o.IsTechnicalElective)
                    {
                        e.Courses.Add(currentCourse);
                        electiveAdded = true;
                    }
                }
                if (!electiveAdded)
                {
                    currentTerm.Electives.Add(new ElectiveDisplay
                    {
                        IsTechnicalElective = o.IsTechnicalElective,
                        Courses             = new List <CourseDisplay>()
                        {
                            currentCourse
                        }
                    });
                }
            }

            AddSectionToCourse(o, currentCourse);
            return(currentCourse);
        }
Esempio n. 4
0
    private void LoadCoursesIntoList()
    {
        Course[] _courses = courseManager.courseList.ToArray();

        //Loop through all courses in the list
        for (int i = 0; i < _courses.Length; i++)
        {
            // Instantiate a courseDisplayPrefab and parent it to the list object
            RectTransform _cd = Instantiate(courseDisplayPrefab) as RectTransform;
            _cd.name = courseDisplayPrefab.name;
            // The CourseDisplay makes it easy to setup the course becuase it takes care of
            // local references to UI components
            CourseDisplay _cdComponent = _cd.GetComponent <CourseDisplay>();
            if (_cdComponent == null)
            {
                Debug.LogError("No CourseDisplay on the courseDisplayPrefab");
                break;
            }
            _cdComponent.Load(_courses[i]);
            _cd.transform.SetParent(courseListObject);
        }
    }
 /// <summary>
 /// Gets a list of courses
 /// </summary>
 /// <returns>
 /// List of course details in JSON or XML format
 /// </returns>
 public List <CourseDisplay> Get()
 {
     return(CourseDisplay.Search(""));
 }
Esempio n. 6
0
 private void logic(object sender, EventArgs e)
 {
     HandleMovement();
     CourseDisplay.InvalidateVisual();
 }