Ejemplo n.º 1
0
        public static CourseOption getOrCourses(List <HtmlNode> found, ref int i, string credits)
        {
            CourseOption selectOr = new CourseOption("Select one course from the following:", credits);
            HtmlNode     n        = found[i];

            selectOr.Add(getCourse(n, credits));
            while ((n = found[++i]).HasClass("orclass"))
            {
                string orCrs   = n.FirstChild.InnerText;
                int    orIndex = orCrs.IndexOf("or") + 2;
                orCrs = orCrs.Substring(orIndex, orCrs.Length - orIndex).Trim();
                string[] crsParts = orCrs.Split();
                selectOr.Add(crsParts[0], crsParts[1], "", false, false, "");
            }
            --i;
            return(selectOr);
        }
Ejemplo n.º 2
0
        private static CourseOption getCourseOptions(List <HtmlNode> found, HtmlNode n, ref int i)
        {
            string[] desc_footnotes = getDescAndFootnotes(n);
            string   credits        = n.LastChild.InnerText.Trim();

            CourseOption co = new CourseOption(desc_footnotes[0], credits);

            co.Footnotes = desc_footnotes[1];

            //while the next row is one of the course options (first child has div, last child lacks hourscol class)
            while (!(n = found[++i]).LastChild.HasClass("hourscol") || n.LastChild.InnerText.Trim().Length == 0 || n.FirstChild.InnerText.Contains("Group"))
            {
                if (n.InnerText.Length == 0 && n.FirstChild.FirstChild == null &&
                    found[i + 1].FirstChild.FirstChild != null && found[i + 1].FirstChild.FirstChild.Name == "div")
                {
                    //This was an empty row in the data table, so move to the next one.
                    continue;
                }

                //If the next row has the orclass, turn this section into a select from
                if (found[i + 1].FirstChild.HasClass("orclass"))
                {
                    co.Add(getOrCourses(found, ref i, credits));
                }
                //If the word group is found in this row, at the heading of this set, or the only text in this row is in the first column...
                //A course group was found.
                else if (n.FirstChild.InnerText.ToLower().Contains("group") || co.Note.ToLower().Contains("group") || n.InnerText.Trim().Equals(n.FirstChild.InnerText.Trim()))
                {
                    co.Add(getCourseGroup(found, n, ref i, credits));
                }
                else
                {
                    co.Add(getCourse(n, credits));
                }
            }
            --i;
            return(co);
        }