async Task answerQuestion(TestAnswerPostModel answerModel, bool isAuto = false) { try { if (answerModel == null || answerModel.Answers == null || answerModel.Answers.Count == 0) { _services.Dialogs.ShowError(CrossLocalization.Translate("answer_question_not_selected_error")); return; } await DataAccess.AnswerQuestionAndGetNext(answerModel); if (DataAccess.IsError) { _services.Dialogs.ShowError(DataAccess.ErrorMessage); return; } if (!isAuto) { _questionsLeft--; } await getAndSetQuestion(getNextQuestion()); } catch (Exception ex) { AppLogs.Log(ex); } }
async Task answerQuestion(bool isAuto = false) { try { setLoading(true); TestAnswerPostModel postModel = null; switch (_questionType) { case 0: case 1: postModel = getSelectedAnswer(isAuto); break; case 2: postModel = getEditableAnswer(isAuto); break; case 3: postModel = getMovableAnswer(); break; } await answerQuestion(postModel, isAuto); setLoading(false); } catch (Exception ex) { AppLogs.Log(ex); } }
/// <summary> /// Answer question callback. /// </summary> /// <param name="answer">Answer model.</param> /// <returns>String. <c>"Ok"</c>, for example.</returns> static async Task <object> answerQuestionCallback( TestAnswerPostModel answer) => await AppServices.AnswerQuestionAndGetNext(answer);
/// <summary> /// Answer question. /// </summary> /// <param name="answer">Answer data.</param> /// <returns>String. <c>"Ok"</c>, for example.</returns> public async static Task <object> AnswerQuestionAndGetNext(TestAnswerPostModel answer) { var dataAccess = new DataAccess <object>("answer_question_error", answerQuestionCallback(answer)); return(await GetDataObject(dataAccess, false)); }
/// <summary> /// Answer question request. /// </summary> /// <param name="answer">Answer data.</param> /// <returns>String. <c>"Ok"</c>, for example.</returns> public static async Task <object> AnswerQuestionAndGetNext(TestAnswerPostModel answer) { var body = JsonController.ConvertObjectToJson(answer); return(await AppServicesController.Request($"{Links.AnswerQuestionAndGetNext}", body)); }