private async Task GetQuestions() { var(res, questions) = await ExamServices.GetPaper(_examId); if (res == ErrorCodes.ExamNotBegin) { // If the exam not begin, display the count down _examNotBegin = true; } else if (res == ErrorCodes.Success) { _examNotBegin = false; _questions = questions; } StateHasChanged(); }
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; }
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(); }