Пример #1
0
        private async Task HandleUpdateBasicInfo()
        {
            var res = await ExamServices.UpdateExamDetails(_updateExamDetailsModel);

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

                return;
            }

            await Message.Success("Exam information updated");

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

            if (res2 == ErrorCodes.Success)
            {
                var secs    = details.Duration;
                var hours   = secs / 3600;
                var minutes = (secs - hours * 3600) / 60;
                var seconds = secs - minutes * 60 - hours * 3600;

                _updateExamDetailsModel.Name             = details.Name;
                _updateExamDetailsModel.Description      = details.Description;
                _updateExamDetailsModel.StartTime        = details.StartTime;
                _updateExamDetailsModel.Duration         = new DateTime(1999, 04, 27, 10, minutes, seconds);
                _updateExamDetailsModel.OpenBook         = details.OpenBook;
                _updateExamDetailsModel.MaximumTakersNum = details.MaxTakers;
            }
        }
Пример #2
0
        /// <summary>
        /// Obtains the exam details
        /// </summary>
        private async Task GetExamDetails()
        {
            var(ret, details) = await ExamServices.GetExamDetails(_examId);

            if (ret == ErrorCodes.Success)
            {
                _examDetails = details;
            }
        }
Пример #3
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();
        }
Пример #4
0
        private async Task OnJoinExam()
        {
            var(res, details) = await ExamServices.GetExamDetails(_examIdToJoin);

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

                return;
            }

            var confirm = await Modal.ConfirmAsync(new ConfirmOptions()
            {
                Title   = "Confirm to join exam",
                Content = RenderExamDescription(details)
            });

            if (confirm)
            {
                var(re, banReason) = await ExamServices.JoinExam(_examIdToJoin);

                if (re != ErrorCodes.Success)
                {
                    await Modal.ErrorAsync(new ConfirmOptions()
                    {
                        Title   = "Cannot join the exam",
                        Content = ErrorCodes.MessageMap[re] + (banReason == null ? "" : " Reason: " + banReason)
                    });

                    return;
                }

                await Modal.SuccessAsync(new ConfirmOptions()
                {
                    Content = "You have successfully joined the exam."
                });
            }

            _joinExamModalVisible = false;
        }
Пример #5
0
        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;
        }
Пример #6
0
        protected override async Task OnInitializedAsync()
        {
            if (!int.TryParse(ExamId, out _examId))
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Cannot obtain exam information",
                    Content = "Invalid exam ID"
                });

                return;
            }

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

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

                if (res == ErrorCodes.NotLoggedIn)
                {
                    NavManager.NavigateTo("/User/Login");
                }

                return;
            }

            var secs    = details.Duration;
            var hours   = secs / 3600;
            var minutes = (secs - hours * 3600) / 60;
            var seconds = secs - minutes * 60 - hours * 3600;

            _updateExamDetailsModel.Id               = _examId;
            _updateExamDetailsModel.Name             = details.Name;
            _updateExamDetailsModel.Description      = details.Description;
            _updateExamDetailsModel.StartTime        = details.StartTime;
            _updateExamDetailsModel.Duration         = new DateTime(1999, 04, 27, hours, minutes, seconds);
            _updateExamDetailsModel.OpenBook         = details.OpenBook;
            _updateExamDetailsModel.MaximumTakersNum = details.MaxTakers;

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

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

                return;
            }

            _questions       = questions;
            _questionEditors = new QuestionEditor[_questions.Count];
            StateHasChanged();
        }