public SingleVariantPassControl(SingleQuestionAnswer singleQuestionAnswer, bool isPreviewState)
        {
            InitializeComponent();
            answer        = singleQuestionAnswer;
            VariantSingle = new List <RadioButton>();
            //Добавление вариантов в случайном порядке
            var added_indexes = new HashSet <int>();
            var rnd           = new Random();
            var graphics      = CreateGraphics();

            for (var i = 0; i < singleQuestionAnswer.Variants.Count; i++)
            {
                int index;
                do
                {
                    index = rnd.Next(0, singleQuestionAnswer.Variants.Count);
                }while (added_indexes.Contains(index));
                added_indexes.Add(index);
                VariantSingle.Add(OleXisTest.Controls.GetRadioButton(singleQuestionAnswer.Variants[i], OleXisTest.Controls.GetStringWidth(singleQuestionAnswer.Variants[i], graphics) + 20, index * OleXisTest.Controls.PASSING_RADIOBUTTON_INDENT_Y, this));
                if (isPreviewState)
                {
                    VariantSingle.Last().AutoCheck = false;
                }
            }
            if (isPreviewState)
            {
                VariantSingle[singleQuestionAnswer.Answer].Checked = true;
            }
        }
 public SingleVariantEditControl(SingleQuestionAnswer singleQuestionAnswer) : this()
 {
     for (var i = 0; i < singleQuestionAnswer.Variants.Count; i++)
     {
         AddVariant();
         TextVariant[i].Text = singleQuestionAnswer.Variants[i];
     }
     if (CorrectVariantSingle.Count > 0)
     {
         CorrectVariantSingle[singleQuestionAnswer.Answer].Checked = true;
     }
 }
Пример #3
0
 public SingleQuestionAnswer(SingleQuestionAnswer answerToClone)
 {
     Variants = new List <string>(answerToClone.Variants);
     Answer   = answerToClone.Answer;
 }