public SingleChoiceAnswerWindow(Answer ans)
        {
            this.InitializeComponent();
            // Вставьте ниже код, необходимый для создания объекта.
            this.AnswerModel = ans;
            this.AnswerSaved = ans;

            this.DataContext = this.AnswerModel;
        }
        public void SetAnswerTrue(Answer ans)
        {
            if (this.QuestionModel.Answers.Contains(ans))
            {
                throw new ArgumentOutOfRangeException();
            }

            foreach (Answer item in this.QuestionModel.Answers)
            {
                item.IsTrue = false;
            }
            ans.IsTrue = true;
        }
Пример #3
0
 private void addAsnwerButton_Click(object sender, EventArgs e)
 {
     if (questionsTabControl.TabPages.Count != 0)
     {
         var v = questionsTabControl.SelectedIndex;
         Answer = GetAnswerEvent();
         generatedTest.AddAnswers(v, Answer);
         foreach (ListBox c in questionsTabControl.SelectedTab.Controls)
         {
             if (c is ListBox)
             {
                 c.Items.Add((c.Items.Count).ToString() + ". " + Answer.GetAnswer);
             }
         }
     }
     else
     {
         MessageBox.Show("Brak pytań do których możesz dodać odpowiedź!");
     }
 }
Пример #4
0
        /// <summary>
        /// парсинг вопроса
        /// </summary>
        /// <param name="question">элемент XML с вопросом</param>
        /// <exception cref="ArgumentException">неправлиный тип вопроса</exception>
        public virtual void Parse(XElement question)
        {
            this.ID = Int32.Parse(question.Attribute("ID").Value);
            if (this.ID == null) {
                throw new ArgumentException("Uncorrect xml file"); }

            this.MaxMark = Int32.Parse(question.Attribute("MaxMark").Value);
            if (this.MaxMark == null || this.MaxMark <= 0) { this.MaxMark = 1; }

            this.MinMark = Int32.Parse(question.Attribute("MinMark").Value);
            if (this.MinMark == null || this.MaxMark < 0 || this.MinMark >= this.MaxMark) { this.MinMark = 0; }

            try
            {
                this.Type = Question.GetTypeOfQuestion(question);
            }
            catch
            {
                throw new ArgumentException("Uncorrect xml file");
            }

            XElement Mdata = question.Element("MediaData");
            if (Mdata != null)
            {
                this.Data = new MediaData();
                this.Data.Parse(Mdata);
            }

            switch (this.Type)
            {
                case QuestionType.SingleChoice:
                    {
                        foreach (XElement answer in question.Element("Answers").Elements())
                        {
                            Answer ans = new Answer();
                            ans.Parse(answer);
                            this.Answers.Add(ans);
                        }
                        break;
                    }
                case QuestionType.MultiChoice:
                    {
                        break;
                    }
            }

            foreach (XElement RigthAns in question.Element("RightAnswers").Elements())
            {
                RightAnswer ans = RightAnswer.Parse(RigthAns);
                this.RightAnswers.Add(ans);
            }
        }
Пример #5
0
        public static ObservableCollection<QuestionBase> _Debug_GetTestQuestions()
        {
            ObservableCollection<QuestionBase> res;
            res = new ObservableCollection<QuestionBase>();

            {
                QSingleChoice q = new QSingleChoice()
                {
                    Name = "A1",
                    Number = 1,
                    Data = new MediaData("Lol1")
                    {
                       Files = new ObservableCollection<MediaFile>()
                       {
                           new MediaFile("TEXT1")
                       }
                    }
                };

                Answer ans = new Answer(new MediaData("Answer1"), true);
                q.Answers.Add(ans);

                Answer ans2 = new Answer(new MediaData("Answer2"), false);
                q.Answers.Add(ans2);

                res.Add(q);
            }


            {
                QSingleChoice q2 = new QSingleChoice()
                {
                    Name = "A2",
                    Number = 2,
                    Data = new MediaData("Lol2")
                    {
                        Files = new ObservableCollection<MediaFile>()
                       {
                           new MediaFile("TEXT2")
                       }
                    }
                };

                var ans = new Answer(new MediaData("Answer1"), false);
                q2.Answers.Add(ans);

                var ans2 = new Answer(new MediaData("Answer2"), true);
                q2.Answers.Add(ans2);

                res.Add(q2);
            }

            {
                QMultiChoice q3 = new QMultiChoice()
                {
                    Name = "A3",
                    Number = 3,
                    Data = new MediaData("Lol3")
                };


                var ans = new MultiChoiceBallAswer(new MediaData("Answer1"), true);
                q3.Answers.Add(ans);

                var ans2 = new MultiChoiceBallAswer(new MediaData("Answer2"), true);
                q3.Answers.Add(ans2);

                res.Add(q3);
            }

            return res;
        }