/// <summary>
        /// Obtains the exam details
        /// </summary>
        private async Task GetExamDetails()
        {
            var(ret, details) = await ExamServices.GetExamDetails(_examId);

            if (ret == ErrorCodes.Success)
            {
                _examDetails = details;
            }
        }
Example #2
0
        protected override async Task OnInitializedAsync()
        {
            if (!int.TryParse(ExamId, out _examId))
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Cannot get exam result",
                    Content = "Invalid examId"
                });

                return;
            }

            var(r, details) = await ExamServices.GetExamDetails(_examId);

            if (r != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Cannot get exam result",
                    Content = ErrorCodes.MessageMap[r]
                });

                return;
            }

            _examDetails = details;

            var(res, questions) = await ExamServices.GetPaper(_examId);

            if (res != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Cannot get exam result",
                    Content = ErrorCodes.MessageMap[res]
                });

                return;
            }

            _questions = questions;
            StateHasChanged();
        }
        protected override async Task OnInitializedAsync()
        {
            if (!int.TryParse(ExamId, out _examId))
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title = "Invalid exam ID"
                });

                return;
            }

            var(res, details) = await ExamServices.GetExamDetails(_examId);

            if (res != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Failed to obtain exam information",
                    Content = ErrorCodes.MessageMap[res]
                });

                return;
            }

            _model = details;

            var(res2, takers) = await ExamServices.GetTestTakers(_examId);

            if (res2 != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Failed to obtain list of exam takers",
                    Content = ErrorCodes.MessageMap[res2]
                });

                return;
            }

            _takers = takers;

            var(res3, proctors) = await ExamServices.GetProctors(_examId);

            if (res3 != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Failed to obtain list of exam proctors",
                    Content = ErrorCodes.MessageMap[res3]
                });

                return;
            }

            _proctors = proctors;

            var(res4, questions) = await ExamServices.GetPaper(_examId);

            if (res4 != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Failed to obtain questions",
                    Content = ErrorCodes.MessageMap[res4]
                });

                return;
            }

            _questions = questions;
        }