Example #1
0
        public void LoadData()
        {
            Debug.WriteLine("Reading list of degrees");
             try
             {
            StreamReader deparmentsReader = new StreamReader(degreeList);

            string degree;
            while ((degree = deparmentsReader.ReadLine()) != null)
            {
               String filename = String.Format("Curricula/{0}.json", degree);

               if (File.Exists(filename))
               {
                  Debug.WriteLine(filename);

                  String fileContents = System.IO.File.ReadAllText(filename);
                  JArray json = JArray.Parse(fileContents);

                  foreach (JToken jsonItem in json)
                  {
                     if (jsonItem["type"].ToString().Equals("filter"))
                     {
                        IFilter<Course> filter = ParseCourseFilter(jsonItem["filter"]);
                        if (!orphanedFilters.ContainsKey(jsonItem.Value<String>("id")))
                        {
                           orphanedFilters.Add(jsonItem.Value<String>("id"), filter);
                        }
                     }
                     else
                     {
                        // likely only 1 per file
                        String name = jsonItem["name"].ToString();
                        DegreeProgram program = new DegreeProgram(name);
                        Degrees.Add(program);

                        JToken reqs = jsonItem["requirements"];

                        foreach (JToken jsonDegreeCategory in reqs)
                        {
                           DegreeRequirementCategory cat = new DegreeRequirementCategory(jsonDegreeCategory["name"].ToString());
                           JToken filters = jsonDegreeCategory["filters"];

                           foreach (JToken jsonCourseFilter in filters)
                           {
                              IFilter<Course> courseFilter = ParseCourseFilter(jsonCourseFilter);
                              if (courseFilter != null)
                              {
                                 DegreeRequirement degreeReq = new DegreeRequirement();
                                 degreeReq.Category = cat;
                                 degreeReq.CourseRequirement = courseFilter;
                                 if (jsonCourseFilter["id"] != null)
                                 {
                                    degreeReq.Name = jsonCourseFilter.Value<String>("id");
                                 }
                                 program.Requirements.Add(degreeReq);
                              }
                           }
                        }
                     }
                  }
               }
            }
             }
             catch (Exception e)
             {
            Debug.WriteLine("Count not read degrees.txt");
            Debug.WriteLine(e.Message);
             }
        }
Example #2
0
 public Student(DegreeProgram degree)
 {
     Schedule = new Schedule(this);
      Degree = degree;
 }