functions to make student csv file
This commit is contained in:
parent
ed48b943aa
commit
50a04dbef0
@ -1101,5 +1101,17 @@ namespace EduNetworkBuilder
|
|||||||
MessageBox.Show(Translate("NB_NotImplimented"));
|
MessageBox.Show(Translate("NB_NotImplimented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string CSVSafeString(string source)
|
||||||
|
{
|
||||||
|
string dest = source;
|
||||||
|
char[] chars = { '\t', '\r', '\n', '\"', ',' };
|
||||||
|
|
||||||
|
if (dest.IndexOfAny(chars) >= 0)
|
||||||
|
{
|
||||||
|
dest = '\"' + dest.Replace("\"", "\"\"") + '\"'; //quotes around outside, replace " with ""
|
||||||
|
}
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2055,5 +2055,28 @@ namespace EduNetworkBuilder
|
|||||||
PPF.Edit();
|
PPF.Edit();
|
||||||
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -549,7 +549,7 @@ namespace EduNetworkBuilder
|
|||||||
{
|
{
|
||||||
btnHWDelete.Visible = false; //Only the teacher can delete the homework
|
btnHWDelete.Visible = false; //Only the teacher can delete the homework
|
||||||
btnHWGive.Visible = false;
|
btnHWGive.Visible = false;
|
||||||
btnHWSave.Visible = false;
|
btnHWSave.Visible = false;
|
||||||
}
|
}
|
||||||
if(OnStudentTree)
|
if(OnStudentTree)
|
||||||
{ //We cannot give or delete submitted stuff
|
{ //We cannot give or delete submitted stuff
|
||||||
|
Loading…
Reference in New Issue
Block a user