IQuestionPack IQuestionProvider.GetNextQuestion()
        {
            var         answerData = AppManager.I.DB.GetWordDataByRandom();
            LL_WordData randomWord = new LL_WordData(answerData.Id, answerData);

            StringTestData fakeData = new StringTestData(
                ArabicAlphabetHelper.PrepareArabicStringForDisplay(
                    "منذ لم نرك منذ مدة " + randomWord.Data.Arabic + " منذ مدة" +
                    "منذ لم نرك منذ مدة " +
                    "منذ لم نرك منذ مدة "));

            List <ILivingLetterData> wrongAnswers = new List <ILivingLetterData>();

            while (wrongAnswers.Count < 6)
            {
                var randomData = AppManager.I.DB.GetWordDataByRandom();

                if (randomData.Id != answerData.Id && !wrongAnswers.Any((a) => { return(a.Id == randomData.Id); }))
                {
                    wrongAnswers.Add(randomData.ConvertToLivingLetterData());
                }
            }

            return(new SampleQuestionPack(fakeData, wrongAnswers, new ILivingLetterData[] { randomWord }));
        }
 void updateText()
 {
     if (isTMPro)
     {
         if (isArabic)
         {
             if (isUI)
             {
                 gameObject.GetComponent <TextMeshProUGUI>().text = ArabicAlphabetHelper.PrepareArabicStringForDisplay(m_text);
             }
             else
             {
                 gameObject.GetComponent <TextMeshPro>().text = ArabicAlphabetHelper.PrepareArabicStringForDisplay(m_text);
             }
         }
         else
         {
             if (isUI)
             {
                 gameObject.GetComponent <TextMeshProUGUI>().text = m_text;
             }
             else
             {
                 gameObject.GetComponent <TextMeshPro>().text = m_text;
             }
         }
     }
     else
     {
         if (isArabic)
         {
             if (isUI)
             {
                 gameObject.GetComponent <Text>().text = ArabicAlphabetHelper.PrepareArabicStringForDisplay(m_text);
             }
             else
             {
                 gameObject.GetComponent <TextMesh>().text = ArabicAlphabetHelper.PrepareArabicStringForDisplay(m_text);
             }
         }
         else
         {
             if (isUI)
             {
                 gameObject.GetComponent <Text>().text = m_text;
             }
             else
             {
                 gameObject.GetComponent <TextMesh>().text = m_text;
             }
         }
     }
 }
示例#3
0
        public SampleQuestionProvider()
        {
            currentQuestion = 0;

            description = "Questions description";

            // 10 QuestionPacks
            for (int i = 0; i < 32; i++)
            {
                List <ILivingLetterData> correctAnswers = new List <ILivingLetterData>();
                List <ILivingLetterData> wrongAnswers   = new List <ILivingLetterData>();

                LL_WordData newWordData = AppManager.I.Teacher.GetRandomTestWordDataLL();
                //LL_WordData newWordData = AppManager.I.Teacher.GetRandomTestWordDataLL(new WordFilters(requireDiacritics: true));

                //LL_WordData newWordData = new LL_WordData(AppManager.I.DB.GetWordDataById("welcome"));


                if (newWordData == null)
                {
                    return;
                }

                foreach (var letterData in ArabicAlphabetHelper.ExtractLetterDataFromArabicWord(newWordData.Data.Arabic))
                {
                    correctAnswers.Add(letterData);
                }

                correctAnswers = correctAnswers.Distinct().ToList();

                // At least 4 wrong letters
                while (wrongAnswers.Count < 4)
                {
                    var letter = AppManager.I.Teacher.GetRandomTestLetterLL();

                    if (!CheckIfContains(correctAnswers, letter) && !CheckIfContains(wrongAnswers, letter))
                    {
                        wrongAnswers.Add(letter);
                    }
                }

                var currentPack = new SampleQuestionPack(newWordData, wrongAnswers, correctAnswers);
                questions.Add(currentPack);
            }
        }
