public static QuestionBlank GenerateBlank(QuestionBank bank, int kol) { var GenRand = new double[kol]; var res = new QuestionBlank(); for (int i = 0; i < kol; i++) { GenRand[i] = App.Rnd.NextDouble(); } res.GenAnswer = new int[kol][]; for (int i = 0; i < kol; i++) { res.GenAnswer[i] = Globals.Randoming(3); } var tq = bank.Questions.ToArray(); Array.Sort(GenRand, tq); res.Questions = tq.Take(kol).ToArray(); return(res); }
void ITestService.Generate(string studentPath, string bankPath, string outputFolder) { Guid g; XElement xml = XElement.Load(bankPath); XElement xmlU = XElement.Load(studentPath); var grp = Grp.LoadFromXml(xmlU); var questionBank = QuestionBank.LoadFromXml(xml); var questionBLank = QuestionBlank.GenerateBlank(questionBank, 3); foreach (User student in grp.Users) { questionBLank.ForUser = student; var p = questionBLank.SavePrepottToXml(); var s = questionBLank.SaveStudentToXml(); g = Guid.NewGuid(); var XGuid = new XElement("Guid"); XGuid.Add(g); p.Add(XGuid); s.Add(XGuid); var chpath = Path.Combine(outputFolder, "Check"); var stpath = Path.Combine(outputFolder, "KR"); Directory.CreateDirectory(stpath); Directory.CreateDirectory(chpath); var chpatsh = string.Format("{0} {1} {2} CheckKR.xml", student.FName, student.IName, student.OName); var stpatsh = string.Format("{0} {1} {2} KR.xml", student.FName, student.IName, student.OName); p.Save(System.IO.Path.Combine(chpath, chpatsh)); s.Save(System.IO.Path.Combine(stpath, stpatsh)); } }