Пример #1
0
    public void CheckAnswer() // Match the given answer to the expected answer, and send "true" if correct
    {
        bool   correct = false;
        string givenAnswer;

        if ((multipleChoiceToggle.isOn && chosenAnswer == correctAnswer) || (answerInput.text == dataList[selection].answer)) // If looking for multiple choice & correct
        {
            correct = true;


            resultGUIResult.text = "Correct!";
            resultGUIAnswer.text = "";
        }
        else
        {
            resultGUIResult.text = "Incorrect.";
            resultGUIAnswer.text = "The answer was: " + dataList[selection].answer;
        }

        if (multipleChoiceToggle.isOn)
        {
            givenAnswer = multipleChoices[chosenAnswer].GetComponentInChildren <Text>().text;
        }
        else
        {
            givenAnswer = answerInput.text;
        }

        Card_Handler.Card currentContent = deck_handler.dataList[deck_handler.selection].content[selection];

        markList[selection] = new Mark(currentContent.question, currentContent.answer, givenAnswer, correct, false); // Record Result
        resultGUI.SetActive(true);
    }
Пример #2
0
    // Functions
    public void LoadPracticeDeck() // Start a practice session with the selected deck and settings
    {
        colourIndicator.GetComponent <Image>().material = colourOptions[deck_handler.dataList[deck_handler.selection].colour];
        if (shuffleToggle.isOn) // if shuffling deck
        {
            dataList      = new List <Card_Handler.Card>(deck_handler.dataList[deck_handler.selection].content);
            markListIndex = new int[dataList.Count];

            for (int i = 0; i < dataList.Count; i++)
            {
                Card_Handler.Card temp1 = dataList[i];
                int temp2 = markListIndex[i];

                int randomIndex = UnityEngine.Random.Range(i, dataList.Count);

                dataList[i]           = dataList[randomIndex];
                dataList[randomIndex] = temp1;

                markListIndex[i]           = randomIndex;
                markListIndex[randomIndex] = temp2;
            }
        }
        else
        {
            dataList = deck_handler.dataList[deck_handler.selection].content;
        }

        if (multipleChoiceToggle.isOn) // If using multiple choice
        {
            multipleChoiceWindow.gameObject.SetActive(true);
            answerInput.gameObject.SetActive(false);
        }
        else
        {
            multipleChoiceWindow.gameObject.SetActive(false);
            answerInput.gameObject.SetActive(true);
        }

        //Empty the list
        markList = new Mark[dataList.Count];

        deckTitle.text = deck_handler.dataList[deck_handler.selection].title;
        LoadPracticeCard(-1);
    }