prep for admin loading in one student file
This commit is contained in:
parent
cff1dada9c
commit
392c8c8b35
@ -1751,34 +1751,45 @@ namespace EduNetworkBuilder
|
|||||||
MessageBox.Show(NB.Translate("NB_LogOutFirst"));
|
MessageBox.Show(NB.Translate("NB_LogOutFirst"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int counter = 0;
|
if (CurrentUser == null)
|
||||||
PersonClass tUser = null;
|
{ //Load a starting, or a new user
|
||||||
while (counter < 3)
|
int counter = 0;
|
||||||
{
|
PersonClass tUser = null;
|
||||||
string tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true);
|
while (counter < 3)
|
||||||
string tUserName = Path.GetFileNameWithoutExtension(filename);
|
{
|
||||||
string PasToUse = tUserName + tPass;
|
string tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true);
|
||||||
tUser = PersonClass.TryLoad(filename, PasToUse);
|
string tUserName = Path.GetFileNameWithoutExtension(filename);
|
||||||
if (tUser != null) break;
|
string PasToUse = tUserName + tPass;
|
||||||
counter++;
|
tUser = PersonClass.TryLoad(filename, PasToUse);
|
||||||
}
|
if (tUser != null) break;
|
||||||
if(tUser == null)
|
counter++;
|
||||||
{
|
}
|
||||||
//failed to load.
|
if (tUser == null)
|
||||||
MessageBox.Show("Too many password failures. Exiting.");
|
{
|
||||||
return;
|
//failed to load.
|
||||||
}
|
MessageBox.Show("Too many password failures. Exiting.");
|
||||||
CurrentUser = tUser;
|
return;
|
||||||
CurrentUser.filepath = Path.GetDirectoryName(filename); //store the directory
|
}
|
||||||
OurSettings = NB.GetSettings(); //Grab the new settings from the user
|
CurrentUser = tUser;
|
||||||
if (CurrentUser.ChangePassAtFirstLogin)
|
CurrentUser.filepath = Path.GetDirectoryName(filename); //store the directory
|
||||||
CurrentUser.ChangePassword(); //change the password
|
OurSettings = NB.GetSettings(); //Grab the new settings from the user
|
||||||
UpdateMenu();
|
if (CurrentUser.ChangePassAtFirstLogin)
|
||||||
|
CurrentUser.ChangePassword(); //change the password
|
||||||
|
UpdateMenu();
|
||||||
|
|
||||||
//Now, open a new window to edit them.
|
//Now, open a new window to edit them.
|
||||||
PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
|
PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
|
||||||
CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
|
CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
|
||||||
UpdateMenu();
|
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")
|
else if (extension == ".enbh")
|
||||||
{
|
{
|
||||||
|
@ -573,5 +573,52 @@ namespace EduNetworkBuilder
|
|||||||
return Top;
|
return Top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return the student with the specified UserName
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="UserName">The user name to find</param>
|
||||||
|
/// <returns>The specified person, or null if no such person exists.</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Import the settings from a student record
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ImportedStudent">the student we are importing from</param>
|
||||||
|
/// <returns>The count of homeworks we added. -1 if there is an error</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -919,24 +919,9 @@ namespace EduNetworkBuilder
|
|||||||
continue; //Do not try to load in the data
|
continue; //Do not try to load in the data
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieve all the stored settings, in case we need to re-write their file
|
int tCountSubmitted = CurrentUser.TeacherImportStudentHomework(tempStudent);
|
||||||
storedStudent.UserSettings = tempStudent.UserSettings;
|
NumSubmitted += tCountSubmitted;
|
||||||
|
if (tCountSubmitted >0)
|
||||||
//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)
|
|
||||||
NumStudentsNoSubmissions++;
|
NumStudentsNoSubmissions++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user