From 5c6fe6ffbbac613cdcbf969112938f5d89961c12 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sun, 30 Jul 2017 18:18:41 -0500 Subject: [PATCH] Make changes to a homework file --- .../PersonProfileForm.Designer.cs | 295 ++++++++++++++---- EduNetworkBuilder/PersonProfileForm.cs | 95 +++++- .../Resources/languages/edustrings.resx | 8 + EduNetworkBuilder/SchoolworkClass.cs | 12 +- 4 files changed, 345 insertions(+), 65 deletions(-) diff --git a/EduNetworkBuilder/PersonProfileForm.Designer.cs b/EduNetworkBuilder/PersonProfileForm.Designer.cs index 703d4cd..2de20c7 100644 --- a/EduNetworkBuilder/PersonProfileForm.Designer.cs +++ b/EduNetworkBuilder/PersonProfileForm.Designer.cs @@ -30,17 +30,35 @@ { this.tcTabControl = new System.Windows.Forms.TabControl(); this.TabProfile = new System.Windows.Forms.TabPage(); - this.TabClasswork = new System.Windows.Forms.TabPage(); - this.tbUsername = new System.Windows.Forms.TextBox(); - this.lblUsername = new System.Windows.Forms.Label(); - this.tbFullName = new System.Windows.Forms.TextBox(); - this.lblFullName = new System.Windows.Forms.Label(); this.btnChangePassword = new System.Windows.Forms.Button(); - this.btnExit = new System.Windows.Forms.Button(); + this.lblFullName = new System.Windows.Forms.Label(); + this.tbFullName = new System.Windows.Forms.TextBox(); + this.lblUsername = new System.Windows.Forms.Label(); + this.tbUsername = new System.Windows.Forms.TextBox(); + this.TabClasswork = new System.Windows.Forms.TabPage(); this.tvClasswork = new System.Windows.Forms.TreeView(); + this.btnExit = new System.Windows.Forms.Button(); + this.tcTreeData = new System.Windows.Forms.TabControl(); + this.tabClass = new System.Windows.Forms.TabPage(); + this.TabHomework = new System.Windows.Forms.TabPage(); + this.TabStudent = new System.Windows.Forms.TabPage(); + this.tbHWClass = new System.Windows.Forms.TextBox(); + this.tbHWName = new System.Windows.Forms.TextBox(); + this.tbHWDescription = new System.Windows.Forms.TextBox(); + this.lblHWClass = new System.Windows.Forms.Label(); + this.lblHWName = new System.Windows.Forms.Label(); + this.lblHWDescription = new System.Windows.Forms.Label(); + this.dtpHWDue = new System.Windows.Forms.DateTimePicker(); + this.lblHWDue = new System.Windows.Forms.Label(); + this.tbHWSubmitted = new System.Windows.Forms.TextBox(); + this.lblHWSubmitted = new System.Windows.Forms.Label(); + this.btnImportStudents = new System.Windows.Forms.Button(); this.tcTabControl.SuspendLayout(); this.TabProfile.SuspendLayout(); this.TabClasswork.SuspendLayout(); + this.tcTreeData.SuspendLayout(); + this.tabClass.SuspendLayout(); + this.TabHomework.SuspendLayout(); this.SuspendLayout(); // // tcTabControl @@ -71,50 +89,6 @@ this.TabProfile.Text = "Profile"; this.TabProfile.UseVisualStyleBackColor = true; // - // TabClasswork - // - this.TabClasswork.Controls.Add(this.tvClasswork); - this.TabClasswork.Location = new System.Drawing.Point(4, 25); - this.TabClasswork.Name = "TabClasswork"; - this.TabClasswork.Padding = new System.Windows.Forms.Padding(3); - this.TabClasswork.Size = new System.Drawing.Size(410, 251); - this.TabClasswork.TabIndex = 1; - this.TabClasswork.Text = "Classwork"; - this.TabClasswork.UseVisualStyleBackColor = true; - // - // tbUsername - // - this.tbUsername.Enabled = false; - this.tbUsername.Location = new System.Drawing.Point(100, 19); - this.tbUsername.Name = "tbUsername"; - this.tbUsername.Size = new System.Drawing.Size(124, 22); - this.tbUsername.TabIndex = 0; - // - // lblUsername - // - this.lblUsername.AutoSize = true; - this.lblUsername.Location = new System.Drawing.Point(17, 22); - this.lblUsername.Name = "lblUsername"; - this.lblUsername.Size = new System.Drawing.Size(73, 17); - this.lblUsername.TabIndex = 1; - this.lblUsername.Text = "Username"; - // - // tbFullName - // - this.tbFullName.Location = new System.Drawing.Point(99, 59); - this.tbFullName.Name = "tbFullName"; - this.tbFullName.Size = new System.Drawing.Size(125, 22); - this.tbFullName.TabIndex = 2; - // - // lblFullName - // - this.lblFullName.AutoSize = true; - this.lblFullName.Location = new System.Drawing.Point(23, 63); - this.lblFullName.Name = "lblFullName"; - this.lblFullName.Size = new System.Drawing.Size(71, 17); - this.lblFullName.TabIndex = 3; - this.lblFullName.Text = "Full Name"; - // // btnChangePassword // this.btnChangePassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -126,6 +100,61 @@ this.btnChangePassword.UseVisualStyleBackColor = true; this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click); // + // lblFullName + // + this.lblFullName.AutoSize = true; + this.lblFullName.Location = new System.Drawing.Point(23, 63); + this.lblFullName.Name = "lblFullName"; + this.lblFullName.Size = new System.Drawing.Size(71, 17); + this.lblFullName.TabIndex = 3; + this.lblFullName.Text = "Full Name"; + // + // tbFullName + // + this.tbFullName.Location = new System.Drawing.Point(99, 59); + this.tbFullName.Name = "tbFullName"; + this.tbFullName.Size = new System.Drawing.Size(125, 22); + this.tbFullName.TabIndex = 2; + // + // lblUsername + // + this.lblUsername.AutoSize = true; + this.lblUsername.Location = new System.Drawing.Point(17, 22); + this.lblUsername.Name = "lblUsername"; + this.lblUsername.Size = new System.Drawing.Size(73, 17); + this.lblUsername.TabIndex = 1; + this.lblUsername.Text = "Username"; + // + // tbUsername + // + this.tbUsername.Enabled = false; + this.tbUsername.Location = new System.Drawing.Point(100, 19); + this.tbUsername.Name = "tbUsername"; + this.tbUsername.Size = new System.Drawing.Size(124, 22); + this.tbUsername.TabIndex = 0; + // + // TabClasswork + // + this.TabClasswork.Controls.Add(this.tcTreeData); + this.TabClasswork.Controls.Add(this.tvClasswork); + this.TabClasswork.Location = new System.Drawing.Point(4, 25); + this.TabClasswork.Name = "TabClasswork"; + this.TabClasswork.Padding = new System.Windows.Forms.Padding(3); + this.TabClasswork.Size = new System.Drawing.Size(410, 251); + this.TabClasswork.TabIndex = 1; + this.TabClasswork.Text = "Classwork"; + this.TabClasswork.UseVisualStyleBackColor = true; + // + // tvClasswork + // + this.tvClasswork.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.tvClasswork.Location = new System.Drawing.Point(6, 6); + this.tvClasswork.Name = "tvClasswork"; + this.tvClasswork.Size = new System.Drawing.Size(131, 239); + this.tvClasswork.TabIndex = 0; + this.tvClasswork.Click += new System.EventHandler(this.tvClasswork_Click); + // // btnExit // this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -137,14 +166,147 @@ this.btnExit.UseVisualStyleBackColor = true; this.btnExit.Click += new System.EventHandler(this.btnExit_Click); // - // tvClasswork + // tcTreeData // - this.tvClasswork.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.tvClasswork.Location = new System.Drawing.Point(6, 6); - this.tvClasswork.Name = "tvClasswork"; - this.tvClasswork.Size = new System.Drawing.Size(131, 239); - this.tvClasswork.TabIndex = 0; + this.tcTreeData.Controls.Add(this.tabClass); + this.tcTreeData.Controls.Add(this.TabHomework); + this.tcTreeData.Controls.Add(this.TabStudent); + this.tcTreeData.Location = new System.Drawing.Point(145, 9); + this.tcTreeData.Name = "tcTreeData"; + this.tcTreeData.SelectedIndex = 0; + this.tcTreeData.Size = new System.Drawing.Size(264, 235); + this.tcTreeData.TabIndex = 1; + // + // tabClass + // + this.tabClass.Controls.Add(this.btnImportStudents); + this.tabClass.Location = new System.Drawing.Point(4, 25); + this.tabClass.Name = "tabClass"; + this.tabClass.Padding = new System.Windows.Forms.Padding(3); + this.tabClass.Size = new System.Drawing.Size(256, 206); + this.tabClass.TabIndex = 0; + this.tabClass.Text = "Class"; + this.tabClass.UseVisualStyleBackColor = true; + // + // TabHomework + // + this.TabHomework.Controls.Add(this.lblHWSubmitted); + this.TabHomework.Controls.Add(this.tbHWSubmitted); + this.TabHomework.Controls.Add(this.lblHWDue); + this.TabHomework.Controls.Add(this.dtpHWDue); + this.TabHomework.Controls.Add(this.lblHWDescription); + this.TabHomework.Controls.Add(this.lblHWName); + this.TabHomework.Controls.Add(this.lblHWClass); + this.TabHomework.Controls.Add(this.tbHWDescription); + this.TabHomework.Controls.Add(this.tbHWName); + this.TabHomework.Controls.Add(this.tbHWClass); + this.TabHomework.Location = new System.Drawing.Point(4, 25); + this.TabHomework.Name = "TabHomework"; + this.TabHomework.Padding = new System.Windows.Forms.Padding(3); + this.TabHomework.Size = new System.Drawing.Size(256, 206); + this.TabHomework.TabIndex = 1; + this.TabHomework.Text = "Homework"; + this.TabHomework.UseVisualStyleBackColor = true; + // + // TabStudent + // + this.TabStudent.Location = new System.Drawing.Point(4, 25); + this.TabStudent.Name = "TabStudent"; + this.TabStudent.Padding = new System.Windows.Forms.Padding(3); + this.TabStudent.Size = new System.Drawing.Size(256, 206); + this.TabStudent.TabIndex = 2; + this.TabStudent.Text = "Student"; + this.TabStudent.UseVisualStyleBackColor = true; + // + // tbHWClass + // + this.tbHWClass.Location = new System.Drawing.Point(131, 6); + this.tbHWClass.Name = "tbHWClass"; + this.tbHWClass.Size = new System.Drawing.Size(100, 22); + this.tbHWClass.TabIndex = 0; + // + // tbHWName + // + this.tbHWName.Location = new System.Drawing.Point(131, 36); + this.tbHWName.Name = "tbHWName"; + this.tbHWName.Size = new System.Drawing.Size(100, 22); + this.tbHWName.TabIndex = 1; + // + // tbHWDescription + // + this.tbHWDescription.Location = new System.Drawing.Point(131, 64); + this.tbHWDescription.Name = "tbHWDescription"; + this.tbHWDescription.Size = new System.Drawing.Size(100, 22); + this.tbHWDescription.TabIndex = 2; + // + // lblHWClass + // + this.lblHWClass.AutoSize = true; + this.lblHWClass.Location = new System.Drawing.Point(6, 9); + this.lblHWClass.Name = "lblHWClass"; + this.lblHWClass.Size = new System.Drawing.Size(42, 17); + this.lblHWClass.TabIndex = 3; + this.lblHWClass.Text = "Class"; + // + // lblHWName + // + this.lblHWName.AutoSize = true; + this.lblHWName.Location = new System.Drawing.Point(6, 36); + this.lblHWName.Name = "lblHWName"; + this.lblHWName.Size = new System.Drawing.Size(45, 17); + this.lblHWName.TabIndex = 4; + this.lblHWName.Text = "Name"; + // + // lblHWDescription + // + this.lblHWDescription.AutoSize = true; + this.lblHWDescription.Location = new System.Drawing.Point(6, 64); + this.lblHWDescription.Name = "lblHWDescription"; + this.lblHWDescription.Size = new System.Drawing.Size(79, 17); + this.lblHWDescription.TabIndex = 5; + this.lblHWDescription.Text = "Description"; + // + // dtpHWDue + // + this.dtpHWDue.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtpHWDue.Location = new System.Drawing.Point(91, 92); + this.dtpHWDue.Name = "dtpHWDue"; + this.dtpHWDue.Size = new System.Drawing.Size(140, 22); + this.dtpHWDue.TabIndex = 6; + // + // lblHWDue + // + this.lblHWDue.AutoSize = true; + this.lblHWDue.Location = new System.Drawing.Point(6, 97); + this.lblHWDue.Name = "lblHWDue"; + this.lblHWDue.Size = new System.Drawing.Size(34, 17); + this.lblHWDue.TabIndex = 7; + this.lblHWDue.Text = "Due"; + // + // tbHWSubmitted + // + this.tbHWSubmitted.Location = new System.Drawing.Point(91, 120); + this.tbHWSubmitted.Name = "tbHWSubmitted"; + this.tbHWSubmitted.Size = new System.Drawing.Size(140, 22); + this.tbHWSubmitted.TabIndex = 8; + // + // lblHWSubmitted + // + this.lblHWSubmitted.AutoSize = true; + this.lblHWSubmitted.Location = new System.Drawing.Point(6, 125); + this.lblHWSubmitted.Name = "lblHWSubmitted"; + this.lblHWSubmitted.Size = new System.Drawing.Size(71, 17); + this.lblHWSubmitted.TabIndex = 9; + this.lblHWSubmitted.Text = "Submitted"; + // + // btnImportStudents + // + this.btnImportStudents.Location = new System.Drawing.Point(6, 6); + this.btnImportStudents.Name = "btnImportStudents"; + this.btnImportStudents.Size = new System.Drawing.Size(164, 23); + this.btnImportStudents.TabIndex = 0; + this.btnImportStudents.Text = "Import Students"; + this.btnImportStudents.UseVisualStyleBackColor = true; // // PersonProfileForm // @@ -160,6 +322,10 @@ this.TabProfile.ResumeLayout(false); this.TabProfile.PerformLayout(); this.TabClasswork.ResumeLayout(false); + this.tcTreeData.ResumeLayout(false); + this.tabClass.ResumeLayout(false); + this.TabHomework.ResumeLayout(false); + this.TabHomework.PerformLayout(); this.ResumeLayout(false); } @@ -176,5 +342,20 @@ private System.Windows.Forms.Label lblFullName; private System.Windows.Forms.Button btnExit; private System.Windows.Forms.TreeView tvClasswork; + private System.Windows.Forms.TabControl tcTreeData; + private System.Windows.Forms.TabPage tabClass; + private System.Windows.Forms.TabPage TabHomework; + private System.Windows.Forms.TabPage TabStudent; + private System.Windows.Forms.Label lblHWDescription; + private System.Windows.Forms.Label lblHWName; + private System.Windows.Forms.Label lblHWClass; + private System.Windows.Forms.TextBox tbHWDescription; + private System.Windows.Forms.TextBox tbHWName; + private System.Windows.Forms.TextBox tbHWClass; + private System.Windows.Forms.Label lblHWSubmitted; + private System.Windows.Forms.TextBox tbHWSubmitted; + private System.Windows.Forms.Label lblHWDue; + private System.Windows.Forms.DateTimePicker dtpHWDue; + private System.Windows.Forms.Button btnImportStudents; } } \ No newline at end of file diff --git a/EduNetworkBuilder/PersonProfileForm.cs b/EduNetworkBuilder/PersonProfileForm.cs index a93c841..31e1c13 100644 --- a/EduNetworkBuilder/PersonProfileForm.cs +++ b/EduNetworkBuilder/PersonProfileForm.cs @@ -13,8 +13,12 @@ namespace EduNetworkBuilder { public partial class PersonProfileForm : Form { + enum TopTab { profiletab=0, classworktab=1} + enum TreeDataTab { classtab=0, homeworktab=1, studenttab=2 } PersonClass CurrentUser = null; string FileName = ""; + PersonClass ViewedUser = null; + SchoolworkClass ViewedSchoolwork = null; public PersonProfileForm(string filename = "") { @@ -87,10 +91,23 @@ namespace EduNetworkBuilder } } + tvClasswork.AfterSelect += tvClasswork_Click; + + tbHWClass.LostFocus += SaveSchoolworkDataFromForm; + tbHWDescription.LostFocus += SaveSchoolworkDataFromForm; + tbHWName.LostFocus += SaveSchoolworkDataFromForm; + tbHWSubmitted.LostFocus += SaveSchoolworkDataFromForm; + dtpHWDue.LostFocus += SaveSchoolworkDataFromForm; + //Make sure we update any profile settings they change tbFullName.LostFocus += SaveUserInfoFromForm; } + private void DtpHWDue_LostFocus(object sender, EventArgs e) + { + throw new NotImplementedException(); + } + public PersonClass Edit() { BuilderWindow BW = NB.GetBuilderWin(); @@ -135,16 +152,19 @@ namespace EduNetworkBuilder if (CurrentUser.isAdmin) { //We have a class tree - Node = new TreeNode("Class"); + Node = new TreeNode(NB.Translate("PPF_Class")); + Node.Tag = "Class"; TreeNode Top = Node; tvClasswork.Nodes.Add(Node); foreach(SchoolworkClass SWC in CurrentUser.Projects) { Node = new TreeNode(SWC.Name); + Node.Tag = SWC; //Store the schoolwork record in with the node Top.Nodes.Add(Node); } //we have a students tree - Node = new TreeNode("Students"); + Node = new TreeNode(NB.Translate("PPF_Students")); + Node.Tag = "Students"; tvClasswork.Nodes.Add(Node); } } @@ -198,5 +218,76 @@ namespace EduNetworkBuilder CurrentUser.ChangePassword(Password1); } + + private void ChangeTreeDataTab(TreeDataTab WhatTo) + { + tcTabControl.SelectedIndex = (int)TopTab.classworktab; + tcTreeData.SelectedIndex = (int)WhatTo; + } + + private void tvClasswork_Click(object sender, EventArgs e) + { + if (tvClasswork.SelectedNode == null) return; + + TreeNode Node = tvClasswork.SelectedNode; + + if (Node.Tag is SchoolworkClass) + { + SchoolworkClass SWC = (SchoolworkClass)Node.Tag; + //It is a homework. Select the homework tab and fill it + ChangeTreeDataTab(TreeDataTab.homeworktab); + UpdateFormFromSchoolwork(SWC); + } + } + + void SaveSchoolworkDataFromForm(object sender, EventArgs e) + { + SaveSchoolworkDataFromForm(); + } + private void SaveSchoolworkDataFromForm() + { + if (ViewedSchoolwork == null) return; + ViewedSchoolwork.Class = tbHWClass.Text; + ViewedSchoolwork.Description = tbHWDescription.Text; + ViewedSchoolwork.Name = tbHWName.Text; + ViewedSchoolwork.DueDate = dtpHWDue.Value; + } + + private void UpdateFormFromSchoolwork(SchoolworkClass What) + { + ViewedSchoolwork = What; + UpdateFormFromSchoolwork(); + } + private void UpdateFormFromSchoolwork() + { + if (ViewedSchoolwork == null) + { + tbHWClass.Text = ""; + tbHWDescription.Text = ""; + tbHWName.Text =""; + tbHWSubmitted.Visible = false; + dtpHWDue.Visible = false; + lblHWDue.Visible = false; + return; + } + tbHWClass.Text = ViewedSchoolwork.Class; + tbHWDescription.Text = ViewedSchoolwork.Description; + tbHWName.Text = ViewedSchoolwork.Name; + dtpHWDue.Visible = true; + lblHWDue.Visible = true; + if (ViewedSchoolwork.IsSumbitted) + { + tbHWSubmitted.Visible = true; + lblHWDue.Visible = true; + tbHWSubmitted.Text = ViewedSchoolwork.SaveDate.ToString(); + } + else + { + tbHWSubmitted.Visible = false; + lblHWDue.Visible = false; + } + if (ViewedSchoolwork.DueDate < dtpHWDue.MinDate) ViewedSchoolwork.DueDate = dtpHWDue.MinDate; + dtpHWDue.Value = ViewedSchoolwork.DueDate; + } } } \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index 9b38b90..2fe904c 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1753,4 +1753,12 @@ Cannot load invalid file. NB_InvalidFile = Cannot load invalid file. + + Class + PPF_Class = Class + + + Students + PPF_Students=Students + \ No newline at end of file diff --git a/EduNetworkBuilder/SchoolworkClass.cs b/EduNetworkBuilder/SchoolworkClass.cs index d751b0d..23fa2ae 100644 --- a/EduNetworkBuilder/SchoolworkClass.cs +++ b/EduNetworkBuilder/SchoolworkClass.cs @@ -21,21 +21,21 @@ namespace EduNetworkBuilder /// /// The short description of the project. /// - string Description = ""; + public string Description = ""; /// /// The class to which this project belongs. If the student is using this for multiple classes, /// but more likely just for the teacher to organize things with. /// - string Class = ""; + public string Class = ""; /// /// The date / time that the project is due. /// - DateTime DueDate; + public DateTime DueDate; - bool isMaster = false; //Is this the original project? If so, we never replace it. + public bool isMaster = false; //Is this the original project? If so, we never replace it. - bool IsSumbitted = false; //Is the student submitting this? If so, date-stamp it and lock it. - DateTime SaveDate; //The date this file was saved. + public bool IsSumbitted = false; //Is the student submitting this? If so, date-stamp it and lock it. + public DateTime SaveDate; //The date this file was saved. public SchoolworkClass(XmlNode TheNode) {