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,9 +219,18 @@ namespace EduNetworkBuilder
else this.Text = "Student: " + CurrentUser.UserName;
tvClasswork.Nodes.Clear();
TreeNode Node;
if (CurrentUser.isAdmin)
{
UpdateAdminFormFromUser();
}
else
UpdateStudentFormFromUser();
}
private void UpdateAdminFormFromUser()
{
TreeNode Node;
//We have a class tree
Node = new TreeNode(NB.Translate("PPF_Class"));
Node.Tag = "Class"; //Do not translate this
@ -245,7 +254,21 @@ namespace EduNetworkBuilder
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;
btnHWDelete.Visible = false;
btnLaunch.Visible = false;
btnHWGive.Visible = false;
btnHWSave.Visible = false;
return;
}
tbHWClass.Text = ViewedSchoolwork.Class;
@ -447,7 +472,12 @@ namespace EduNetworkBuilder
if (ViewedSchoolwork.DueDate < dtpHWDue.MinDate) ViewedSchoolwork.DueDate = dtpHWDue.MinDate;
dtpHWDue.Value = ViewedSchoolwork.DueDate;
if (CurrentUser != null && CurrentUser.isAdmin)
{
btnHWDelete.Visible = true; //Only the teacher can delete the homework
btnHWGive.Visible = true;
btnHWSave.Visible = true;
}
btnLaunch.Visible = true;
}

View File

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