Show student homework

This commit is contained in:
Tim Young 2017-08-02 14:37:18 -05:00
parent e488291152
commit 217371a96f
2 changed files with 61 additions and 12 deletions

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.IO;
using System.Windows.Forms;
namespace EduNetworkBuilder
{
@ -229,5 +230,60 @@ namespace EduNetworkBuilder
return true;
}
/// <summary>
/// Organize the projects into a nice project tree.
/// </summary>
/// <returns></returns>
public TreeNode WorkTree(TreeNode theTop=null)
{
Projects.Sort((q, p) => p.DueDate.CompareTo(q.DueDate));
List<SchoolworkClass> DrawFrom = new List<SchoolworkClass>();
List<SchoolworkClass> MasterList = new List<SchoolworkClass>();
DrawFrom.AddRange(Projects);
for (int i = DrawFrom.Count - 1; i >= 0; i--)
{
if (DrawFrom[i].isMaster)
{
MasterList.Add(DrawFrom[i]);
DrawFrom.RemoveAt(i);
}
}
//Now, all the masters are in Master, and submitted projects are in DrawFrom.
TreeNode Node;
TreeNode Top;
TreeNode Master;
//We have a class tree
if (theTop == null)
{
Top = new TreeNode(NB.Translate("PPF_Class"));
Top.Tag = "Class"; //Do not translate this
}
else
{
Top = theTop;
}
foreach(SchoolworkClass MasterSW in MasterList)
{
Master = new TreeNode(MasterSW.Name);
Master.Tag = MasterSW;
for (int i = DrawFrom.Count -1; i>=0; i--)
{
if(DrawFrom[i].ThisID == MasterSW.ThisID)
{
Node = new TreeNode(DrawFrom[i].Name);
Node.Tag = DrawFrom[i];
Master.Nodes.Add(Node);
}
}
Top.Nodes.Add(Master);
}
return Top;
}
}
}

View File

@ -254,24 +254,17 @@ namespace EduNetworkBuilder
{
Node = new TreeNode(PC.UserName);
Node.Tag = PC;
PC.WorkTree(Node);
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);
}
if (CurrentUser == null) return;
TreeNode Top = CurrentUser.WorkTree();
if (Top != null)
tvClasswork.Nodes.Add(Top);
}
private void SaveUserInfoFromForm()