Beispiel #1
0
        public List <string> getOptions(string qid)
        {
            ClassQuestions cQ = new ClassQuestions();

            using (BrainStormerEntities4 db = new BrainStormerEntities4())
            {
                var q = db.Questions.First(p => p.QID == qid);
                cQ.Answer  = q.Answer;
                cQ.Option1 = q.Option1;
                cQ.Option2 = q.Option2;
                cQ.Option3 = q.Option3;
            }
            List <string> temp = new List <string>();

            temp.Add(cQ.Answer);
            temp.Add(cQ.Option1);
            temp.Add(cQ.Option2);
            temp.Add(cQ.Option3);
            Random r = new Random();

            for (int i = 0; i < 4; i++)
            {
                int index = r.Next(temp.Count);
                //if (temp.Count>-1)
                {
                    temP = temp.ElementAt(index);
                    options.Add(temP);
                    temp.RemoveAt(index);
                }
            }
            return(options);
        }
Beispiel #2
0
        public ClassQuestions getQuestion(string qid)
        {
            ClassQuestions questions = null;

            using (BrainStormerEntities4 dataset = new BrainStormerEntities4())
            {
                var matchinqQuestions = dataset.Questions.First((p) => p.QID == qid);
                questions          = new ClassQuestions();
                questions.Question = matchinqQuestions.Question1;
                questions.Answer   = matchinqQuestions.Answer;
                questions.Option1  = matchinqQuestions.Option1;
                questions.Option2  = matchinqQuestions.Option2;
                questions.Option3  = matchinqQuestions.Option3;
            }
            // qID.RemoveAt(index);

            return(questions);
        }