private void iterateListOfCourses(GenericCourse co)
        {
            var crsOp = co as CourseOption;

            co.GetFootnotes(this.Footnotes);
            foreach (GenericCourse crs in crsOp.Courses)
            {
                getAllFootnotes(crs);
            }
        }
 private void getAllFootnotes(GenericCourse root)
 {
     if (root is CourseOption)
     {
         iterateListOfCourses(root);
     }
     else
     {
         root.GetFootnotes(this.Footnotes);
     }
 }
예제 #3
0
        public static GenericCourse GetCourse(List <HtmlNode> nodes, ref int i)
        {
            HtmlNode n = nodes[i];
            HtmlNode code = null, title = null, critical = null, recommended = null, aucc = null, hours = null;

            foreach (HtmlNode data in n.ChildNodes)
            {
                if (data.HasClass("codecol "))
                {
                    code = data;
                }
                else if (data.HasClass("titlecol "))
                {
                    title = data;
                }
                else if (data.HasClass("criticalcol"))
                {
                    critical = data;
                }
                else if (data.HasClass("recommendedcol"))
                {
                    recommended = data;
                }
                else if (data.HasClass("aucccol"))
                {
                    aucc = data;
                }
                else if (data.HasClass("hourscol"))
                {
                    hours = data;
                }
            }

            bool hasCodecol = code != null;
            bool hasLink    = hasCodecol && code.InnerHtml.Contains("class=\"bubblelink code\"");

            bool hasTitlecol = title != null;

            bool hasWideFirstCol = n.InnerHtml.Contains("<td colspan=\"2\"");

            bool hasCriticalCol = critical != null;

            bool hasRecommendedCol = recommended != null;

            bool hasAucccol = aucc != null;

            bool hasHourscol  = hours != null;
            bool hasHourstext = hours != null && hours.InnerText.Length > 0;

            string firsttxt    = n.FirstChild.InnerText.ToLower();
            bool   hasElective = firsttxt.Contains("elective") || firsttxt.Contains("additional");
            //Check if the word select is in the row, but it isnt in the past tense (meaning it isnt a "Select x credits from the following" sort of row)
            bool hasSelect = firsttxt.Contains("select") && (firsttxt.IndexOf("select") != firsttxt.IndexOf("selected"));
            bool hasGroup  = firsttxt.Contains("group");
            bool hasInfo   = firsttxt.Contains("recommended") || firsttxt.Contains("benchmark") || firsttxt.Contains("must be");

            GenericCourse course = null;

            if (hasWideFirstCol)
            {
                if (hasSelect)
                {
                    //[Select one course from the following] || [Select one group from the following]
                    //Course groups always have the word select in the row above them, and this method finds groups if they are present.
                    course = getCourseOptions(nodes, n, ref i);
                }
                else if (hasElective)
                {
                    //[Elective(s)] || [Technical Electives List x]
                    course = getElectiveCourse(n);
                }
                else if (hasInfo)
                {
                    //Information about when courses must be completed
                    course = getProgramInfo(n);
                }
                else
                {
                    //[Arts and Humanites] (AUCC courses
                    course = getAUCCCourse(n);
                }
            }
            else
            {
                //Normal courses
                course = getCourse(n);
            }
            return(course);
        }
예제 #4
0
        private static GenericCourse getCourse(HtmlNode n, string creditsCO = "")
        {
            string[] desc_footnotes = getDescAndFootnotes(n);
            string   crsCode = desc_footnotes[0], footnotes = desc_footnotes[1];

            //If this course text looks like an elective then parse it as one
            if (crsCode.ToLower().Contains("elective") || crsCode.ToLower().Contains("additional"))
            {
                return(getElectiveCourse(n, creditsCO));
            }
            //If this "course" is information, parse it as such
            if (crsCode.ToLower().Contains("must be completed") || crsCode.ToLower().Contains("benchmark") || crsCode.ToLower().Contains("recommended"))
            {
                return(getProgramInfo(n));
            }
            //If this course does not contain numbers (and was not caught by anything else), it is an AUCC course.
            if (!Regex.IsMatch(crsCode, @"\d"))
            {
                return(getAUCCCourse(n));
            }
            //string desc = n.ChildNodes[1].InnerText.Trim();

            bool[] critrec = getCritRec(n);

            string aucc    = getAucc(n);
            string credits = (!creditsCO.Equals(string.Empty)) ? creditsCO : n.LastChild.InnerText.Trim();

            GenericCourse course = null;
            string        dept, num;

            if (crsCode.Contains("&amp; "))
            {
                string[] courses = crsCode.Split(new[] { "&amp; " }, StringSplitOptions.None);

                dept   = courses[0].Split()[0]; num = courses[0].Split()[1];
                course = new Course(dept, num, "", critrec[0], critrec[1], aucc, credits);
                dept   = courses[1].Split()[0]; num = courses[1].Split()[1];

                course.AND = dept + " " + num;
            }
            else if (crsCode.Contains(" or "))
            {
                //[CS 163 or 164] for SEMESTER 2
                //http://catalog.colostate.edu/general-catalog/colleges/natural-sciences/physics/physics-major-applied-concentration/#majorcompletionmaptext
                //Want to parse as [CS 163 desc], [CS 164 desc]
                string[] crs = crsCode.Split(new[] { " or " }, StringSplitOptions.None);
                dept = crs[0].Split()[0].Trim();
                num  = crs[0].Split()[1].Trim();
                string num2 = crs[1].Trim();


                //desc = n.ChildNodes[1].FirstChild.InnerText.Trim();
                //string desc2 = n.ChildNodes[1].LastChild.InnerText.Trim();
                course    = new Course(dept, num, "", critrec[0], critrec[1], aucc, credits);
                course.OR = dept + "" + num2;
            }
            else if (crsCode.Contains("/"))
            {
                string[] courses = crsCode.Split('/');
                dept       = courses[0].Split()[0];
                num        = courses[0].Split()[1];
                course     = new Course(dept, num, "", critrec[0], critrec[1], aucc, credits);
                course.AKA = courses[1];
            }
            else
            {
                dept   = crsCode.Split()[0]; num = crsCode.Split()[1];
                course = new Course(dept, num, "", critrec[0], critrec[1], aucc, credits);
            }
            if (course.Department == "BMS" && course.Number == "495")
            {
                Debugger.Break();
            }
            course.Footnotes = footnotes;
            return(course);
        }
