Beispiel #1
0
        //------------------------------------------------------------------//
        // Authors: Cody Jordan, Cian Carota                                //
        // Date: 4/5/14                                                     //
        //------------------------------------------------------------------//
        /// <summary>Adding a new record to Student XML. </summary>
        /// <param name="student">Student object to be modified.</param>
        /// <param name="RecordToAdd">Record to be added.</param>
        /// <returns>Boolean confirmation.</returns>
        public bool AddNewRecord(Student student, Record RecordToAdd)
        {
            XDocument data = XDocument.Load(student.RecordsPath);

            XElement newRecord = CreateRecordNode(RecordToAdd);

            newRecord.SetAttributeValue("ID", GetNextAvailableID(student.RecordsPath, "record"));
            RecordToAdd.ID = Convert.ToInt32(newRecord.Attribute("ID").Value);

            data.Element("Records").Add(newRecord);
            student.curRecordList.Add(RecordToAdd);
            data.Save(student.RecordsPath);
            return true;
        }
Beispiel #2
0
 //------------------------------------------------------------------//
 // Authors: Cody Jordan, Cian Carota                                //
 // Date: 4/5/14                                                     //
 //------------------------------------------------------------------//
 /// <summary>Creating Record XML for addition of first record.
 /// </summary>
 /// <param name="RecordToAdd">Record object to added.</param>
 /// <param name="student">Student object related to record.</param>
 /// <returns>Boolean confirmation.</returns>
 public bool InitialCreateRecordXML(Student student, Record RecordToAdd)
 {
     return XMLStudentDriver.InitialCreateRecordXML(student, RecordToAdd);
 }
Beispiel #3
0
 //------------------------------------------------------------------//
 // Authors: Cody Jordan, Cian Carota                                //
 // Date: 4/5/14                                                     //
 //------------------------------------------------------------------//
 /// <summary>Add a record to student data.</summary>
 /// <param name="student">Student object to be modified.</param>
 /// <param name="RecordToAdd">Record object to be added.</param>
 public void AddRecordToStudent(Student student, Record RecordToAdd)
 {
     XMLStudentDriver.AddRecordToStudent(student, RecordToAdd);
 }
Beispiel #4
0
 //------------------------------------------------------------------//
 // Authors: Cody Jordan, Cian Carota                                //
 // Date: 4/5/14                                                     //
 //------------------------------------------------------------------//
 /// <summary>Adding a new record to Student XML. </summary>
 /// <param name="student">Student object to be modified.</param>
 /// <param name="RecordToAdd">Record to be added.</param>
 /// <returns>Boolean confirmation.</returns>
 public bool AddNewRecord(Student student, Record RecordToAdd)
 {
     return XMLStudentDriver.AddNewRecord(student, RecordToAdd);
 }
Beispiel #5
0
        private void LoadStudentRecord(Student aStudent)
        {
            if (System.IO.File.Exists(aStudent.RecordsPath))
            {
                XDocument studentRecordsXML = XDocument.Load(aStudent.RecordsPath);
                IEnumerable<XElement> RecordsNodesQuery = SecondLevelOfRoot(studentRecordsXML.Root);

                foreach (XElement record in RecordsNodesQuery)
                {
                    Record newRecord = new Record();
                    newRecord.ID = Convert.ToInt32(record.Attribute("ID").Value);
                    newRecord.DrillID = Convert.ToInt32(record.Element("drillID").Value);
                    newRecord.DrillName = record.Element("drillName").Value;
                    newRecord.DateTaken = record.Element("dataTaken").Value;
                    newRecord.Question = record.Element("questions").Value;
                    newRecord.RangeStart = record.Element("rangeStart").Value;
                    newRecord.RangeEnd = record.Element("rangeEnd").Value;
                    newRecord.Operation = record.Element("operand").Value;
                    newRecord.Wrong = record.Element("wrong").Value;
                    newRecord.Skipped = record.Element("skipped").Value;
                    newRecord.Percent = record.Element("percent").Value;
                    aStudent.curRecordList.Add(newRecord);
                }
            }
        }
Beispiel #6
0
 //------------------------------------------------------------------//
 // Authors: Cody Jordan, Cian Carota                                //
 // Date: 4/5/14                                                     //
 //------------------------------------------------------------------//
 /// <summary>Add a record node to Record XML.</summary>
 /// <param name="RecordToAdd">Record object to be added.</param>
 /// <returns>XElement</returns>
 private XElement CreateRecordNode(Record RecordToAdd)
 {
     XElement newRecord =
         new XElement("record",
             new XElement("drillID", RecordToAdd.DrillID),
             new XElement("drillName", RecordToAdd.DrillName),
             new XElement("dataTaken", RecordToAdd.DateTaken),
             new XElement("questions", RecordToAdd.Question),
             new XElement("rangeStart", RecordToAdd.RangeStart),
             new XElement("rangeEnd", RecordToAdd.RangeEnd),
             new XElement("operand", RecordToAdd.Operation),
             new XElement("wrong", RecordToAdd.Wrong),
             new XElement("skipped", RecordToAdd.Skipped),
             new XElement("percent", RecordToAdd.Percent));
     return newRecord;
 }
Beispiel #7
0
 //------------------------------------------------------------------//
 // Authors: Cody Jordan, Cian Carota                                //
 // Date: 4/5/14                                                     //
 //------------------------------------------------------------------//
 /// <summary>Add data from active session to XML.</summary>
 /// <param name="currentStudent">Student object to be modified.</param>
 /// <param name="currentDrill">Drill object to be modified.</param>
 public void WriteCurrentSession(Student currentStudent, Drill currentDrill)
 {
     Record RecordToAdd = new Record(currentDrill.ID, currentDrill.DrillName, DateTime.Now.ToString("M/d/yyyy"), currentDrill.Questions, currentDrill.RangeStart,
         currentDrill.RangeEnd, currentDrill.Operand, currentDrill.Wrong, currentDrill.Percent, currentDrill.Skipped);
     AddRecordToStudent(currentStudent, RecordToAdd);
 }
Beispiel #8
0
        //------------------------------------------------------------------//
        // Authors: Cody Jordan, Cian Carota                                //
        // Date: 4/5/14                                                     //
        //------------------------------------------------------------------//
        /// <summary>Creating Record XML for addition of first record.
        /// </summary>
        /// <param name="RecordToAdd">Record object to added.</param>
        /// <param name="student">Student object related to record.</param>
        /// <returns>Boolean confirmation.</returns>
        public bool InitialCreateRecordXML(Student student, Record RecordToAdd)
        {
            XElement newRecord = CreateRecordNode(RecordToAdd);

            newRecord.SetAttributeValue("ID", "1");
            RecordToAdd.ID = Convert.ToInt32(newRecord.Attribute("ID").Value);
            student.curRecordList.Add(RecordToAdd);

            XDocument newRecordDoc =
                new XDocument(
                    new XElement("Records", newRecord));
            newRecordDoc.Save(student.RecordsPath);
            return true;
        }
Beispiel #9
0
 //------------------------------------------------------------------//
 // Authors: Cody Jordan, Cian Carota                                //
 // Date: 4/5/14                                                     //
 //------------------------------------------------------------------//
 /// <summary>Add a record to a student in Student XML.</summary>
 /// <param name="student">Student object to be modified.</param>
 /// <param name="RecordToAdd">Record object to be added.</param>
 public void AddRecordToStudent(Student student, Record RecordToAdd)
 {
     if (!System.IO.File.Exists(student.RecordsPath))
     {
         InitialCreateRecordXML(student, RecordToAdd);
     }
     else
     {
         AddNewRecord(student, RecordToAdd);
     }
 }