Ejemplo n.º 1
0
 public void testAddComment()
 {
     Student stud = new Student();
     Period pp = new Period();
     Comment cs = new Comment();
     cs.CommentText = "BLAH BLAH BLAH! BLAH BLAH BLAH!";
     stud.StudentID = "123";
     pp.PeriodID = 11;
     contoller.addOrUpdateStudent(stud);
     contoller.addOrUpdatePeriod(stud, pp);
     contoller.addOrUpdateComment(stud, cs, pp);
     //Assert.AreEqual(contoller.getPeriod(stud, 11).PeriodComment.CommentText, cs.CommentText);
 }
Ejemplo n.º 2
0
 public void addOrUpdateComment(Student stud, Comment c, Period p)
 {
     Period period = new Period();
     period = stud.RptCard.Periods.Find(delegate(Period per) { return per.PeriodID.Equals(p.PeriodID); });
     if (period != null)
     {
         if (c != null)
         {
             Comment cm = period.PeriodComment.Find(delegate(Comment com) {return period.PeriodComment.Equals(c.CommentText);});
             if (cm == null)
             {
                 getPeriod(stud, period.PeriodID).PeriodComment.Add(cm);
             }
         }
     }
 }
Ejemplo n.º 3
0
        private static void addCommentsFromXML(IStudentController controller, String doc)
        {
            #region codes
            //XmlNodeList primelist = doc.SelectNodes("easygradepro/class");
            //Dictionary<string, string> subjectname = new Dictionary<string, string>();
            //foreach (XmlNode primenode in primelist)
            //{
            //    XmlNodeList peroidlist = primenode.SelectNodes("classrecord");
            //    XmlNodeList assignlst = primenode.SelectNodes("assignments/assignment");
            //    XmlNodeList studentinfo = primenode.SelectNodes("student");
            //    foreach (XmlNode test in peroidlist)
            //    {
            //        Period period = new Period();
            //        period.PeriodID = Int32.Parse(test.ChildNodes[1].InnerText);
            //        period.PeriodName = test.ChildNodes[2].InnerText;
            //        foreach (XmlNode student in studentinfo)
            //        {
            //            String studid = student.ChildNodes[0].ChildNodes[0].InnerText;
            //            XmlNodeList comment = student.SelectNodes("stud_grades/score/score_note");
            //            foreach (XmlNode commentcontainer in comment)
            //            {
            //                if (commentcontainer.InnerText != "")
            //                {
            //                    Comment cmt = new Comment();
            //                    cmt.CommentText = commentcontainer.InnerText;
            //                    controller.addOrUpdatePeriod(controller.getStudent(studid), period);
            //                    controller.getPeriod(controller.getStudent(studid), period.PeriodID).PeriodComment.Add(cmt);

            //                }

            //            }

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

                while ((loadedString = myReader.ReadLine()) != null)
                {
                    Student stud = new Student();
                    Period p = new Period();
                    Comment cmt = new Comment();
                    String[] studentDetails = loadedString.Split('\t');
                    stud.StudentID = studentDetails[0];
                    stud.FirstName = studentDetails[1];
                    stud.LastName = studentDetails[2];

                    if (studentDetails[3] != null)
                    {
                        p.PeriodID = 1;
                        p.PeriodName = "Term 1";
                        cmt.CommentText = studentDetails[3];
                        controller.addOrUpdatePeriod(controller.getStudent(stud.StudentID), p);
                        controller.getPeriod(controller.getStudent(stud.StudentID), p.PeriodID).PeriodComment.Add(cmt);
                    }
                }
                myReader.Close();
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        public void testaddCommentsFromXML()
        {
            XmlDocument doc = new XmlDocument();
            Student stud = new Student();
            Comment comm = new Comment();
            Period period = new Period();

            period.PeriodID = 1;
            period.PeriodName = "Term1";

            ////stud.StudentID = "95-0072";
            ////stud.FirstName = "Abbey Geraldine";
            ////stud.LastName = "Matibag";
            ////comm.CommentText = "Abbey tries very hard";

            stud.StudentID = "08-0204";
            stud.FirstName = "Armina";
            stud.LastName = "Bago";
            comm.CommentText = "Armina is an excellent student";

            //stud.StudentID = "04-0140";
            //stud.FirstName = "Beatrice Louee";
            //stud.LastName = "Antonio";
            //comm.CommentText = "Beatrice was fantastic this term definitely!";

            //period.PeriodComment.CommentText = comm.CommentText;

            doc.Load(@"c:\XML\XML Homeroom_template.xml");
            //EGPXMLParser.parseHomeroomXML(FrontController.getInstance().getStudentController(), doc);

            //System.Windows.Forms.MessageBox.Show(controller.getStudent(stud.StudentID).StudentID);
            //System.Windows.Forms.MessageBox.Show(this.controller.getStudent(stud.StudentID).StudentID);
            //System.Windows.Forms.MessageBox.Show(controller.getPeriod(this.controller.getStudent(stud.StudentID), period.PeriodID).PeriodComment.CommentText);
            //Assert.AreEqual(controller.getPeriod(this.controller.getStudent(stud.StudentID), period.PeriodID).PeriodComment.CommentText.Equals(comm.CommentText), true);
            //Assert.AreEqual(comm.CommentText,controller.getStudent(stud.StudentID).RptCard.Periods.Find(delegate(Period per) {return per.PeriodComment.CommentText.Equals(comm.CommentText);}).PeriodComment.CommentText);

            Assert.AreEqual(comm.CommentText, controller.getPeriod(controller.getStudent(stud.StudentID), period.PeriodID).PeriodComment.Find(delegate(Comment comment) { return comment.CommentText.Equals(comm.CommentText); }).CommentText);
        }
Ejemplo n.º 5
0
 public void testAddNullComment()
 {
     Student stud = new Student();
     Period pp = new Period();
     Comment cs = new Comment();
     cs = null;
     stud.StudentID = "123";
     string test = "argh argh argh arghar";
     pp.PeriodID = 11;
     contoller.addOrUpdateStudent(stud);
     contoller.addOrUpdatePeriod(stud, pp);
     contoller.addOrUpdateComment(stud, cs, pp);
     Assert.AreNotEqual(contoller.getPeriod(stud, 11).PeriodComment, test);
     Assert.AreEqual(contoller.getPeriod(stud, 11).PeriodComment, null);
 }