Write student csv file - includes generated passwords if it was set up to create new PWs for students who did not have any defined

This commit is contained in:
Tim Young 2017-08-10 16:32:45 -05:00
parent 50a04dbef0
commit 217ac4dbd7
3 changed files with 120 additions and 90 deletions

View File

@ -2056,27 +2056,5 @@ namespace EduNetworkBuilder
UpdateMenu(); UpdateMenu();
} }
private void WriteStudentCSVFile(string path)
{
try
{
using (var w = new StreamWriter(path))
{
foreach (PersonClass pc in CurrentUser.Students)
{
string UName = NB.CSVSafeString(pc.UserName);
string FName = NB.CSVSafeString(pc.FullName);
string Pass = NB.CSVSafeString(pc.Password);
var line = string.Format("{0},{1},{2}", UName, FName, Pass);
w.WriteLine(line);
w.Flush();
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
} }
} }

View File

@ -38,8 +38,13 @@
this.TabClasswork = new System.Windows.Forms.TabPage(); this.TabClasswork = new System.Windows.Forms.TabPage();
this.tcTreeData = new System.Windows.Forms.TabControl(); this.tcTreeData = new System.Windows.Forms.TabControl();
this.tabClass = new System.Windows.Forms.TabPage(); this.tabClass = new System.Windows.Forms.TabPage();
this.btnExportStudentPasswords = new System.Windows.Forms.Button();
this.btnExportHomework = new System.Windows.Forms.Button();
this.btnGenerateStudentFiles = new System.Windows.Forms.Button();
this.btnImportStudents = new System.Windows.Forms.Button(); this.btnImportStudents = new System.Windows.Forms.Button();
this.TabHomework = new System.Windows.Forms.TabPage(); this.TabHomework = new System.Windows.Forms.TabPage();
this.btnHWSave = new System.Windows.Forms.Button();
this.btnHWGive = new System.Windows.Forms.Button();
this.btnLaunch = new System.Windows.Forms.Button(); this.btnLaunch = new System.Windows.Forms.Button();
this.btnHWDelete = new System.Windows.Forms.Button(); this.btnHWDelete = new System.Windows.Forms.Button();
this.lblHWSubmitted = new System.Windows.Forms.Label(); this.lblHWSubmitted = new System.Windows.Forms.Label();
@ -53,6 +58,8 @@
this.tbHWName = new System.Windows.Forms.TextBox(); this.tbHWName = new System.Windows.Forms.TextBox();
this.tbHWClass = new System.Windows.Forms.TextBox(); this.tbHWClass = new System.Windows.Forms.TextBox();
this.TabStudents = new System.Windows.Forms.TabPage(); this.TabStudents = new System.Windows.Forms.TabPage();
this.btnReadAllStudentHomework = new System.Windows.Forms.Button();
this.btnAllHomeworkToStudents = new System.Windows.Forms.Button();
this.TabStudent = new System.Windows.Forms.TabPage(); this.TabStudent = new System.Windows.Forms.TabPage();
this.btnStudentUpdateFile = new System.Windows.Forms.Button(); this.btnStudentUpdateFile = new System.Windows.Forms.Button();
this.btnStudentChangePassword = new System.Windows.Forms.Button(); this.btnStudentChangePassword = new System.Windows.Forms.Button();
@ -62,12 +69,6 @@
this.tbStudentUsername = new System.Windows.Forms.TextBox(); this.tbStudentUsername = new System.Windows.Forms.TextBox();
this.tvClasswork = new System.Windows.Forms.TreeView(); this.tvClasswork = new System.Windows.Forms.TreeView();
this.btnExit = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button();
this.btnGenerateStudentFiles = new System.Windows.Forms.Button();
this.btnHWGive = new System.Windows.Forms.Button();
this.btnHWSave = new System.Windows.Forms.Button();
this.btnAllHomeworkToStudents = new System.Windows.Forms.Button();
this.btnExportHomework = new System.Windows.Forms.Button();
this.btnReadAllStudentHomework = new System.Windows.Forms.Button();
this.tcTabControl.SuspendLayout(); this.tcTabControl.SuspendLayout();
this.TabProfile.SuspendLayout(); this.TabProfile.SuspendLayout();
this.TabClasswork.SuspendLayout(); this.TabClasswork.SuspendLayout();
@ -176,6 +177,7 @@
// //
// tabClass // tabClass
// //
this.tabClass.Controls.Add(this.btnExportStudentPasswords);
this.tabClass.Controls.Add(this.btnExportHomework); this.tabClass.Controls.Add(this.btnExportHomework);
this.tabClass.Controls.Add(this.btnGenerateStudentFiles); this.tabClass.Controls.Add(this.btnGenerateStudentFiles);
this.tabClass.Controls.Add(this.btnImportStudents); this.tabClass.Controls.Add(this.btnImportStudents);
@ -187,6 +189,36 @@
this.tabClass.Text = "Class"; this.tabClass.Text = "Class";
this.tabClass.UseVisualStyleBackColor = true; this.tabClass.UseVisualStyleBackColor = true;
// //
// btnExportStudentPasswords
//
this.btnExportStudentPasswords.Location = new System.Drawing.Point(6, 93);
this.btnExportStudentPasswords.Name = "btnExportStudentPasswords";
this.btnExportStudentPasswords.Size = new System.Drawing.Size(152, 23);
this.btnExportStudentPasswords.TabIndex = 9;
this.btnExportStudentPasswords.Text = "Export Passwords";
this.btnExportStudentPasswords.UseVisualStyleBackColor = true;
this.btnExportStudentPasswords.Click += new System.EventHandler(this.btnExportStudentPasswords_Click);
//
// btnExportHomework
//
this.btnExportHomework.Location = new System.Drawing.Point(6, 64);
this.btnExportHomework.Name = "btnExportHomework";
this.btnExportHomework.Size = new System.Drawing.Size(152, 23);
this.btnExportHomework.TabIndex = 8;
this.btnExportHomework.Text = "Export Homework";
this.btnExportHomework.UseVisualStyleBackColor = true;
this.btnExportHomework.Click += new System.EventHandler(this.btnExportHomework_Click);
//
// btnGenerateStudentFiles
//
this.btnGenerateStudentFiles.Location = new System.Drawing.Point(6, 35);
this.btnGenerateStudentFiles.Name = "btnGenerateStudentFiles";
this.btnGenerateStudentFiles.Size = new System.Drawing.Size(152, 23);
this.btnGenerateStudentFiles.TabIndex = 3;
this.btnGenerateStudentFiles.Text = "Generate Files";
this.btnGenerateStudentFiles.UseVisualStyleBackColor = true;
this.btnGenerateStudentFiles.Click += new System.EventHandler(this.btnGenerateStudentFiles_Click);
//
// btnImportStudents // btnImportStudents
// //
this.btnImportStudents.Location = new System.Drawing.Point(6, 6); this.btnImportStudents.Location = new System.Drawing.Point(6, 6);
@ -221,6 +253,26 @@
this.TabHomework.Text = "Homework"; this.TabHomework.Text = "Homework";
this.TabHomework.UseVisualStyleBackColor = true; this.TabHomework.UseVisualStyleBackColor = true;
// //
// btnHWSave
//
this.btnHWSave.Location = new System.Drawing.Point(91, 177);
this.btnHWSave.Name = "btnHWSave";
this.btnHWSave.Size = new System.Drawing.Size(75, 23);
this.btnHWSave.TabIndex = 13;
this.btnHWSave.Text = "Save";
this.btnHWSave.UseVisualStyleBackColor = true;
this.btnHWSave.Click += new System.EventHandler(this.btnHWSave_Click);
//
// btnHWGive
//
this.btnHWGive.Location = new System.Drawing.Point(172, 148);
this.btnHWGive.Name = "btnHWGive";
this.btnHWGive.Size = new System.Drawing.Size(75, 23);
this.btnHWGive.TabIndex = 12;
this.btnHWGive.Text = "Give";
this.btnHWGive.UseVisualStyleBackColor = true;
this.btnHWGive.Click += new System.EventHandler(this.btnHWGive_Click);
//
// btnLaunch // btnLaunch
// //
this.btnLaunch.Location = new System.Drawing.Point(91, 148); this.btnLaunch.Location = new System.Drawing.Point(91, 148);
@ -335,6 +387,26 @@
this.TabStudents.Text = "Students"; this.TabStudents.Text = "Students";
this.TabStudents.UseVisualStyleBackColor = true; this.TabStudents.UseVisualStyleBackColor = true;
// //
// btnReadAllStudentHomework
//
this.btnReadAllStudentHomework.Location = new System.Drawing.Point(23, 68);
this.btnReadAllStudentHomework.Name = "btnReadAllStudentHomework";
this.btnReadAllStudentHomework.Size = new System.Drawing.Size(207, 23);
this.btnReadAllStudentHomework.TabIndex = 7;
this.btnReadAllStudentHomework.Text = "Read in Student Homework";
this.btnReadAllStudentHomework.UseVisualStyleBackColor = true;
this.btnReadAllStudentHomework.Click += new System.EventHandler(this.btnReadAllStudentHomework_Click);
//
// btnAllHomeworkToStudents
//
this.btnAllHomeworkToStudents.Location = new System.Drawing.Point(23, 29);
this.btnAllHomeworkToStudents.Name = "btnAllHomeworkToStudents";
this.btnAllHomeworkToStudents.Size = new System.Drawing.Size(207, 23);
this.btnAllHomeworkToStudents.TabIndex = 6;
this.btnAllHomeworkToStudents.Text = "All Homework To Students";
this.btnAllHomeworkToStudents.UseVisualStyleBackColor = true;
this.btnAllHomeworkToStudents.Click += new System.EventHandler(this.btnAllHomeworkToStudents_Click);
//
// TabStudent // TabStudent
// //
this.TabStudent.Controls.Add(this.btnStudentUpdateFile); this.TabStudent.Controls.Add(this.btnStudentUpdateFile);
@ -424,66 +496,6 @@
this.btnExit.UseVisualStyleBackColor = true; this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click); this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
// //
// btnGenerateStudentFiles
//
this.btnGenerateStudentFiles.Location = new System.Drawing.Point(6, 35);
this.btnGenerateStudentFiles.Name = "btnGenerateStudentFiles";
this.btnGenerateStudentFiles.Size = new System.Drawing.Size(152, 23);
this.btnGenerateStudentFiles.TabIndex = 3;
this.btnGenerateStudentFiles.Text = "Generate Files";
this.btnGenerateStudentFiles.UseVisualStyleBackColor = true;
this.btnGenerateStudentFiles.Click += new System.EventHandler(this.btnGenerateStudentFiles_Click);
//
// btnHWGive
//
this.btnHWGive.Location = new System.Drawing.Point(172, 148);
this.btnHWGive.Name = "btnHWGive";
this.btnHWGive.Size = new System.Drawing.Size(75, 23);
this.btnHWGive.TabIndex = 12;
this.btnHWGive.Text = "Give";
this.btnHWGive.UseVisualStyleBackColor = true;
this.btnHWGive.Click += new System.EventHandler(this.btnHWGive_Click);
//
// btnHWSave
//
this.btnHWSave.Location = new System.Drawing.Point(91, 177);
this.btnHWSave.Name = "btnHWSave";
this.btnHWSave.Size = new System.Drawing.Size(75, 23);
this.btnHWSave.TabIndex = 13;
this.btnHWSave.Text = "Save";
this.btnHWSave.UseVisualStyleBackColor = true;
this.btnHWSave.Click += new System.EventHandler(this.btnHWSave_Click);
//
// btnAllHomeworkToStudents
//
this.btnAllHomeworkToStudents.Location = new System.Drawing.Point(23, 29);
this.btnAllHomeworkToStudents.Name = "btnAllHomeworkToStudents";
this.btnAllHomeworkToStudents.Size = new System.Drawing.Size(207, 23);
this.btnAllHomeworkToStudents.TabIndex = 6;
this.btnAllHomeworkToStudents.Text = "All Homework To Students";
this.btnAllHomeworkToStudents.UseVisualStyleBackColor = true;
this.btnAllHomeworkToStudents.Click += new System.EventHandler(this.btnAllHomeworkToStudents_Click);
//
// btnExportHomework
//
this.btnExportHomework.Location = new System.Drawing.Point(6, 64);
this.btnExportHomework.Name = "btnExportHomework";
this.btnExportHomework.Size = new System.Drawing.Size(152, 23);
this.btnExportHomework.TabIndex = 8;
this.btnExportHomework.Text = "Export Homework";
this.btnExportHomework.UseVisualStyleBackColor = true;
this.btnExportHomework.Click += new System.EventHandler(this.btnExportHomework_Click);
//
// btnReadAllStudentHomework
//
this.btnReadAllStudentHomework.Location = new System.Drawing.Point(23, 68);
this.btnReadAllStudentHomework.Name = "btnReadAllStudentHomework";
this.btnReadAllStudentHomework.Size = new System.Drawing.Size(207, 23);
this.btnReadAllStudentHomework.TabIndex = 7;
this.btnReadAllStudentHomework.Text = "Read in Student Homework";
this.btnReadAllStudentHomework.UseVisualStyleBackColor = true;
this.btnReadAllStudentHomework.Click += new System.EventHandler(this.btnReadAllStudentHomework_Click);
//
// PersonProfileForm // PersonProfileForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@ -551,5 +563,6 @@
private System.Windows.Forms.Button btnExportHomework; private System.Windows.Forms.Button btnExportHomework;
private System.Windows.Forms.Button btnAllHomeworkToStudents; private System.Windows.Forms.Button btnAllHomeworkToStudents;
private System.Windows.Forms.Button btnReadAllStudentHomework; private System.Windows.Forms.Button btnReadAllStudentHomework;
private System.Windows.Forms.Button btnExportStudentPasswords;
} }
} }

