/// <summary> /// 9 April 2014 /// Jonathan Sanborn /// /// XML Constructor /// </summary> /// <param name="mmControl">The Control Object</param> /// <param name="s">The Student this assignment belongs to</param> /// <param name="d">An XElement that represents a Assignment</param> public Assignment(MMControl mmControl, Student s, XElement d) { ID = d.Element("ID").Value; ProblemSet = mmControl.FileHandler.GetProblemSetByID(d.Element("ProblemSetID").Value); DateAssigned = DateTime.Parse( d.Element("DateAssigned").Value); IsCompleted = bool.Parse(d.Element("Completed").Value); if (d.Element("DateCompleted") != null) { DateCompleted = DateTime.Parse(d.Element("DateCompleted").Value); } Student = s; GetAssignmentAttempts(mmControl); }
/// <summary> /// 22 March 2014 Jonathan Sanborn & Harvey Mercado /// Parameterized constructor for Assignment /// </summary> /// <param name="id">A unique ID for the Assignment</param> /// <param name="userID">The unique ID of the user that the assignment is assigned to.</param> /// <param name="problemSetId">the problem set Id of the for which the Problem Set that the assignment is built on</param> /// <param name="goal">The percent of problems that must be correct to pass this assignment values 0.0-1.0.</param> public Assignment(Ctrl mmControl, string id, Student student, ProblemSet problemSet) { init(); this.ID = id; this.Student = student; this.ProblemSet = problemSet; this.DateAssigned = DateTime.Now; GetAssignmentAttempts(mmControl); }
/// <summary> /// 22 March 2014 Jonathan Sanborn & Harvey Mercado /// Parameterized constructor for Assignment /// </summary> /// <param name="mmControl">The Control Object</param> /// <param name="id">A unique ID for the Assignment</param> /// <param name="student">The student that this assignment belongs to.</param> /// <param name="problemSet">the problem set the assignment is built on</param> /// <param name="isCompleted">a boolean indicating that the assignment has been Completed</param> public Assignment(MMControl mmControl, string id, Student student, ProblemSet problemSet, bool isCompleted) { init(); this.ID = id; this.Student = student; this.ProblemSet = problemSet; this.IsCompleted = isCompleted; this.DateAssigned = DateTime.Now; GetAssignmentAttempts(mmControl); }
/// <summary> /// Validate a record from the input file /// </summary> /// <param name="inputLine"></param> /// <returns></returns> /// <history> /// <Created 5 May 2014>Arun Gopinath</Created> /// <Modified 5 May 2014></Modified> /// </history> private bool ValidateInputRecord ( string inputLine ) { bool valid = true; string[] words = inputLine.Split ( ',' ); int maxLen = Properties.Settings.Default.NameLengthMax; if ( words[0].All ( char.IsLetterOrDigit ) == false || words[0].Length > maxLen || words[1].All ( char.IsLetterOrDigit ) == false || words[1].Length > maxLen || words[2].All ( char.IsLetterOrDigit ) == false || words[2].Length > maxLen ) { MessageBox.Show ( "Input file contains Non-Alphanumeric Names/ID", "Select Input file", MessageBoxButtons.OK, MessageBoxIcon.Information ); valid = false; } else { Student s = new Student ( this, Guid.NewGuid ().ToString (), words[1], words[0], words[2], words[2], DateTime.Today, "1", 0 ); importStudentList.Add ( s ); } return valid; }
/// <summary> /// 22 March 2014 /// Jonathan Sanborn & Harvey Mercado /// Adds a new student to the system /// </summary> /// <param name="newUser">A student user to add to the system</param> internal void AddNewStudent(Student newStudent) { AllUserList.Add(newStudent); StudentList.Add(newStudent); this.FileHandler.SaveNewUser(newStudent); }
/// <summary> /// Jonathan Sanborn /// /// Gets the Assignments assigned to the Student /// </summary> /// <param name="student">The Students to get the assignments</param> /// <returns>The Assignments for the student</returns> public List<Assignment> GetAssignmentsByStudent(Student student) { List<Assignment> assignmentList = new List<Assignment>(); string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentFilename); XDocument AssignmentDocument; try { AssignmentDocument = OpenFile(fileName, MMFileType.Assignment); if (AssignmentDocument != null) { assignmentList = AssignmentDocument.Descendants("Assignment").Where( w => w.Element("UserID").Value == student.ID).Select(d => new Assignment(MMControl,student, d)).ToList(); } } catch (System.ArgumentOutOfRangeException ex) { System.Diagnostics.Debug.Write(ex.Message); } return assignmentList; }
/// </summary> /// Handle requst from a form to open the Student Report form /// </summary> /// <author> Jeff Bunce </author> /// <Modified 5 May 2014>Jonathan Sanborn</Modified> internal void RequestStudentReport(Student selectedStudent) { //studentReportForm = new frmStudentReport(this); //studentReportForm.MdiParent = this.adminControlForm; studentReportForm.ShowDialog(); WaitOneSec(); studentReportForm.WindowState = FormWindowState.Maximized; studentReportForm.ShowSelectedStudentDetail(selectedStudent); }
/// <summary> /// 1 April 2014 /// Jonathan Sanborn /// /// Gets the Student with the passed ID /// </summary> /// <param name="id">The id of the student to get from the xml</param> /// <returns>Student with the passed in ID or null</returns> public Student GetStudentByID(string id) { string fileName = Path.Combine(filePath, Properties.Settings.Default.usersFilename); Student student = null; try { XDocument userFile = OpenFile(fileName, MMFileType.User); if (userFile != null) { XElement elem = userFile.Descendants("User").First(s => s.Element("ID").Value == id && s.Element("Type").Value == UserType.Student.ToString()); student = new Student(MMControl, elem); } } catch (FileNotFoundException ex) { System.Diagnostics.Debug.Write(ex.Message); } return student; }
/// <summary> /// Jonathan Sanborn /// /// Copy construct from a User object /// </summary> /// <param name="mmControl">The Controller Object</param> /// <param name="student">The User to copy</param> public Student(Ctrl mmControl, Student student) : base() { init(); this.ID = student.ID; this.UserType = student.UserType; this.FirstName = student.FirstName; this.LastName = student.LastName; this.ScreenName = student.ScreenName; this.LoginRecords = student.LoginRecords; this.Password = student.Password; this.RewardUnits = student.RewardUnits; getAssignments(mmControl); }
/// <summary> /// 22 March 2014 /// Jonathan Sanborn & Harvey Mercado /// Called to login the user currently set /// /// 21 April 2014 /// Jeff Bunce /// Refactored /// /// </summary> internal void UserLogin(object sender, EventArgs e) { if (currentUser == null) { MessageBox.Show("Please Select a user.", "Select User", MessageBoxButtons.OK, MessageBoxIcon.Information); return; // must select a user } TextBox txtPassword = loginForm.Controls.Find("txtPassword", true)[0] as TextBox; if (AuthenticateUser(CurrentUser, txtPassword.Text)) { txtPassword.Text = string.Empty; currentUser.Login(); } else { MessageBox.Show("Sorry that is not the right password", "Incorrect Password", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Text = String.Empty; return; // selected user must authenticate } loginForm.Hide(); loginForm.Close(); if (currentUser.UserType == UserType.Student) { currentStudent = StudentList.Where(w => currentUser.ID == w.ID).First(); problemSetList.Clear(); if (currentStudent.IncompleteAssignments > 0) { ctrlStudent = new CtrlStudent(this); ctrlStudent.TakeControl(this); UpdateLocalLists(); } else { MessageBox.Show(currentUser.ScreenName + " currently has no assignments. Please go see your teacher.", "Go See Teacher", MessageBoxButtons.OK, MessageBoxIcon.Information); keepAlive = true; currentUser.Logout(this); } } else if (currentUser.UserType == UserType.Administrator) { ctrlAdmin = new CtrlAdmin(this); ctrlAdmin.TakeControl(this); UpdateLocalLists(); } }
/// <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); }
///// <summary> ///// 1 April 2014 ///// Jonathan Sanborn ///// ///// Gets the assignements and assignments of the passed in student. ///// </summary> ///// <param name="student">The Student to load with the assignment</param> //public void GetStudentAssignments(ref Student student) //{ // student.Assignments.Clear(); // student.AssignmentAttempts.Clear(); // student.Assignments.AddRange(FileHandler.GetAssignmentsByUser(student)); // foreach (Assignment assign in student.Assignments) // { // student.AssignmentAttempts.AddRange(FileHandler.GetAssignmentAttemptsByAssignmentID(assign.ID)); // } //} /// <summary> /// 22 March 2014 /// Jonathan Sanborn & Harvey Mercado /// Called to login the user currently set /// /// 21 April 2014 /// Jeff Bunce /// Refactored /// /// </summary> internal void UserLogin() { if (currentUser == null) { MessageBox.Show("Please Select a user.", "Select User", MessageBoxButtons.OK, MessageBoxIcon.Information); return; // must select a user } TextBox txtPassword = LoginForm.Controls.Find("txtPassword", true)[0] as TextBox; if (AuthenticateUser(CurrentUser, txtPassword.Text)) { txtPassword.Text = string.Empty; currentUser.Login(); } else { MessageBox.Show("Wrong Password", "Wrong Password", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Text = String.Empty; return; // selected user must authenticate } if (currentUser.UserType == UserType.Student) { currentStudent = StudentList.Where(w => currentUser.ID == w.ID).First(); ProblemSetList.Clear(); if (currentStudent.IncompleteAssignments > 0) { LoginForm.Hide(); LoginForm.Close(); Assignment assign = CurrentStudent.Assignments.Where(w => !w.IsCompleted).First(); assignmentSession = new AssignmentSession(this, ref assign); StudentWelcomeForm = new Forms.frmStudentWelcome(this); StudentWelcomeForm.ShowDialog(); } else { MessageBox.Show(currentUser.ScreenName + " currently has no assignments. Please go see your teacher.", "Go See Teacher", MessageBoxButtons.OK, MessageBoxIcon.Information); currentUser.Logout(this); } } else if (currentUser.UserType == UserType.Administrator) { LoginForm.Hide(); LoginForm.Close(); ProblemSetList = FileHandler.GetAllProblemSets(); AdminForm = new frmAdminControl(this); AdminForm.ShowDialog(); } }