diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs
index e12a9c2..1ab4d45 100644
--- a/EduNetworkBuilder/NetworkBuilder.cs
+++ b/EduNetworkBuilder/NetworkBuilder.cs
@@ -1751,34 +1751,45 @@ namespace EduNetworkBuilder
MessageBox.Show(NB.Translate("NB_LogOutFirst"));
return;
}
- int counter = 0;
- PersonClass tUser = null;
- while (counter < 3)
- {
- string tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true);
- string tUserName = Path.GetFileNameWithoutExtension(filename);
- string PasToUse = tUserName + tPass;
- tUser = PersonClass.TryLoad(filename, PasToUse);
- if (tUser != null) break;
- counter++;
- }
- if(tUser == null)
- {
- //failed to load.
- MessageBox.Show("Too many password failures. Exiting.");
- return;
- }
- CurrentUser = tUser;
- CurrentUser.filepath = Path.GetDirectoryName(filename); //store the directory
- OurSettings = NB.GetSettings(); //Grab the new settings from the user
- if (CurrentUser.ChangePassAtFirstLogin)
- CurrentUser.ChangePassword(); //change the password
- UpdateMenu();
+ if (CurrentUser == null)
+ { //Load a starting, or a new user
+ int counter = 0;
+ PersonClass tUser = null;
+ while (counter < 3)
+ {
+ string tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true);
+ string tUserName = Path.GetFileNameWithoutExtension(filename);
+ string PasToUse = tUserName + tPass;
+ tUser = PersonClass.TryLoad(filename, PasToUse);
+ if (tUser != null) break;
+ counter++;
+ }
+ if (tUser == null)
+ {
+ //failed to load.
+ MessageBox.Show("Too many password failures. Exiting.");
+ return;
+ }
+ CurrentUser = tUser;
+ CurrentUser.filepath = Path.GetDirectoryName(filename); //store the directory
+ OurSettings = NB.GetSettings(); //Grab the new settings from the user
+ if (CurrentUser.ChangePassAtFirstLogin)
+ CurrentUser.ChangePassword(); //change the password
+ UpdateMenu();
- //Now, open a new window to edit them.
- PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
- CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
- UpdateMenu();
+ //Now, open a new window to edit them.
+ PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
+ CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
+ UpdateMenu();
+ }
+ else if(CurrentUser != null && CurrentUser.isAdmin)
+ {
+ //We want to import the student information for this one student
+ //Dig up the corresponding user.
+ //Use the alt password for that user to load the file
+ //import their settings
+ //messagebox to show what we are doing
+ }
}
else if (extension == ".enbh")
{
diff --git a/EduNetworkBuilder/PersonClass.cs b/EduNetworkBuilder/PersonClass.cs
index 213910f..994f2f3 100644
--- a/EduNetworkBuilder/PersonClass.cs
+++ b/EduNetworkBuilder/PersonClass.cs
@@ -573,5 +573,52 @@ namespace EduNetworkBuilder
return Top;
}
+ ///
+ /// Return the student with the specified UserName
+ ///
+ /// The user name to find
+ /// The specified person, or null if no such person exists.
+ public PersonClass StudentWithTheUserName(string UserName)
+ {
+ if (!isAdmin) return null; //Students do not store other student records
+ foreach(PersonClass PC in Students)
+ {
+ if (PC.UserName == UserName) return PC;
+ }
+ return null;
+ }
+
+ ///
+ /// Import the settings from a student record
+ ///
+ /// the student we are importing from
+ /// The count of homeworks we added. -1 if there is an error
+ public int TeacherImportStudentHomework(PersonClass ImportedStudent)
+ {
+ if (!isAdmin) return -1;
+ PersonClass StoredStudent = StudentWithTheUserName(ImportedStudent.UserName);
+ if (StoredStudent == null) return -1;
+
+ int NumSubmitted = 0;
+
+ //Retrieve all the stored settings, in case we need to re-write their file
+ StoredStudent.UserSettings = ImportedStudent.UserSettings;
+
+ //Pull out their password, in case we want to retrieve it. (sigh)
+ StoredStudent.Password = ImportedStudent.Password;
+
+ // loop through all networks
+ foreach (SchoolworkClass SWC in ImportedStudent.Projects)
+ {
+ // Find any that are submitted, which are not in the admin file
+ if (StoredStudent.RegisterNewlySubmittedHW(SWC))
+ {
+ // copy them into the admin file
+ NumSubmitted++;
+ }
+ }
+ return NumSubmitted;
+ }
+
}
}
diff --git a/EduNetworkBuilder/PersonProfileForm.cs b/EduNetworkBuilder/PersonProfileForm.cs
index 0dd2b3e..b16fcd0 100644
--- a/EduNetworkBuilder/PersonProfileForm.cs
+++ b/EduNetworkBuilder/PersonProfileForm.cs
@@ -919,24 +919,9 @@ namespace EduNetworkBuilder
continue; //Do not try to load in the data
}
- //Retrieve all the stored settings, in case we need to re-write their file
- storedStudent.UserSettings = tempStudent.UserSettings;
-
- //Pull out their password, in case we want to retrieve it. (sigh)
- storedStudent.Password = tempStudent.Password;
-
- // loop through all networks
- foreach (SchoolworkClass SWC in tempStudent.Projects)
- {
- // Find any that are submitted, which are not in the admin file
- if(storedStudent.RegisterNewlySubmittedHW(SWC))
- {
- // copy them into the admin file
- NumSubmitted++;
- HadASubmission = true;
- }
- }
- if (!HadASubmission)
+ int tCountSubmitted = CurrentUser.TeacherImportStudentHomework(tempStudent);
+ NumSubmitted += tCountSubmitted;
+ if (tCountSubmitted >0)
NumStudentsNoSubmissions++;
}
else