Example #1
0
        private async Task <Guid> CreateTestFlowAsync()
        {
            string testName              = SharedConsoleFlows.AskForString("What is the name of the test?");
            byte   numberOfVersions      = SharedConsoleFlows.AskForByte("How many versions are there?");
            byte   minimumGrade          = SharedConsoleFlows.AskForByte("What is the minimum grade?");
            byte   standardizationFactor = SharedConsoleFlows.AskForByte("What is the standardization factor?");

            var createTestRequest = new CreateTestRequest()
            {
                Name                  = testName,
                MinimumGrade          = minimumGrade,
                StandardizationFactor = standardizationFactor,
                NumberOfVersions      = numberOfVersions
            };
            CreateTestResult createTestResponse = await _testController.CreateTestAsync(createTestRequest);

            Guid testId = createTestResponse.TestId;

            if (createTestResponse.ValidationMessages.Any())
            {
                SharedConsoleFlows.PrintValidationMessages(createTestResponse.ValidationMessages);
                testId = await CreateTestFlowAsync();
            }
            return(testId);
        }
Example #2
0
        private async Task AddAssignmentsFlowAsync(Guid testId)
        {
            byte numberOfAssignments = SharedConsoleFlows.AskForByte("How many normal assignments are there?");

            for (int assignmentIndex = 0; assignmentIndex < numberOfAssignments; assignmentIndex++)
            {
                await AddAssignmentFlowAsync(testId, assignmentIndex);
            }
        }
        private async Task AddStudentsFlowAsync(Guid classId)
        {
            await AddStudentFlowAsync(classId);

            bool addAnotherStudent = SharedConsoleFlows.AskForBool("Add another student?");

            if (addAnotherStudent)
            {
                await AddStudentsFlowAsync(classId);
            }
        }
        private async Task CreateClassFromFile(IFileInfoWrapper[] files)
        {
            byte             chosenIndex = SharedConsoleFlows.AskForByte("What file should be used?");
            IFileInfoWrapper chosenFile  = await GetFile(files, chosenIndex);

            var request = new CreateMagisterClassRequest
            {
                MagisterFileLocation = chosenFile.FullName
            };
            CreateMagisterClassResult createMagisterClassResponse = await _classController.CreateMagisterClassAsync(request);

            if (createMagisterClassResponse.ValidationMessages.Any())
            {
                SharedConsoleFlows.PrintValidationMessages(createMagisterClassResponse.ValidationMessages);
                await StartAsync();
            }
        }
Example #5
0
        private async Task AddAssignmentFlowAsync(Guid testId, int assignmentIndex)
        {
            byte numberOfQuestions = SharedConsoleFlows.AskForByte($"How many questions are there for assignment: {assignmentIndex + 1}?");

            var addAssignmentRequest = new AddAssignmentRequest
            {
                TestId            = testId,
                NumberOfQuestions = numberOfQuestions
            };

            AddAssignmentResult addAssignmentResult = await _testController.AddAssignmentAsync(addAssignmentRequest);

            if (addAssignmentResult.ValidationMessages.Any())
            {
                SharedConsoleFlows.PrintValidationMessages(addAssignmentResult.ValidationMessages);
                await AddAssignmentFlowAsync(testId, assignmentIndex);
            }
        }
        private async Task <Guid> CreateClassFlowAsync()
        {
            Console.WriteLine("What is the name of the class?");
            string className          = Console.ReadLine();
            var    createClassRequest = new CreateClassRequest()
            {
                Name = className
            };
            CreateClassResult createClassResponse = await _classController.CreateClassAsync(createClassRequest);

            Guid classId = createClassResponse.ClassId;

            if (createClassResponse.ValidationMessages.Any())
            {
                SharedConsoleFlows.PrintValidationMessages(createClassResponse.ValidationMessages);
                classId = await CreateClassFlowAsync();
            }
            return(classId);
        }
        public async Task StartAsync()
        {
            Console.Clear();
            IDirectoryInfoWrapper directory = _directoryInfoWrapperFactory.Create(_magisterDirectoryLocation);

            IFileInfoWrapper[] files = directory.GetFiles();

            if (files.Any())
            {
                PrintAvailableFiles(files);
                await CreateClassFromFile(files);
            }
            else
            {
                Console.WriteLine("No magister files present. Add a file into the folder:");
                Console.WriteLine(_magisterDirectoryLocation.Value);
                SharedConsoleFlows.AskForAnyKey("Press any key to go back.");
            }
        }
        private async Task AddStudentFlowAsync(Guid classId)
        {
            string firstName = SharedConsoleFlows.AskForString("What is the first name of the student?");
            string infix     = SharedConsoleFlows.AskForOptionalString("What is the infix of the student?");
            string lastName  = SharedConsoleFlows.AskForString("What is the last name of the student?");
            var    model     = new AddStudentRequest
            {
                ClassId   = classId,
                FirstName = firstName,
                Infix     = infix,
                LastName  = lastName
            };
            AddStudentResult addStudentResponse = await _classController.AddStudentAsync(model);

            if (addStudentResponse.ValidationMessages.Any())
            {
                SharedConsoleFlows.PrintValidationMessages(addStudentResponse.ValidationMessages);
                await AddStudentFlowAsync(classId);
            }
        }
