Esempio n. 1
0
        private static Question CreateQuestion(string line, typeOfQuestion type)
        {
            Question question;

            if (type == typeOfQuestion.open)
            {
                const string patternForOpenQuestion = @".*Tresc:""(.*?)""; .*""(\d{2,3})"".";
                Regex rExtractForOpen = new Regex(patternForOpenQuestion, RegexOptions.IgnoreCase);
                Match mExtractForOpen = rExtractForOpen.Match(line);
                Group g0_open = mExtractForOpen.Groups[0];
                Group g1_open = mExtractForOpen.Groups[1];
                Group g2_open = mExtractForOpen.Groups[2];
                question = new Question(g1_open.ToString(), "open", g2_open.ToString());
                
            }
            else
            {
                const string patternForCloseQuestion = @".*Tresc:""(.*?)""; Odpowiedz_A:""(.*?)""; Odpowiedz_B:""(.*?)""; Odpowiedz_C:""(.*?)""; Odpowiedz_D:""(.*?)""; Odpowiedz_E:""(.*?)""; Prawidlowa:""(.*?)""; Czas:""(\d{2,3})"".";
                Regex rExtractForClose = new Regex(patternForCloseQuestion, RegexOptions.IgnoreCase);
                Match mExtractForClose = rExtractForClose.Match(line);
                Group g0_close = mExtractForClose.Groups[0];
                Group g1_close = mExtractForClose.Groups[1];
                Group g2_close = mExtractForClose.Groups[2];
                Group g3_close = mExtractForClose.Groups[3];
                Group g4_close = mExtractForClose.Groups[4];
                Group g5_close = mExtractForClose.Groups[5];
                Group g6_close = mExtractForClose.Groups[6];
                Group g7_close = mExtractForClose.Groups[7];
                Group g8_close = mExtractForClose.Groups[8];
                answers.Add(g2_close.ToString());
                answers.Add(g3_close.ToString());
                answers.Add(g4_close.ToString());
                answers.Add(g5_close.ToString());
                answers.Add(g6_close.ToString());

                question = new Question(g1_close.ToString(), "close", answers, g7_close.ToString(), g8_close.ToString());
                answers.Clear();
            }
            return question;
        }
Esempio n. 2
0
 public void ChangeContext(Question question)
 {
     if (!(DataContext == question))
         DataContext = question;
 }
Esempio n. 3
0
 private static List<bool> InsertInfoIfAnswerIsImage(Question question)
 {
     List<bool> ifAnswerIsImage = new List<bool>();
     foreach (Test.Question.Answer ans in question.AnswersProperty)
     {
         ifAnswerIsImage.Add(ans.isImage);
     }
     return ifAnswerIsImage;
 }
Esempio n. 4
0
        private static List<string> GetInfoFromPropertyIntoList(Question question)
        {
            List<string> answersForClosed = new List<string>();

            foreach (Test.Question.Answer ans in question.AnswersProperty)
            {
                answersForClosed.Add(ans.AnswerContent);
            }
            return answersForClosed;
        }
Esempio n. 5
0
 private static Task WaitingForTimer(Question qst, System.Windows.Threading.DispatcherTimer dt)
 {
     int sumOfTicks = 0;
     int neededTicks = qst.TimeToAnswer;
     dispatcherTimerTick = false;
     dt.Interval = new TimeSpan(0, 0, 1);
     dt.Tick += (sender, e) => { Dt_Tick(sender, e, ref sumOfTicks, neededTicks); };
     dt.Start();
     Task task = Task.Run(() =>
     {
         while (sumOfTicks <= qst.TimeToAnswer)
         {
             if (!dt.IsEnabled)
                 break;
         };
     });
     return task;
 }