Exemplo n.º 1
0
        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);
        }
        public static QuestionBank LoadFromXml(XElement Ques)
        {
            var res = new QuestionBank();

            foreach (var ques in Ques.Elements())
            {
                res.Questions.Add(Question.LoadFromXml(ques));
            }

            return(res);
        }
Exemplo n.º 3
0
        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));
            }
        }