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 }));
        }
Beispiel #2
0
        public SampleQuestionWithWordsProvider()
        {
            currentQuestion = 0;

            description = "Questions description";

            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();

                if (newWordData == null)
                {
                    return;
                }

                correctAnswers.Add(newWordData);

                // At least 4 wrong words
                while (wrongAnswers.Count < 4)
                {
                    var word = AppManager.I.Teacher.GetRandomTestWordDataLL();

                    if (!correctAnswers.Contains(word) && !wrongAnswers.Contains(word))
                    {
                        wrongAnswers.Add(word);
                    }
                }

                var currentPack = new SampleQuestionPack(newWordData, wrongAnswers, correctAnswers);
                questions.Add(currentPack);
            }
        }
        public bool Equals(ILivingLetterData data)
        {
            LL_WordData other = data as LL_WordData;

            if (other == null)
            {
                return(false);
            }

            return(other.Data.Id == Data.Id);
        }
Beispiel #4
0
 public void Show(System.Action callback, Db.LocalizationDataId text, LL_WordData word = null)
 {
     if (word != null)
     {
         WidgetPopupWindow.I.ShowSentenceAndWord(callback, text, word);
     }
     else
     {
         WidgetPopupWindow.I.ShowSentence(callback, text);
     }
 }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        public void SetWord(string imageId, LL_WordData wordData)
        {
            if (wordData == null)
            {
                WordTextGO.SetActive(false);
            }
            else
            {
                WordTextGO.SetActive(true);
                WordTextGO.GetComponent <TextRender>().SetLetterData(wordData);
            }

            if (!imageId.IsNullOrEmpty())
            {
                DrawingImageGO.SetActive(true);
                DrawingImageGO.GetComponent <TextMeshProUGUI>().text = imageId;
            }
            else
            {
                DrawingImageGO.SetActive(false);
            }
        }
Beispiel #7
0
 public void Show(System.Action callback, Db.LocalizationDataId text, bool markResult, LL_WordData word = null)
 {
     if (word != null)
     {
         WidgetPopupWindow.I.ShowSentenceAndWordWithMark(callback, text, word, markResult);
     }
     else
     {
         WidgetPopupWindow.I.ShowSentenceWithMark(callback, text, markResult, null);
     }
 }
Beispiel #8
0
        public void ShowSentenceAndWordWithMark(Action callback, Db.LocalizationDataId SentenceId, LL_WordData wordData, bool result)
        {
            ResetContents();

            currentCallback = callback;
            ButtonGO.gameObject.SetActive(callback != null);

            MarkOK.SetActive(result);
            MarkKO.SetActive(!result);


            TitleGO.GetComponent <TextRender>().SetSentence(SentenceId);

            //AudioManager.I.PlayDialog(SentenceId);

            SetWord(wordData.DrawingCharForLivingLetter, wordData);

            Show(true);
        }