Ejemplo n.º 1
0
        // Transform the study plan (a list of enrolled units) into a list of semesters, each with their own list of enrolled units
        private IEnumerable <SemesterPlan> projectPlan()
        {
            List <SemesterPlan> semesters = new List <SemesterPlan>();

            var thisYear = System.DateTime.Now.Year;

            for (int year = thisYear + 5; year >= thisYear - 4; year--)
            {
                foreach (var offering in new Offering[] { Offering.Semester2, Offering.Semester1 })
                {
                    Semester semester = new Semester(year, offering);
                    semesters.Add(new SemesterPlan
                    {
                        label      = StudyPlannerModel.display(semester),
                        semester   = semester,
                        enrollable = inFlightUnitCode != null && StudyPlannerModel.isEnrollableIn(inFlightUnitCode, semester, plan.Items),
                        units      = plan.Items
                                     .Where(unit => unit.semester.Equals(semester))
                                     .Select(unit => new UnitInSemester
                        {
                            unit         = unit,
                            offering     = StudyPlannerModel.displayOffered(unit.code),
                            group        = getGroup(unit.code, unit.studyArea),
                            statusColour = StudyPlannerModel.isLegalIn(unit.code, semester, plan.Items) ? StudyAreaColour(unit.studyArea) : "Red"
                        })
                    });
                }
            }
            return(semesters);
        }
Ejemplo n.º 2
0
        // Load a new course by parsing Study Area information from a CSV resourse file
        private IEnumerable <StudyArea> LoadCourse(string CVSFile)
        {
            var studyAreas = new List <StudyArea>();

            using (var file = new System.IO.StringReader(CVSFile))
            {
                while (true)
                {
                    var studyArea = new StudyArea();
                    studyArea.code = file.ReadLine();
                    if (studyArea.code == "" || studyArea.code == null)
                    {
                        break;
                    }
                    studyArea.title  = file.ReadLine();
                    studyArea.colour = file.ReadLine();
                    var units = new List <UnitInStudyArea>();
                    studyArea.units = units;
                    studyAreas.Add(studyArea);
                    while (true)
                    {
                        var line = file.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        var csv = line.Split(',');
                        if (csv.Length < 3)
                        {
                            break;
                        }
                        else
                        {
                            units.Add(new UnitInStudyArea {
                                code = csv[0], studyArea = studyArea.code, XPos = ScaleX(double.Parse(csv[1])), YPos = ScaleY(double.Parse(csv[2])), offering = StudyPlannerModel.displayOffered(csv[0]), group = csv[3]
                            });
                        }
                    }
                }
            }
            return(studyAreas);
        }