Ejemplo n.º 1
0
    //HALF COMPLETED // LATER TESTS AND IMPROVEMENTS WILL DONE SOON
    //Pre_Test Next button behaivour region from PreTest Panel
    //When last question is answered make Play button appear instead of next button

    //As the response checker the system will send the test data sand tries to get a response
    //if the response is corect then
    public void Tests_Next_Button()
    {
        if (Start_Test_Panel.activeSelf)//NEXT Butonuna tıklanınca
        {
            Start_Test_Panel.SetActive(false);
            User_Detail_Panel.SetActive(true);
            NextButton.SetActive(true);
        }
        //Sends User Details on first "next" button click
        else if (User_Detail_Panel.activeSelf)//NEXT Butonuna tıklanınca
        {
            if (Gender.text.Length > 0 && Occupation.text.Length > 0 && Age.text.Length > 0 && ProfExp.text.Length > 0)
            {
                //Regex compares the textbox, if all chars are integer then returns true, forr others we check if string is not empty
                if ((Regex.IsMatch(Age.text, @"^\d+$")) && (Occupation.text.ToString() == "") && (Gender.text.ToString() == "") && (Regex.IsMatch(ProfExp.text, @"^\d+$")))
                {
                    //Cevapları al ve gönder
                    D.user.age        = Age.text.ToString();
                    D.user.country    = Gender.text.ToString();
                    D.user.occupation = Occupation.text.ToString();
                    D.user.prof_exp   = ProfExp.text.ToString();
                    D.user.security   = D.con.security;
                    D.user.user_id    = D.con.user_id;
                    D.BuildNewSerialization(D.user);
                    //CHECK if sended dat ais correct and we got a response
                    User_Detail_Panel.SetActive(false);
                    TestGroup.SetActive(true);
                    QuestionTextPlace.text = Questions[i];
                }
            }
        }
        else
        {
            //Soruyu al
            if (((buttonstate != "") && (buttonstate != null && buttonvalue == 0)) || (buttonstate == null && buttonvalue != 0))
            {
                switch (i)
                {
                //Sends answers based on which question we are on
                case 0:
                    D.pre.bir = buttonstate;
                    break;

                case 1:
                    D.pre.iki = buttonstate;
                    break;

                case 2:
                    D.pre.uc = buttonstate;
                    break;

                case 3:
                    D.pre.dort = buttonstate;
                    break;

                case 4:
                    D.pre.bes = buttonstate;
                    break;

                case 5:
                    D.pre.alti = buttonstate;
                    break;

                case 6:
                    D.pre.yedi = buttonstate;
                    break;

                case 7:
                    D.pre.sekiz = buttonstate;
                    YesNoButtonHolder.SetActive(false);
                    NumberButtonHolder.SetActive(true);
                    break;

                case 8:
                    D.pre.puan = buttonvalue;
                    D.SendTestData(D.pre);
                    //Next button => Start Button
                    NextButton.SetActive(false);
                    break;
                }
                //Increment the counter to get next question
                i++;
                QuestionTextPlace.text = Questions[i];
            }
            buttonstate = null;
            buttonvalue = 0;
        }
    }