예제 #1
0
        public void LoadCourseTest()
        {
            Course course = new Course();

            XDocument doc = XDocument.Load(fileName);

            if (doc.Root != null)
            {
                course.CourseName = doc.Root.Attributes("name").First().Value;
                var levels = doc.Descendants("level");
                foreach (var level in levels)
                {
                    Level mlevel = new Level();
                    mlevel.LevelName = level.Attributes("level").First().Value;

                    course.Levels.Add(mlevel);

                    var modules = level.Descendants("module");
                    foreach (var module in modules)
                    {
                        Module mmodule = new Module();
                        mmodule.Code    = module.Attributes("code").First().Value;
                        mmodule.Name    = module.Attributes("name").First().Value;
                        mmodule.Credits = int.Parse(module.Attributes("credit").First().Value);

                        mlevel.Modules.Add(mmodule);

                        var assignments = module.Descendants("assessment");
                        foreach (var assignment in assignments)
                        {
                            Assessment ass = new Assessment();
                            ass.Name   = assignment.Attributes("name").First().Value;
                            ass.Mark   = decimal.Parse(assignment.Attributes("mark").First().Value);
                            ass.Weight = decimal.Parse(assignment.Attributes("weight").First().Value);

                            mmodule.Assessments.Add(ass);
                        }
                    }
                }
            }
        }
 public AssessmentUC(Assessment assessment)
 {
     InitializeComponent();
     this.Assessment = assessment;
 }