View File

@ -149,7 +149,7 @@ namespace EduNetworkBuilder
private void DtpHWDue_LostFocus(object sender, EventArgs e) private void DtpHWDue_LostFocus(object sender, EventArgs e)
{ {
throw new NotImplementedException();
} }
public PersonClass Edit() public PersonClass Edit()
@ -961,5 +961,44 @@ namespace EduNetworkBuilder
"\n\t" + NumStudentsNoSubmissions, "\n\t" + NumStudentsNoFiles, "\n\t" + NumStudentsNoSubmissions, "\n\t" + NumStudentsNoFiles,
"\n\t" + NumErrorFiles)); "\n\t" + NumErrorFiles));
} }
private void WriteStudentCSVFile(string path)
{
try
{
using (var w = new StreamWriter(path))
{
foreach (PersonClass pc in CurrentUser.Students)
{
string UName = NB.CSVSafeString(pc.UserName);
string FName = NB.CSVSafeString(pc.FullName);
string Pass = NB.CSVSafeString(pc.Password);
var line = string.Format("{0},{1},{2}", UName, FName, Pass);
w.WriteLine(line);
w.Flush();
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
private void btnExportStudentPasswords_Click(object sender, EventArgs e)
{
SaveFileDialog mydialog = new SaveFileDialog();
mydialog.AddExtension = true;
string filter = "Comma Separated List (*.csv)|*.csv";
mydialog.Filter = filter;
mydialog.CheckFileExists = false;
mydialog.ShowHelp = true;
if (CurrentUser.UserSettings.LastPath != null && CurrentUser.UserSettings.LastPath != "")
mydialog.FileName = CurrentUser.UserSettings.LastPath;
DialogResult result = mydialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel) return;
WriteStudentCSVFile(mydialog.FileName);
}
} }
} }