Esempio n. 1
0
        private void GenerateQuiz(Category curCat, int questionsAmount)
        {
            QuestionClass qc = new QuestionClass();

            qc.GenerateQuestions(questionsAmount, curCat);
            ListOfQuestions = qc.QuizQuestions;
        }
Esempio n. 2
0
        private QuestionClass AddQuestion(Category cat, int qNumber)
        {
            QuestionClass newQuestion = new QuestionClass();
            int           randId      = random.Next(cat.CategoryItems.Count);

            newQuestion.QuestionNumber = qNumber;
            newQuestion.Question       = cat.CategoryItems.Where(w => w.Id == randId).Select(s => s.PolishWord).FirstOrDefault();
            newQuestion.CorrectAnswer  = cat.CategoryItems.Where(w => w.Id == randId).Select(s => s.EnglishWord).FirstOrDefault();
            newQuestion.FakeAnswers    = cat.CategoryItems.Where(w => w.Id != randId).OrderBy(ob => random.Next()).Select(s => s.EnglishWord).Take(3).ToList();

            return(newQuestion);
        }
Esempio n. 3
0
 public fMain()
 {
     try
     {
         InitializeComponent();
         DataManager.Setup();
         FillListBox();
         QuestionClass aa = new QuestionClass();
         aa.GenerateQuestions(10, DataManager.QuizCategories.First());
     }
     catch (Exception ex)
     {
         throw new Exception("Ładowanie głównej formatki.", ex);
     }
 }
Esempio n. 4
0
        public void GenerateQuestions(int size, Category cat)
        {
            int tempNumber = 1;

            while (tempNumber <= size)
            {
                QuestionClass tempQuestion = this.AddQuestion(cat, tempNumber);
                if (QuizQuestions.Any(a => a.CorrectAnswer == tempQuestion.CorrectAnswer))
                {
                    continue;
                }
                else
                {
                    QuizQuestions.Add(tempQuestion);
                    tempNumber++;
                }
            }
        }