public void DeleteAssignmentAttempt(AssignmentAttempt assignmentAttempt)
        {
            string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentAttempsFilename);

            try
            {
                XDocument assignmentAttemptFile = OpenFile(fileName, MMFileType.AssignmentAttempt);

                if (assignmentAttemptFile != null)
                {
                    assignmentAttemptFile.Descendants("AssignmentAttempt").First(s => s.Element("ID").Value == assignmentAttempt.ID).Remove();
                    assignmentAttemptFile.Save(fileName);
                }
            }
            catch (FileNotFoundException ex)
            {
                System.Diagnostics.Debug.Write(ex.Message);
            }
            catch (ArgumentNullException ex)
            {
                System.Diagnostics.Debug.Write(DateTime.Now.ToString() + " UpdateAssignmentAttempt failed null referance.\n" + ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                System.Diagnostics.Debug.Write(DateTime.Now.ToString() + " UpdateAssignmentAttempt failed Invalid Operation.\n" + ex.Message);
            }
        }
        /// <summary>
        /// 9 April 2014
        /// Jonathan Sanborn
        ///
        /// Constructor for an Assignment Session
        /// </summary>
        /// <param name="mmControl">The Control Object</param>
        /// <param name="assign">The Assignment for this session</param>
        public AssignmentSession(MMControl mmControl, ref Assignment assign)
        {
            init();
            MMControl           = mmControl;
            assignment          = assign;
            problemSetGenerator = new ProblemSetGenerator(assignment.ProblemSet);
            assignmentAttempt   = new AssignmentAttempt();
            problemList         = problemSetGenerator.GetProblemList;

            attemptsRemaining = (int)Assignment.ProblemSet.NumberOfAttempts;
            currentProblem    = problemList.First();
            problemList.Remove(CurrentProblem);
        }
        //public List<AssignmentAttempt> GetAssignmentAttemptsByDateRange(DateTime startDate, DateTime endDate)
        //{
        //    var assignmentAttempts = from assignmentAttempt in GetAllAssignmentAttempts()
        //                             where assignmentAttempt.Date >= startDate
        //                                && assignmentAttempt.Date <= endDate
        //                             select assignmentAttempt;

        //    return new List<AssignmentAttempt>(assignmentAttempts);
        //}

        public void SaveNewAssignmentAttempt(AssignmentAttempt assignmentAttempt)
        {
            string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentAttempsFilename);

            try
            {
                XDocument assignmentAttemptFile = OpenFile(fileName, MMFileType.AssignmentAttempt);

                if (assignmentAttemptFile != null)
                {
                    assignmentAttemptFile.Element("AssignmentAttempts").Add(assignmentAttempt.GetXMLNode());
                    assignmentAttemptFile.Save(fileName);
                }
            }
            catch (FileNotFoundException ex)
            {
                System.Diagnostics.Debug.Write(ex.Message);
            }
        }
        /// <summary>
        /// 9 April 2014
        /// Jonathan Sanborn
        /// 
        /// Constructor for an Assignment Session
        /// </summary>
        /// <param name="mmControl">The Control Object</param>
        /// <param name="assign">The Assignment for this session</param>
        public AssignmentSession(MMControl mmControl, ref Assignment assign)
        {
            init();
            MMControl = mmControl;
            assignment = assign;
            problemSetGenerator = new ProblemSetGenerator(assignment.ProblemSet);
            assignmentAttempt = new AssignmentAttempt();
            problemList = problemSetGenerator.GetProblemList;

            attemptsRemaining = (int)Assignment.ProblemSet.NumberOfAttempts;
            currentProblem = problemList.First();
            problemList.Remove(CurrentProblem);
        }
            public void DeleteAssignmentAttempt(AssignmentAttempt assignmentAttempt)
            {
                string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentAttempsFilename);

                try
                {
                    XDocument assignmentAttemptFile = OpenFile(fileName, MMFileType.AssignmentAttempt);

                    if (assignmentAttemptFile != null)
                    {
                        assignmentAttemptFile.Descendants("AssignmentAttempt").First(s => s.Element("ID").Value == assignmentAttempt.ID).Remove();
                        assignmentAttemptFile.Save(fileName);
                    }

                }
                catch (FileNotFoundException ex)
                {
                    System.Diagnostics.Debug.Write(ex.Message);
                }
                catch (ArgumentNullException ex)
                {
                    System.Diagnostics.Debug.Write(DateTime.Now.ToString() + " UpdateAssignmentAttempt failed null referance.\n" + ex.Message);
                }
                catch (InvalidOperationException ex)
                {
                    System.Diagnostics.Debug.Write(DateTime.Now.ToString() + " UpdateAssignmentAttempt failed Invalid Operation.\n" + ex.Message);
                }   
            }
            //public List<AssignmentAttempt> GetAssignmentAttemptsByDateRange(DateTime startDate, DateTime endDate)
            //{
            //    var assignmentAttempts = from assignmentAttempt in GetAllAssignmentAttempts()
            //                             where assignmentAttempt.Date >= startDate
            //                                && assignmentAttempt.Date <= endDate
            //                             select assignmentAttempt;

            //    return new List<AssignmentAttempt>(assignmentAttempts);
            //}

            public void SaveNewAssignmentAttempt(AssignmentAttempt assignmentAttempt)
            {
                string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentAttempsFilename);

                try
                {
                    XDocument assignmentAttemptFile = OpenFile(fileName, MMFileType.AssignmentAttempt);

                    if (assignmentAttemptFile != null)
                    {
                        assignmentAttemptFile.Element("AssignmentAttempts").Add(assignmentAttempt.GetXMLNode());
                        assignmentAttemptFile.Save(fileName);
                    }
                }
                catch (FileNotFoundException ex)
                {
                    System.Diagnostics.Debug.Write(ex.Message);
                }
            
            }
        /// <summary>
        /// 9 April 2014
        /// Jonathan Sanborn
        /// 
        /// Constructor for an Assignment Session
        /// </summary>
        /// <param name="mmControl">The Control Object</param>
        /// <param name="assign">The Assignment for this session</param>
        internal CtrlMathDrill(CtrlStudent mmControl, Student currentStudent)
        {
            init();
            parentControl = mmControl;
            //loggedInStudent = new Student();
            loggedInStudent = currentStudent;
            assignmentAttempt = new AssignmentAttempt();
            studentDrillForm = new frmStudentDrill(this);
            studentResultForm = new frmDrillResult(this);
            

        }