Example #1
0
        private void AddNewInfos(string path, DateTime passingTime)
        {
            string testName = GetLastPathPart(path);

            foreach (string classFolderPath in Directory.GetDirectories(path))
            {
                string className = GetLastPathPart(classFolderPath);

                foreach (string pupilFilePath in Directory.GetFiles(classFolderPath, "*.txt"))
                {
                    string pupilFileName = GetLastPathPart(pupilFilePath);

                    int    spaceIndex = pupilFileName.IndexOf(' ');
                    int    pointIndex = pupilFileName.IndexOf('.');
                    string lastName   = pupilFileName.Substring(0, spaceIndex);
                    string firstName  = pupilFileName.Substring(spaceIndex + 1, pointIndex - spaceIndex - 1);
                    string result     = File.ReadAllText(pupilFilePath);

                    int            classId        = _classEngine.GetClassId(className);
                    int            pupilId        = _pupilEngine.GetPupilId(firstName, lastName);
                    var            classInfo      = new ClassInfo(classId, className, string.Empty);
                    var            pupilInfo      = new PupilInfo(pupilId, firstName, lastName, classId);
                    AnxietyResults anxietyResults = _anxietyTestResultMaker.MakeResults(result);
                    var            testResultInfo = new TestResultInfo(_testResultEngine.GetNextTestResultId(), testName, pupilId, result, passingTime, _anxietyTestResultMaker.DoesHighAnxietyExist(anxietyResults), classId, string.Empty);

                    _classEngine.AddClassInfoSorted(classInfo);
                    _pupilEngine.AddPupilInfoSorted(pupilInfo);
                    _testResultEngine.AddTestResultInfoSorted(testResultInfo);
                }
            }
        }