Ejemplo n.º 1
0
    public void LoadQuestionAndAnswersForIndex(int arrayIndex)
    {
        respondQuizzScrollerController.Reset();
        quizzQuestion.text = _questions.GetQuestionsList()[arrayIndex].GetQuestionTitle();

        Question question = _questions.GetQuestionsList()[arrayIndex];
        Answers  answers  = GameManager.Instance.GetApiManager().GetAnswersForQuestion(this._quizz.GetQuizzId(), question.GetQuestionId());


        // Error/Exception managing
        if (question == null)
        {
            Debug.LogError("[WARNING]: questionData is null");
            PopupManager.PopupAlert("Error", "QuestionData is null (is data from API valid ?).\n" + NetworkRequestManager.lastHttpWebRequestErrorMessage, "Return to menu", GameManager.Instance.pagesManager.ShowMenuPage);
            return;
        }

        for (int answerIndex = 0; answerIndex < answers.GetAnswersList().Count; ++answerIndex)
        {
            Answer answer = answers.GetAnswersList()[answerIndex];

            Debug.Log($"answer: {answer.GetDataToShowAsPossibleAnswer()} is correct ? {answer.IsCorrectAnswer()}");

            if (answer.IsCorrectAnswer())
            {
                goodAnswer = answer.GetDataToShowAsPossibleAnswer();
            }

            respondQuizzScrollerController.AddDataToScroller(answer.Clone() as Answer);
        }

        // Error/Exception managing
        if (answers.GetAnswersList().Count == 0)
        {
            Debug.LogError("[WARNING]: No answer possible for this question");
            PopupManager.PopupAlert("Error", "No answer possible for this question", "Return to menu", GameManager.Instance.pagesManager.ShowMenuPage);
            return;
        }

        // Error/Exception managing
        if (goodAnswer == null)
        {
            Debug.LogError("[WARNING]: There is no good answer value");
            PopupManager.PopupAlert("Error", "This question can't be responded, there is no good answer value returned by API", "Return to menu", GameManager.Instance.pagesManager.ShowMenuPage);
            return;
        }
    }
Ejemplo n.º 2
0
 public void TestCloneMethod()
 {
     var testAnswer = new Answer("Test answer", true);
     Assert.IsTrue(testAnswer.Equals(testAnswer.Clone() as Answer));
 }