Example #1
0
    int CountCorrectItems(int currentQuestion)
    {
        TriviaQuestion tq = questionMap[currentQuestion];
        //int numNeeded = tq.numAnswersNeeded;
        int numCorrect = 0, numFalse = 0;

        foreach (var button in textButtons)
        {
            AnswerButton ab = button.GetComponent <AnswerButton>();
            if (ab.gameObject.activeSelf == false)
            {
                continue;
            }

            string answer = ab.Answer;
            if (ab.isSelected == true)
            {
                if (Utils.IsInList(answer, tq.correctAnswers))
                {
                    numCorrect++;
                }
                else if (Utils.IsInList(answer, tq.falseAnswers) == true)
                {
                    numFalse++;
                    ab.ShowIncorrectOverlay();
                }
            }
            else
            {
                /// if is correct answer but missed...
                if (Utils.IsInList(answer, tq.correctAnswers))
                {
                    ab.ShowCorrectOverlay();
                }
            }
        }

        foreach (var button in imageButtons)

        {
            AnswerButton ab = button.GetComponent <AnswerButton>();
            if (ab.gameObject.activeSelf == false)
            {
                continue;
            }
            if (ab.isSelected == true) // && ab.isCorrectAnswer)
            {
                if (ab.isCorrectAnswer == true)
                {
                    numCorrect++;
                }
                else
                {
                    numFalse++;
                    ab.ShowIncorrectOverlay();
                }
            }
            else
            {
                if (ab.isCorrectAnswer == true)
                {
                    ab.ShowCorrectOverlay();
                }
            }

            /*
             * else
             * {
             *
             *  ab.ShowIncorrectOverlay();
             * }
             */
        }
        return(numCorrect);
    }