private void addQuestion_Click(object sender, RoutedEventArgs e)
        {
            string questionString = questionTextBox.Text;
            string measureString = measureTextBox.Text;
            string exampleString = exampleTextBox.Text;

            if (questionString.Equals(String.Empty))
            {
                return;
            }

            questionsNumber++;

            Question question = new Question(questionString, questionsNumber, Test.Type);

            question.Measure = measureString;
            question.Example = exampleString;

            Test.AddQuestion(question);

            questionsNumberLabel.Content = questionsNumber.ToString();
            if (questionsNumber > 0)
            {
                specifyRules.IsEnabled = true;
            }

            RestoreOriginalState();
        }
Exemplo n.º 2
0
        public void AddQuestion(Question question) 
        {
            if (Questions.Count == 0) 
            {
                if (!TestFile.Exists)
                {
                    using (StreamWriter streamWriter = TestFile.AppendText())
                    {
                        streamWriter.WriteLine("Questions:");
                    }
                }
            }

            if (!Questions.ContainsKey(question.Number)) 
            {
                Questions.Add(question.Number, question);
                AddQuestionToFile(question);
            }
        }
        private void addQuestion_Click(object sender, RoutedEventArgs e)
        {
            string questionString = questionTextBox.Text;
            string aString = aAnswerTextBox.Text;
            string bString = bAnswerTextBox.Text;

            if (questionString.Equals(String.Empty) || aString.Equals(String.Empty) || bString.Equals(String.Empty)) 
            {
                return;
            }

            Dictionary<String, String> answers = new Dictionary<string, string>();

            answers.Add("a", aString);
            answers.Add("b", bString);

            if (cAnswerTextBox.IsEnabled && !cAnswerTextBox.Text.Equals(String.Empty)) 
            {
                answers.Add("c", cAnswerTextBox.Text);
            }

            if (dAnswerTextBox.IsEnabled && !dAnswerTextBox.Text.Equals(String.Empty))
            {
                answers.Add("d", dAnswerTextBox.Text);
            }

            questionsNumber++;

            Question question = new Question(questionString, questionsNumber, test.Type);
            question.Answers = answers;

            test.AddQuestion(question);

            questionsNumberLabel.Content = questionsNumber.ToString();

            if (questionsNumber > 0) 
            {
                specifyRules.IsEnabled = true;
            }

            RestoreOriginalState();
        }
Exemplo n.º 4
0
        private SociologicalTest CreateTest(string name, string description, int number, int type,
            Dictionary<int, Dictionary<string, string>> questions, List<Rule> rules) 
        {
            SociologicalTest test = new SociologicalTest(number, name, description, type);

            test.rules = rules;

            foreach (int key in questions.Keys) 
            {
                string text = null;
                string measure = null;
                string example = null;
                Dictionary<string, string> values = questions[key];
                Dictionary<string, string> answers = new Dictionary<string, string>();
                foreach (var value in values) 
                {
                    if (value.Key.Equals("q"))
                    {
                        text = value.Value;
                    }
                    else if (value.Key.Equals("measure")) 
                    {
                        measure = value.Value;
                    }
                    else if (value.Key.Equals("example"))
                    {
                        example = value.Value;
                    }
                    else
                    {
                        answers.Add(value.Key, value.Value);
                    }
                }

                Question question = new Question(text, key, type);
                question.Answers = answers;
                question.Measure = measure;
                question.Example = example;

                test.Questions.Add(key, question);
            }

            return test;
        }
Exemplo n.º 5
0
 private void AddQuestionToFile(Question question) 
 {
     if (!TestFile.Exists)
     {
         using (StreamWriter streamWriter = TestFile.AppendText())
         {
             streamWriter.WriteLine("n/" + question.Number);
             streamWriter.WriteLine("q/" + question.QuestionText);
             streamWriter.WriteLine("measure/" + question.Measure);
             streamWriter.WriteLine("example/" + question.Example);
             foreach (var answer in question.Answers) 
             {
                 streamWriter.WriteLine(answer.Key + "/" + answer.Value);
             }
         }
     }
 }