示例#4
0
        public void DetailWord(WordInfo info)
        {
            DetailPanel.SetActive(true);
            Debug.Log("Detail Word :" + info.data.Id);
            AudioManager.I.PlayWord(info.data.Id);
            MoreInfoPanel.SetActive(false);
            ScoreText.text = "Score: " + info.score;

            var output = "";

            var splittedLetters = ArabicAlphabetHelper.SplitWordIntoLetters(info.data.Arabic);

            foreach (var letter in splittedLetters)
            {
                output += letter.GetChar() + " ";
            }
            output += "\n";
            output += info.data.Arabic;

            //output += "\n";

            //foreach (var letter in splittedLetters) {
            //    output += letter.GetChar();
            //}

            ArabicText.text = output;

            LL_Isolated.Init(new LL_WordData(info.data));
            LL_Initial.gameObject.SetActive(false);
            LL_Final.gameObject.SetActive(false);

            if (info.data.Drawing != "")
            {
                var drawingChar = AppManager.I.Teacher.wordHelper.GetWordDrawing(info.data);
                Drawing.text = drawingChar;
                //LL_Medial.gameObject.SetActive(true);
                LL_Medial.Init(new LL_ImageData(info.data));
                Debug.Log("Drawing: " + info.data.Drawing + " / " + ArabicAlphabetHelper.GetLetterFromUnicode(info.data.Drawing));
            }
            else
            {
                Drawing.text = "";
                LL_Medial.gameObject.SetActive(false);
            }
        }
        public MakeFriendsQuestionProvider()
        {
            currentQuestion = 0;
            description     = "Questions description";

            List <ILivingLetterData> correctAnswers;
            List <ILivingLetterData> wrongAnswers;

            LL_WordData newWordData1;
            LL_WordData newWordData2;
            List <ILivingLetterData> wordLetters1    = new List <ILivingLetterData>();
            List <ILivingLetterData> wordLetters2    = new List <ILivingLetterData>();
            List <ILivingLetterData> commonLetters   = new List <ILivingLetterData>();
            List <ILivingLetterData> uncommonLetters = new List <ILivingLetterData>();

            for (int iteration = 0; iteration < quizzesCount; iteration++)
            {
                // Get 2 words with at least 1 common letter
                int outerLoopAttempts = 50;
                do
                {
                    newWordData1 = null;
                    newWordData2 = null;
                    wordLetters1.Clear();
                    wordLetters2.Clear();
                    commonLetters.Clear();
                    uncommonLetters.Clear();

                    newWordData1 = AppManager.I.Teacher.GetRandomTestWordDataLL();
                    foreach (var letterData in ArabicAlphabetHelper.ExtractLetterDataFromArabicWord(newWordData1.Data.Arabic))
                    {
                        wordLetters1.Add(letterData);
                    }

                    int innerLoopAttempts = 50;
                    do
                    {
                        newWordData2 = AppManager.I.Teacher.GetRandomTestWordDataLL();
                        innerLoopAttempts--;
                    } while(newWordData2.Id == newWordData1.Id && innerLoopAttempts > 0);
                    if (innerLoopAttempts <= 0)
                    {
                        UnityEngine.Debug.LogError("MakeFriends QuestionProvider Could not find 2 different words!");
                    }

                    foreach (var letterData in ArabicAlphabetHelper.ExtractLetterDataFromArabicWord(newWordData2.Data.Arabic))
                    {
                        wordLetters2.Add(letterData);
                    }

                    // Find common letter(s) (without repetition)
                    for (int i = 0; i < wordLetters1.Count; i++)
                    {
                        var letter = wordLetters1[i];

                        //if (wordLetters2.Contains(letter))
                        if (wordLetters2.Exists(x => x.Id == letter.Id))
                        {
                            //if (!commonLetters.Contains(letter))
                            if (!commonLetters.Exists(x => x.Id == letter.Id))
                            {
                                commonLetters.Add(letter);
                            }
                        }
                    }

                    // Find uncommon letters (without repetition)
                    for (int i = 0; i < wordLetters1.Count; i++)
                    {
                        var letter = wordLetters1[i];

                        //if (!wordLetters2.Contains(letter))
                        if (!wordLetters2.Exists(x => x.Id == letter.Id))
                        {
                            //if (!uncommonLetters.Contains(letter))
                            if (!uncommonLetters.Exists(x => x.Id == letter.Id))
                            {
                                uncommonLetters.Add(letter);
                            }
                        }
                    }

                    for (int i = 0; i < wordLetters2.Count; i++)
                    {
                        var letter = wordLetters2[i];

                        if (!wordLetters1.Contains(letter))
                        {
                            if (!uncommonLetters.Contains(letter))
                            {
                                uncommonLetters.Add(letter);
                            }
                        }
                    }
                    outerLoopAttempts--;
                } while(commonLetters.Count == 0 && outerLoopAttempts > 0);
                if (outerLoopAttempts <= 0)
                {
                    UnityEngine.Debug.LogError("MakeFriends QuestionProvider Could not find enough data for QuestionPack #" + iteration
                                               + "\nInfo: Word1: " + ArabicFixer.Fix(newWordData1.TextForLivingLetter) + " Word2: " + ArabicFixer.Fix(newWordData2.TextForLivingLetter)
                                               + "\nWordLetters1: " + wordLetters1.Count + " WordLetters2: " + wordLetters2.Count
                                               + "\nCommonLetters: " + commonLetters.Count + " UncommonLetters: " + uncommonLetters.Count);
                }

                commonLetters   = commonLetters.Shuffle();
                uncommonLetters = uncommonLetters.Shuffle();

                correctAnswers = new List <ILivingLetterData>(commonLetters);
                wrongAnswers   = new List <ILivingLetterData>(uncommonLetters);

                var currentPack = new MakeFriendsQuestionPack(newWordData1, newWordData2, wrongAnswers, correctAnswers);
                questions.Add(currentPack);
            }
        }