예제 #1
0
        protected override async Task OnInitializedAsync()
        {
            var(res2, answer, _) = await ExamServices.GetAnswer("", ExamId, QuestionNum);

            Console.WriteLine(res2);
            if (res2 == ErrorCodes.Success)
            {
                _answer = answer;
                if (answer is ChoiceAnswer choiceAnswer && Question is ChoiceQuestion choiceQuestion)
                {
                    if (choiceQuestion.MultiChoice)
                    {
                        _choiceChecked = new bool[choiceQuestion.Choices.Count];
                        foreach (var i in choiceAnswer.Choices)
                        {
                            _choiceChecked[i] = true;
                        }
                    }
                    else
                    {
                        _choiceSingle = choiceAnswer.Choices[0];
                    }
                }
                else if (answer is ShortAnswer shortAnswer && Question is ShortAnswerQuestion shortAnswerQuestion)
                {
                    _answerString = shortAnswer.Answer;
                }
예제 #2
0
        protected override async Task OnInitializedAsync()
        {
            var(res, answer, time) = await ExamServices.GetAnswer(UserId, ExamId, QuestionNum);

            if (res == ErrorCodes.Success)
            {
                _answer = answer;
                _time   = time;
            }
            else if (res == ErrorCodes.QuestionNotAnswered)
            {
                _displayText = "The exam taker did not answered this question";
            }
            else
            {
                _displayText = "Error fetching answer: " + ErrorCodes.MessageMap[res];
            }
        }