Give homework and print stats

This commit is contained in:
Tim Young 2017-08-02 12:17:20 -05:00
parent c4e24b8c98
commit e8d62bc914
4 changed files with 51 additions and 1 deletions

View File

@ -218,5 +218,16 @@ namespace EduNetworkBuilder
} }
#endregion #endregion
public bool AddHomework(SchoolworkClass ToAdd)
{
//Check to see if we already exist
foreach(SchoolworkClass one in Projects)
{
if (one.ThisID == ToAdd.ThisID) return false;
}
Projects.Add(ToAdd);
return true;
}
} }
} }

View File

@ -119,6 +119,7 @@ namespace EduNetworkBuilder
} }
catch(Exception e) catch(Exception e)
{ {
MessageBox.Show(e.ToString());
CurrentUser = null; CurrentUser = null;
Close(); //we did not succeed. Exit out Close(); //we did not succeed. Exit out
} }
@ -696,7 +697,22 @@ namespace EduNetworkBuilder
private void btnHWGive_Click(object sender, EventArgs e) private void btnHWGive_Click(object sender, EventArgs e)
{ {
int NumStudents = 0;
int NumGiven = 0;
int NumAlready = 0;
//Create a new homework class for each student, containing this homework
if (ViewedSchoolwork == null) return;//We do not have homework selected
foreach(PersonClass PC in CurrentUser.Students)
{
NumStudents++;
SchoolworkClass SWC = ViewedSchoolwork.Clone();
SWC.isMaster = true; //It is homework
SWC.IsSumbitted = false; //It has not yet been submitted
bool didit = PC.AddHomework(SWC);
if (didit) NumGiven++;
else NumAlready++;
}
MessageBox.Show(string.Format(NB.Translate("PPF_GiveHWStats"),"\n\t" + NumStudents, "\n\t" + NumGiven, "\n\t" + NumAlready ));
} }
private void btnHWSave_Click(object sender, EventArgs e) private void btnHWSave_Click(object sender, EventArgs e)

View File

@ -1793,6 +1793,10 @@
<value>Generate Files</value> <value>Generate Files</value>
<comment>PPF_GenerateFiles = Generate Files</comment> <comment>PPF_GenerateFiles = Generate Files</comment>
</data> </data>
<data name="PPF_GiveHWStats" xml:space="preserve">
<value>Result: {0} Students {1} Given {2} Already had this homework</value>
<comment>PPF_GiveHWStats = Result: {0} Students {1} Given {2} Already had this homework</comment>
</data>
<data name="PPF_HWGive" xml:space="preserve"> <data name="PPF_HWGive" xml:space="preserve">
<value>Give</value> <value>Give</value>
<comment>PPF_HWGive = Give</comment> <comment>PPF_HWGive = Give</comment>

View File

@ -38,6 +38,8 @@ namespace EduNetworkBuilder
public DateTime SaveDate; //The date this file was saved. public DateTime SaveDate; //The date this file was saved.
public UInt64 ThisID { get; protected set; } public UInt64 ThisID { get; protected set; }
protected SchoolworkClass() { }
public SchoolworkClass(XmlNode TheNode) public SchoolworkClass(XmlNode TheNode)
{ {
Load(TheNode); Load(TheNode);
@ -53,6 +55,23 @@ namespace EduNetworkBuilder
isMaster = true; isMaster = true;
} }
public SchoolworkClass Clone()
{
SchoolworkClass dest = new SchoolworkClass();
Clone(this, dest);
return dest;
}
public static void Clone(SchoolworkClass source, SchoolworkClass dest)
{
dest.Class = source.Class;
dest.Description = source.Description;
dest.DueDate = source.DueDate;
dest.isMaster = source.isMaster;
dest.IsSumbitted = source.IsSumbitted;
dest.Name = source.Name;
dest.SaveDate = source.SaveDate;
dest.theProject = source.theProject.Clone();
}
#region Load and Save #region Load and Save
//Load and save functions //Load and save functions