Example #1
0
    public void saveQuiz()
    {
        if (unfinishedQuiz.Count > 0)
        {
            string[] none = new string[3] {
                "", "", ""
            };
            if (quizTitle.text == "")
            {
                //Debug.Log("Invalid quiz name");
                showErrorBox("Enter a quiz name.");
                return;
            }
            FXplayer.fxplayer.PlayFX(fxOptions.tap);

            Question title = new Question(quizTitle.text, none, -1);    // adding one more Question that holds the name of the quiz, this is not an actual question
            unfinishedQuiz.Add(title);

            //SaveLoad.SaveQuizSet(unfinishedQuiz);
            QuizContainer newQuiz = new QuizContainer(unfinishedQuiz);
            gm.addQuizToSave(newQuiz);

            resetMenus();
            backToMain();
        }
        else
        {
            //Debug.Log("Input more questions!");
            showErrorBox("Input more questions!");
        }
    }
    public static QuizContainer Load(string path)
    {
        var           serializer   = new XmlSerializer(typeof(QuizContainer));
        QuizContainer deserialized = null;
        string        path2;

#if WINDOWS_UWP
        path2 = Path.GetFullPath(Path.Combine(Application.persistentDataPath + "/" + "data.xml"));
        try
        {
            using (FileStream reader = File.Open(path2, FileMode.Open))
            {
                return(serializer.Deserialize(reader) as QuizContainer);
            }
        }
        catch (System.Exception e)
        {
            //Debug.LogWarningFormat("Error loading animation : {0}", e.Message);
            return(deserialized);
        }
#else
        using (var stream = new FileStream(path, FileMode.Open))
        {
            return(serializer.Deserialize(stream) as QuizContainer);
        }
#endif
    }
Example #3
0
    void deleteQuiz()
    {
        if (editedQuiz != null)
        {
            int index = gm.quizStorage.IndexOf(editedQuiz);
            gm.RemoveQuizButton(index);

            gm.quizStorage.Remove(editedQuiz);
            SaveLoad.SaveQuizSet(gm.quizStorage);
            editedQuiz = null;
            return;
        }// else it should be removed by simply resetting everything, already done
    }
Example #4
0
 void resetMenus()
 {
     //reset stuff
     quizTitle.text = "";
     foreach (QuestionButton a in buttonLayoutGroup.transform.GetComponentsInChildren <QuestionButton>())
     {
         Destroy(a.gameObject);
     }
     unfinishedQuiz = new List <Question>();
     confirmDeleteBox.SetActive(false);
     questionTxt.transform.parent.gameObject.SetActive(false);
     buttonLayoutGroup.transform.parent.gameObject.SetActive(false);
     editedQuiz = null;
 }
Example #5
0
 public void addQuizToSave(QuizContainer newQuiz)
 {
     if (quizStorage.Count > chosenQuiz && chosenQuiz != -1)
     {
         quizStorage[chosenQuiz] = newQuiz;
         quizButtons[chosenQuiz].transform.GetChild(0).GetComponent <TMP_Text>().text = quizStorage[chosenQuiz].container[quizStorage[chosenQuiz].container.Count - 1].question;
     }
     else
     {
         quizStorage.Add(newQuiz);
         AddQuizButton();
     }
     SaveLoad.SaveQuizSet(quizStorage);
 }
Example #6
0
    public void Load(string file)
    {
        quizContainer = XmlIO.LoadXml <QuizContainer>(file);

        AddQuizTimeRecToDict();

        AddQuizTimeAtkToDict();

        AddLinkQuizToDict();

        AddOptQuizToDict();

        AddImgOptQuizToDict();

        AddTyping1QuizToDict();

        AddTyping2QuizToDict();
    }
    void populateQuiz()
    {
        var QuizPageCollection = QuizContainer.Load(Path.Combine(Application.dataPath, "Resources/data.xml"));

        foreach (QuizPage page in QuizPageCollection.Pages)
        {
            GameObject myPage = Instantiate(quizPrefab, new Vector3(0, 0, 0), Quaternion.identity); //create new quizPage instant

            myPage.transform.parent = quiz.transform;                                               //make this child to Quiz in hierarchy
                                                                                                    //populate it with data from QuizPageCollection

            //add question
            myPage.transform.Find("question").GetComponent <TextMeshPro>().text = page.question;

            //pass page number & correct answer to the Controller
            myPage.transform.GetComponent <QuizPageController>().number  = page.number;
            myPage.transform.GetComponent <QuizPageController>().correct = page.correct;
            myPage.name = "Page" + page.number;

            //add image
            string       ImageName = page.image + "Front";
            MeshRenderer mr        = myPage.transform.Find("BigCapsule").GetComponent <MeshRenderer>();
            mr.material = Resources.Load(page.image, typeof(Material)) as Material;
            myPage.gameObject.SetActive(false);

            //populate answers
            myPage.transform.Find("answer1").GetComponent <TextMeshPro>().text = page.answer1;
            myPage.transform.Find("answer2").GetComponent <TextMeshPro>().text = page.answer2;
            myPage.transform.Find("answer3").GetComponent <TextMeshPro>().text = page.answer3;
            myPage.transform.Find("answer4").GetComponent <TextMeshPro>().text = page.answer4;


            //input the target of the arrow
            string corrDirec = "directional" + page.correct;
            myPage.transform.Find("GuideArrow").GetComponent <ArrowHandler>().DirectionalTarget = arts.transform.GetChild(page.directional);


            //make sure only one answer is selected
            myPage.transform.Find("answer1").GetComponent <Interactable>().OnClick.AddListener(delegate() { myPage.SendMessage("AnswerSwitch", 1); });
            myPage.transform.Find("answer2").GetComponent <Interactable>().OnClick.AddListener(delegate() { myPage.SendMessage("AnswerSwitch", 2); });
            myPage.transform.Find("answer3").GetComponent <Interactable>().OnClick.AddListener(delegate() { myPage.SendMessage("AnswerSwitch", 3); });
            myPage.transform.Find("answer4").GetComponent <Interactable>().OnClick.AddListener(delegate() { myPage.SendMessage("AnswerSwitch", 4); });
        }
    }
Example #8
0
    public void openQuizBuilder(QuizContainer quiz)
    {
        gameObject.SetActive(true);
        quizzesMenu.SetActive(false);
        quizEditorMenu.SetActive(false);

        editedQuiz     = quiz;
        unfinishedQuiz = new List <Question>();
        for (int i = 0; i < quiz.container.Count - 1; i++)
        {
            newQuestionButton();
            questionTxt.text = quiz.container[i].question;
            a1Txt.text       = quiz.container[i].answers[0];
            a2Txt.text       = quiz.container[i].answers[1];
            a3Txt.text       = quiz.container[i].answers[2];
            toggles[quiz.container[i].correctIndex].isOn = true;

            saveQuestion(i);
        }
        quizTitle.text = quiz.container[unfinishedQuiz.Count].question;
    }
 public void ParentActiveVariantTest()
 {
     QuizContainer target = new QuizContainer(); // TODO: Initialize to an appropriate value
     RibbonGroupVariant expected = new RibbonGroupVariant(); // TODO: Initialize to an appropriate value
     RibbonGroupVariant actual;
     target.ParentActiveVariant = expected;
     actual = target.ParentActiveVariant;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void ScrollToEndTest()
 {
     QuizContainer target = new QuizContainer(); // TODO: Initialize to an appropriate value
     target.ScrollToEnd();
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
 public void QuizContainerConstructorTest()
 {
     QuizContainer target = new QuizContainer();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }