Esempio n. 1
0
        public void testAddSkill()
        {
            Student st = new Student();
            Period  pd = new Period();
            Skill   sk = new Skill();

            st.StudentID  = "12";
            st.FirstName  = "taks";
            pd.PeriodID   = 1;
            pd.PeriodName = "sampleterm";
            sk.SkillID    = "D1";
            sk.SkillName  = "sampleskill";
            contoller.addOrUpdateStudent(st);
            contoller.addOrUpdatePeriod(st, pd);
            contoller.addOrUpdateSkill(st, sk, pd);
            int asd = contoller.getPeriod(st, 1).Skills.Count;

            Assert.AreEqual(contoller.getPeriod(st, 1).Skills.Count, asd);
            Assert.AreEqual(contoller.getPeriod(st, 1).Skills.Find(delegate(Skill sk2) { return(sk2.SkillID.Equals(sk.SkillID)); }), sk);
        }
Esempio n. 2
0
        private static void addSkillsFromXML(IStudentController controller, String doc)
        {
            #region codes
            //XmlNodeList primelist = doc.SelectNodes("easygradepro/class");

            //foreach (XmlNode primenode in primelist)
            //{
            //    XmlNodeList periodList = primenode.SelectNodes("classrecord");
            //    XmlNodeList studentinfo = primenode.SelectNodes("student");
            //    XmlNodeList gradename = primenode.SelectNodes("standards/standard");
            //    Dictionary<String, String> skillNames = new Dictionary<string, string>();
            //    foreach (XmlNode test in gradename)
            //    {
            //        Skill skill = new Skill();
            //        skill.SkillID = test.ChildNodes[0].InnerText;
            //        skill.SkillName = test.ChildNodes[3].InnerText;
            //        skillNames.Add(skill.SkillID, skill.SkillName);
            //    }

            //            foreach (XmlNode student in studentinfo)
            //            {
            //                //String adviser;
            //                Student idgeter = new Student();
            //                idgeter.StudentID = student.ChildNodes[0].ChildNodes[0].InnerText;
            //                idgeter.LastName = student.ChildNodes[0].ChildNodes[3].InnerText;
            //                idgeter.FirstName = student.ChildNodes[0].ChildNodes[4].InnerText;
            //                XmlNodeList gradeinfo = student.SelectNodes("stud_grades/stud_stdgrades");

            //                foreach (XmlNode test in periodList)
            //                {
            //                    Period period = new Period();
            //                    period.PeriodID = Int32.Parse(test.ChildNodes[1].InnerText);
            //                    period.PeriodName = test.ChildNodes[2].InnerText;
            //                    //adviser = test.ChildNodes[8].InnerText;
            //                    controller.addOrUpdatePeriod(controller.getStudent(idgeter.StudentID), period);
            //                foreach (XmlNode grade in gradeinfo)
            //                {
            //                    if (grade.HasChildNodes == true)
            //                    {
            //                        XmlNodeList stdgradeinfo = grade.SelectNodes("stud_stdgrade");

            //                        foreach (XmlNode stdgrade in stdgradeinfo)
            //                        {

            //                            Skill skilltostore = new Skill();
            //                            skilltostore.SkillID = stdgrade.ChildNodes[0].InnerText;
            //                            skilltostore.SkillName = skillNames[skilltostore.SkillID];
            //                            if (stdgrade.ChildNodes[1].InnerText == "" || stdgrade.ChildNodes[2].InnerText == "")
            //                            {
            //                                skilltostore.NumericGrade = 0.0;
            //                                skilltostore.LetterGrade = "N/A";
            //                            }
            //                            else
            //                            {
            //                                skilltostore.NumericGrade = double.Parse(stdgrade.ChildNodes[1].InnerText);
            //                                skilltostore.LetterGrade = stdgrade.ChildNodes[2].InnerText;
            //                            }
            //                            //idgeter.Adviser = adviser;
            //                            controller.addOrUpdateSkill(controller.getStudent(idgeter.StudentID), skilltostore, controller.getPeriod(controller.getStudent(idgeter.StudentID), period.PeriodID));

            //                        }

            //                    }
            //                    else
            //                    {
            //                        break;
            //                    }

            //                }
            //        }
            //    }
            //}
            #endregion
            try
            {
                myReader = new StreamReader(doc);
            }
            catch (Exception er)
            {
                System.Windows.Forms.MessageBox.Show(er.Message, "Unable to run the File");
            }
            String loadedString = null;
            Student stud = new Student();

            while ((loadedString = myReader.ReadLine()) != null)
            {
                String[] studentDetails = loadedString.Split('\t');
                stud.StudentID = studentDetails[0];

                Period period = new Period();
                period.PeriodID = Convert.ToInt32(studentDetails[3].Substring(5,1));
                controller.addOrUpdatePeriod(controller.getStudent(stud.StudentID), period);

                int term1Counter = 8;
                while (term1Counter <= 68)
                {
                    Skill Skill = new Skill();
                    Skill.SkillID = studentDetails[term1Counter];
                    if (Skill.SkillID != "A" || Skill.SkillID != "B" || Skill.SkillID != "C" || Skill.SkillID != "D" || Skill.SkillID != "E")
                    {
                        if (studentDetails[term1Counter + 1] != "")
                        {
                            String[] skillGrades = studentDetails[term1Counter + 1].Split('/');
                            Skill.NumericGrade = Convert.ToDouble(skillGrades[0]);
                            Skill.LetterGrade = skillGrades[1];
                        }
                        else
                        {
                            //Grade.SubjectID = studentDetails[4].Substring(0, 4);
                            Skill.LetterGrade = "N/A";
                            Skill.NumericGrade = 0;
                        }
                    }
                    term1Counter += 2;
                    controller.addOrUpdateSkill(controller.getStudent(stud.StudentID), Skill, controller.getPeriod(controller.getStudent(stud.StudentID), period.PeriodID));
                }
            }
        }
