public static Answers KamalsAnswers() { Answers answers = new Answers(); answers.AddAnswer(KamalsGoodAnswer(UserMother.Kamal)); answers.AddAnswer(KamalsBadAnswer(UserMother.Kamal)); return answers; }
public override Answers GetAnswersForQuestion(object quizzId, object questionId) { string json_quizzes_with_questions_with_answers = NetworkRequestManager.HttpGetRequest(apiAnswersUrl); CheckIfNullAndLog(json_quizzes_with_questions_with_answers, $"[WARNING]: Response for {GetActualMethodName()} is null"); DardiNestedApiModel.QuizzesInAPI quizzesData = JsonUtility.FromJson <DardiNestedApiModel.QuizzesInAPI>(json_quizzes_with_questions_with_answers); Answers answers = new Answers(); foreach (QuizzInAPI quizzData in quizzesData.quizzes) { if (quizzData.id.ToString() == quizzId.ToString()) { foreach (QuestionInAPI questionData in quizzData.questions) { if (questionData.id.ToString() == questionId.ToString()) { foreach (DardiNestedApiModel.AnswerInAPI answerData in questionData.answers) { answerData.MapAPIValuesToAbstractClass(); answers.AddAnswer(answerData); } return(answers); } } } } return(null); }
public override Answers GetAnswersForQuestion(object quizzId, object questionId) { // Replace {quizzId} and {questionid} in the link base.apiAnswersUrl = base._originalApiAnswersUrl.Replace("{quizzId}", quizzId.ToString()).Replace("{questionId}", questionId.ToString()); string json_questions_with_answers = NetworkRequestManager.HttpGetRequest(apiAnswersUrl); CheckIfNullAndLog(json_questions_with_answers, $"[WARNING]: Response for {GetActualMethodName()} is null"); KwizApiModel.QuestionsInAPI questionsData = JsonUtility.FromJson <KwizApiModel.QuestionsInAPI>(json_questions_with_answers); Answers answers = new Answers(); // Let's begin to search the questionId we need in this case foreach (QuestionInAPI questionData in questionsData.data) { Debug.Log(questionId); if (questionId.ToString() == questionData.id.ToString()) { // Now that we found the question with the questionId we need, let's get all answers foreach (AnswerInAPI answerData in questionData.answers) { answerData.MapAPIValuesToAbstractClass(); answers.AddAnswer(answerData); } return(answers); } } return(null); }