Hide give and save buttons if we are not the teacher

This commit is contained in:
Tim Young 2017-08-02 12:38:10 -05:00
parent 6198079bae
commit f2e9cae817
2 changed files with 55 additions and 24 deletions

View File

@ -219,33 +219,56 @@ namespace EduNetworkBuilder
else this.Text = "Student: " + CurrentUser.UserName; else this.Text = "Student: " + CurrentUser.UserName;
tvClasswork.Nodes.Clear(); tvClasswork.Nodes.Clear();
TreeNode Node;
if (CurrentUser.isAdmin) if (CurrentUser.isAdmin)
{ {
//We have a class tree UpdateAdminFormFromUser();
Node = new TreeNode(NB.Translate("PPF_Class")); }
Node.Tag = "Class"; //Do not translate this else
TreeNode Top = Node; UpdateStudentFormFromUser();
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. Use top again so we can populate it }
Top = new TreeNode(NB.Translate("PPF_Students"));
Top.Tag = "Students"; //Do not translate this
tvClasswork.Nodes.Add(Top);
//Create nodes for each student
foreach(PersonClass PC in CurrentUser.Students)
{
Node = new TreeNode(PC.UserName);
Node.Tag = PC;
Top.Nodes.Add(Node);
}
private void UpdateAdminFormFromUser()
{
TreeNode Node;
//We have a class tree
Node = new TreeNode(NB.Translate("PPF_Class"));
Node.Tag = "Class"; //Do not translate this
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. Use top again so we can populate it
Top = new TreeNode(NB.Translate("PPF_Students"));
Top.Tag = "Students"; //Do not translate this
tvClasswork.Nodes.Add(Top);
//Create nodes for each student
foreach (PersonClass PC in CurrentUser.Students)
{
Node = new TreeNode(PC.UserName);
Node.Tag = PC;
Top.Nodes.Add(Node);
}
}
private void UpdateStudentFormFromUser()
{
TreeNode Node;
//We have a class tree
Node = new TreeNode(NB.Translate("PPF_Class"));
Node.Tag = "Class"; //Do not translate this
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);
} }
} }
@ -426,6 +449,8 @@ namespace EduNetworkBuilder
lblHWDue.Visible = false; lblHWDue.Visible = false;
btnHWDelete.Visible = false; btnHWDelete.Visible = false;
btnLaunch.Visible = false; btnLaunch.Visible = false;
btnHWGive.Visible = false;
btnHWSave.Visible = false;
return; return;
} }
tbHWClass.Text = ViewedSchoolwork.Class; tbHWClass.Text = ViewedSchoolwork.Class;
@ -446,8 +471,13 @@ namespace EduNetworkBuilder
} }
if (ViewedSchoolwork.DueDate < dtpHWDue.MinDate) ViewedSchoolwork.DueDate = dtpHWDue.MinDate; if (ViewedSchoolwork.DueDate < dtpHWDue.MinDate) ViewedSchoolwork.DueDate = dtpHWDue.MinDate;
dtpHWDue.Value = ViewedSchoolwork.DueDate; dtpHWDue.Value = ViewedSchoolwork.DueDate;
if(CurrentUser != null && CurrentUser.isAdmin) if (CurrentUser != null && CurrentUser.isAdmin)
{
btnHWDelete.Visible = true; //Only the teacher can delete the homework btnHWDelete.Visible = true; //Only the teacher can delete the homework
btnHWGive.Visible = true;
btnHWSave.Visible = true;
}
btnLaunch.Visible = true; btnLaunch.Visible = true;
} }

View File

@ -61,6 +61,7 @@ namespace EduNetworkBuilder
Clone(this, dest); Clone(this, dest);
return dest; return dest;
} }
public static void Clone(SchoolworkClass source, SchoolworkClass dest) public static void Clone(SchoolworkClass source, SchoolworkClass dest)
{ {
dest.ThisID = source.ThisID; dest.ThisID = source.ThisID;