Example #9
0
        private async Task AddBonusAssignmentFlowAsync(Guid testId)
        {
            bool isBonusAssignmentNeeded = SharedConsoleFlows.AskForBool($"Is there a bonus question?");

            if (isBonusAssignmentNeeded)
            {
                var addAssignmentRequest = new AddAssignmentRequest
                {
                    TestId            = testId,
                    NumberOfQuestions = 1
                };

                AddAssignmentResult addAssignmentResult = await _testController.AddAssignmentAsync(addAssignmentRequest);

                if (addAssignmentResult.ValidationMessages.Any())
                {
                    SharedConsoleFlows.PrintValidationMessages(addAssignmentResult.ValidationMessages);
                }
            }
        }
Example #10
0
        private async Task <Cifra.Application.Models.Test.Test> AskForTestAsync()
        {
            Console.Clear();
            Console.WriteLine("The following tests exist:");
            var result = await _testController.GetTestsAsync();

            int index = 1;

            foreach (var @test in result.Tests)
            {
                Console.WriteLine($"[{index}] {test.Name.Value}");
                index++;
            }
            var chosenIndex = SharedConsoleFlows.AskForByte("Select one of the following tests, type a number");
            var chosenTest  = result.Tests.ElementAtOrDefault(chosenIndex - 1);

            if (chosenTest == null)
            {
                Console.WriteLine("Invalid choice!");
                return(await AskForTestAsync());
            }
            return(chosenTest);
        }
Example #11
0
        /// <inheritdoc/>
        public async Task StartAsync()
        {
            Console.Clear();
            Cifra.Application.Models.Class.Class chosenClass = await AskForClassAsync();

            Cifra.Application.Models.Test.Test chosenTest = await AskForTestAsync();

            Console.Clear();
            string fileName = SharedConsoleFlows.AskForString("What should be the name of the spreadsheet?");

            SaveResult saveResult = await BuildSpreadsheetAsync(chosenClass, chosenTest, fileName);

            if (saveResult.IsSuccess)
            {
                Console.WriteLine("File successfully saved.");
                SharedConsoleFlows.AskForAnyKey("Press any key to go back");
            }
            else
            {
                Console.WriteLine("File not saved due to an error.");
                SharedConsoleFlows.AskForAnyKey("Press any key to go back");
            }
        }
Example #12
0
        private async Task <Cifra.Application.Models.Class.Class> AskForClassAsync()
        {
            Console.Clear();
            Console.WriteLine("The following classes exist:");
            GetAllClassesResult result = await _classController.GetClassesAsync();

            int index = 1;

            foreach (var @class in result.Classes)
            {
                Console.WriteLine($"[{index}] {@class.Name.Value}");
                index++;
            }
            Console.WriteLine();
            var chosenIndex = SharedConsoleFlows.AskForByte("Select one of the following classes, type a number");
            var chosenClass = result.Classes.ElementAtOrDefault(chosenIndex - 1);

            if (chosenClass == null)
            {
                Console.WriteLine("Invalid choice!");
                return(await AskForClassAsync());
            }
            return(chosenClass);
        }