Beispiel #1
0
    private void FetchQuestionsData()
    {
        questionsDico = new Dictionary <int, QuestionData>();
        TextAsset textsData = Resources.Load <TextAsset>("Questions");

        string[] data = textsData.text.Split(new char[] { '\n' });

        for (int i = 1; i < data.Length - 1; i++)
        {
            string[] row = data[i].Split(new char[] { '|' });

            string[] answers = row[2].Split(new char[] { ',' });

            string[] justifTextIDstring = row[3].Split(new char[] { ',' });
            //Si question à choix multiples
            if (answers.Length > 1)
            {
                Dictionary <int, string> answerRefDico = new Dictionary <int, string>();
                //Debug.Log("Nombre d'ensemble de reponse" + justifTextIDstring.Length);

                for (int j = 0; j < answers.Length; j++)
                {
                    string[] textsRefIdsString = justifTextIDstring[j].Split(new char[] { '-' });

                    for (int l = 0; l < textsRefIdsString.Length; l++)
                    {
                        answerRefDico.Add(int.Parse(textsRefIdsString[l]), answers[j]);
                    }
                }

                //foreach (var item in answerRefDico)
                //{
                //    Debug.Log(item.Key + " - " + item.Value);
                //}
                ClosedQuestionData questionRow = new ClosedQuestionData(row[1], answerRefDico);
                questionsDico[int.Parse(row[0])] = questionRow;
            }
            //Sinon on passe juste le nom de la question
            else
            {
                OpenQuestionData questionRow = new OpenQuestionData(row[1], row[4]);
                questionsDico[int.Parse(row[0])] = questionRow;
            }
        }
    }
Beispiel #2
0
 public ClosedQuestion(QuestionData data) : base(data)
 {
     questionData = (ClosedQuestionData)data;
 }