Import homework for teachers. Let them export all the homework for a class and import it for another class
This commit is contained in:
parent
aeb61ebcf1
commit
fc39ba71c6
@ -236,6 +236,7 @@ namespace EduNetworkBuilder
|
||||
if (one.ThisID == ToAdd.ThisID) return false;
|
||||
}
|
||||
Projects.Add(ToAdd);
|
||||
if (ToAdd.ThisID >= UserSettings.NextID) UserSettings.NextID = (uint)(ToAdd.ThisID + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -291,20 +292,51 @@ namespace EduNetworkBuilder
|
||||
int totalHW =0;
|
||||
int Skipped = 0;
|
||||
int imported = 0;
|
||||
int replaced = 0;
|
||||
foreach (SchoolworkClass one in WhatWeRead)
|
||||
if (isAdmin)
|
||||
{
|
||||
totalHW++;
|
||||
if(isAdmin)
|
||||
Dictionary<string, bool> InitialList = new Dictionary<string, bool>();
|
||||
//use a check-box list
|
||||
foreach (SchoolworkClass one in WhatWeRead)
|
||||
{
|
||||
//use a check-box list
|
||||
//Use due date and name + already exists (name / ID)
|
||||
//they check if they want to import
|
||||
//We never overwrite, we make a new one, with new ID
|
||||
string Info = one.DueDate.ToShortDateString();
|
||||
Info += "\t" + one.Name;
|
||||
if (HasHomework(one, true)) Info += " * " + string.Format(NB.Translate("PC_HWHasID"),one.ThisID);
|
||||
if (HasHomework(one, false)) Info += " ** " + string.Format(NB.Translate("PC_HWHasName"));
|
||||
InitialList.Add(Info, false);
|
||||
}
|
||||
else
|
||||
Dictionary<string, bool> ResponseList = NB.CheckPromptBox(InitialList, "Import", Properties.Resources.NBIco);
|
||||
|
||||
if (ResponseList == null) return; //They canceled out.
|
||||
|
||||
int index = 0;
|
||||
foreach(string One in ResponseList.Keys)
|
||||
{
|
||||
if(AddHomework(one))
|
||||
totalHW++;
|
||||
if (ResponseList[One])
|
||||
{ //We are supposed to import it.
|
||||
if (HasHomework(WhatWeRead[index], true))
|
||||
{ //We already have this ID. Get a new ID
|
||||
WhatWeRead[index].ChangeID(this); //Pass in this user, whoever we are
|
||||
}
|
||||
//Now we can add it without issue.
|
||||
AddHomework(WhatWeRead[index]);
|
||||
imported++;
|
||||
}
|
||||
else
|
||||
Skipped++;
|
||||
index++;
|
||||
}
|
||||
//they check if they want to import
|
||||
//We never overwrite, we make a new one, with new ID
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (SchoolworkClass one in WhatWeRead)
|
||||
{
|
||||
totalHW++;
|
||||
|
||||
if (AddHomework(one))
|
||||
{
|
||||
imported++;
|
||||
}
|
||||
@ -314,6 +346,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
}
|
||||
MessageBox.Show(string.Format(NB.Translate("PC_HWFileImportStats"),"\n\t" + totalHW, "\n\t" + imported, "\n\t" + Skipped));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1869,4 +1869,16 @@
|
||||
<value>Save</value>
|
||||
<comment>_Save = Save</comment>
|
||||
</data>
|
||||
<data name="PC_HWFileImportStats" xml:space="preserve">
|
||||
<value>Results: {0} total homework {1} imported {2} skipped</value>
|
||||
<comment>PC_HWFileImportStats = Results: {0} total homework {1} imported {2} skipped</comment>
|
||||
</data>
|
||||
<data name="PC_HWHasID" xml:space="preserve">
|
||||
<value>ID {0} Already exists.</value>
|
||||
<comment>PC_HWHasID = ID {0} Already exists.</comment>
|
||||
</data>
|
||||
<data name="PC_HWHasName" xml:space="preserve">
|
||||
<value>Name already exists.</value>
|
||||
<comment>PC_HWHasName = Name already exists.</comment>
|
||||
</data>
|
||||
</root>
|
@ -136,7 +136,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
switch (Individual.Name.ToLower())
|
||||
{
|
||||
case "EduNetworkBuilderSchoolwork":
|
||||
case "edunetworkbuilderschoolwork":
|
||||
case "schoolwork":
|
||||
ThisList.AddRange(Load(Individual));
|
||||
AddedList = true;
|
||||
@ -221,6 +221,12 @@ namespace EduNetworkBuilder
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
public void ChangeID(PersonClass WhoFor)
|
||||
{
|
||||
if (WhoFor != null && WhoFor.UserSettings != null)
|
||||
ThisID = WhoFor.UserSettings.IssueID();
|
||||
}
|
||||
|
||||
public void Save(XmlWriter writer)
|
||||
{
|
||||
//Save the language name
|
||||
|
Loading…
Reference in New Issue
Block a user