예제 #5
0
 public void AddCourse(GenericCourse course)
 {
     this.Courses.Add(course);
 }
예제 #6
0
 public void Add(GenericCourse course)
 {
     course.SelectFrom = true;
     course.Note      += "<" + Note + ">";
     Courses.Add(course);
 }
        private void loadFromCourseList(List <HtmlNode> found)
        {
            this.SetupRequirements();

            CourseList    cl  = null;
            HtmlNode      n   = null;
            GenericCourse crs = null;

            //if (ProgramTitle == "Minor in Agricultural Business") Debugger.Break();
            for (int i = 0; i < found.Count; i++)
            {
                n = found[i];

                if (n.HasClass("hidden") || n.ParentNode.Name == "thead")
                {
                    continue;
                }

                if (n.HasClass("orclass"))
                {
                    string orCrs = n.FirstChild.InnerText;
                    if (orCrs.Contains("or"))
                    {
                        int orIndex = orCrs.IndexOf("or") + 2;
                        orCrs = orCrs.Substring(orIndex, orCrs.Length - orIndex).Trim();
                    }
                    cl.Courses[cl.Courses.Count - 1].OR = orCrs;
                    continue;
                }

                if (n.HasClass("firstrow"))
                {
                    cl = new CourseList();
                }
                else if (n.HasClass("listsum"))
                {
                    if (cl != null)
                    {
                        CourseLists.Add(cl);
                    }

                    if (Credits == null /*|| int.Parse(Credits) < int.Parse(n.LastChild.InnerText)*/)
                    {
                        this.Credits = n.LastChild.InnerText;
                    }

                    continue;
                }

                if (n.HasClass("areaheader"))
                {
                    string[] desc_footnums = Course.getDescAndFootnotes(n);
                    crs           = new ProgramInfo(desc_footnums[0], false, false);
                    crs.Footnotes = desc_footnums[1];
                }
                else
                {
                    crs = Course.GetCourse(found, ref i);
                }


                //TODO: Write a function for getting all footnotes at once.
                if (crs != null)
                {
                    cl.AddCourse(crs);
                }
            }

            if (printStatus)
            {
                Console.WriteLine(CourseLists.Count + " Requirements<Course Lists> found");
            }
        }
        private void loadFromPlanGrid(List <HtmlNode> found)
        {
            this.SetupRequirements();

            YearRequirements yr = null;

            HtmlNode n = null;

            for (int i = 0; i < found.Count; i++)
            {
                n = found[i];
                if (n.HasClass("hidden") || n.ParentNode.Name == "thead")
                {
                    continue;
                }

                //If this is the level row (FRESHMAN | SOPHOMORE | JUNIOR | SENIOR)
                if (n.HasClass("plangridyear"))
                {
                    //Add the year, which by this point has been filled out with each course, to the completion map
                    if (yr != null)
                    {
                        Requirements.Add(yr);
                    }
                    //Start the next year with the level found in this row
                    yr = new YearRequirements(n.InnerText.Trim());
                }
                //Requirements have these, but they are not labeled, so skip the row.
                else if (n.HasClass("plangridterm"))
                {
                    continue;
                }
                //If this is the credit sum (of the semester) row
                else if (n.HasClass("plangridsum"))
                {
                    //Add the total credits to the semester
                    yr.Credits = n.LastChild.InnerText.Trim();
                }
                //If this is the credit total row OR is marked as the last row
                else if (n.HasClass("plangridtotal") && n.HasClass("lastrow"))
                {
                    //Add the final year to the degree map.
                    if (yr != null)
                    {
                        Requirements.Add(yr);
                    }
                    break;
                }
                //Otherwise this is a course row of some sort.
                else
                {
                    GenericCourse crs = Course.GetCourse(found, ref i);
                    yr.AddCourse(crs);
                }
            }

            if (printStatus)
            {
                Console.WriteLine(Requirements.Count + " Years found");
            }
        }