Esempio n. 3
0
        private static void addSkillsFromXML(IStudentController controller, String doc)
        {
            #region codes
            //XmlNodeList primelist = doc.SelectNodes("easygradepro/class");

            //foreach (XmlNode primenode in primelist)
            //{
            //    XmlNodeList periodList = primenode.SelectNodes("classrecord");
            //    XmlNodeList studentinfo = primenode.SelectNodes("student");
            //    XmlNodeList gradename = primenode.SelectNodes("standards/standard");
            //    Dictionary<String, String> skillNames = new Dictionary<string, string>();
            //    foreach (XmlNode test in gradename)
            //    {
            //        Skill skill = new Skill();
            //        skill.SkillID = test.ChildNodes[0].InnerText;
            //        skill.SkillName = test.ChildNodes[3].InnerText;
            //        skillNames.Add(skill.SkillID, skill.SkillName);
            //    }


            //            foreach (XmlNode student in studentinfo)
            //            {
            //                //String adviser;
            //                Student idgeter = new Student();
            //                idgeter.StudentID = student.ChildNodes[0].ChildNodes[0].InnerText;
            //                idgeter.LastName = student.ChildNodes[0].ChildNodes[3].InnerText;
            //                idgeter.FirstName = student.ChildNodes[0].ChildNodes[4].InnerText;
            //                XmlNodeList gradeinfo = student.SelectNodes("stud_grades/stud_stdgrades");

            //                foreach (XmlNode test in periodList)
            //                {
            //                    Period period = new Period();
            //                    period.PeriodID = Int32.Parse(test.ChildNodes[1].InnerText);
            //                    period.PeriodName = test.ChildNodes[2].InnerText;
            //                    //adviser = test.ChildNodes[8].InnerText;
            //                    controller.addOrUpdatePeriod(controller.getStudent(idgeter.StudentID), period);
            //                foreach (XmlNode grade in gradeinfo)
            //                {
            //                    if (grade.HasChildNodes == true)
            //                    {
            //                        XmlNodeList stdgradeinfo = grade.SelectNodes("stud_stdgrade");

            //                        foreach (XmlNode stdgrade in stdgradeinfo)
            //                        {

            //                            Skill skilltostore = new Skill();
            //                            skilltostore.SkillID = stdgrade.ChildNodes[0].InnerText;
            //                            skilltostore.SkillName = skillNames[skilltostore.SkillID];
            //                            if (stdgrade.ChildNodes[1].InnerText == "" || stdgrade.ChildNodes[2].InnerText == "")
            //                            {
            //                                skilltostore.NumericGrade = 0.0;
            //                                skilltostore.LetterGrade = "N/A";
            //                            }
            //                            else
            //                            {
            //                                skilltostore.NumericGrade = double.Parse(stdgrade.ChildNodes[1].InnerText);
            //                                skilltostore.LetterGrade = stdgrade.ChildNodes[2].InnerText;
            //                            }
            //                            //idgeter.Adviser = adviser;
            //                            controller.addOrUpdateSkill(controller.getStudent(idgeter.StudentID), skilltostore, controller.getPeriod(controller.getStudent(idgeter.StudentID), period.PeriodID));

            //                        }

            //                    }
            //                    else
            //                    {
            //                        break;
            //                    }

            //                }
            //        }
            //    }
            //}
            #endregion
            try
            {
                myReader = new StreamReader(doc);
            }
            catch (Exception er)
            {
                System.Windows.Forms.MessageBox.Show(er.Message, "Unable to run the File");
            }
            String  loadedString = null;
            Student stud         = new Student();

            while ((loadedString = myReader.ReadLine()) != null)
            {
                String[] studentDetails = loadedString.Split('\t');
                stud.StudentID = studentDetails[0];


                Period period = new Period();
                period.PeriodID = Convert.ToInt32(studentDetails[3].Substring(5, 1));
                controller.addOrUpdatePeriod(controller.getStudent(stud.StudentID), period);

                int term1Counter = 8;
                while (term1Counter <= 68)
                {
                    Skill Skill = new Skill();
                    Skill.SkillID = studentDetails[term1Counter];
                    if (Skill.SkillID != "A" || Skill.SkillID != "B" || Skill.SkillID != "C" || Skill.SkillID != "D" || Skill.SkillID != "E")
                    {
                        if (studentDetails[term1Counter + 1] != "")
                        {
                            String[] skillGrades = studentDetails[term1Counter + 1].Split('/');
                            Skill.NumericGrade = Convert.ToDouble(skillGrades[0]);
                            Skill.LetterGrade  = skillGrades[1];
                        }
                        else
                        {
                            //Grade.SubjectID = studentDetails[4].Substring(0, 4);
                            Skill.LetterGrade  = "N/A";
                            Skill.NumericGrade = 0;
                        }
                    }
                    term1Counter += 2;
                    controller.addOrUpdateSkill(controller.getStudent(stud.StudentID), Skill, controller.getPeriod(controller.getStudent(stud.StudentID), period.PeriodID));
                }
            }
        }