예제 #1
0
        public static bool Valid(List <QuestionWebControl> questionControls, FormGenerationSettings settings)
        {
            var valid = true;

            foreach (var qc in questionControls)
            {
                if (!qc.Question.IsMandatory)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(qc.Value))
                {
                    qc.ErrorLabel.Text =
                        WidgetActionFactory.getWidgetActionByName(qc.Question.ControlType).MandatoryQuestionErrorMessage(settings);
                    qc.ErrorLabel.Visible = true;
                    valid = false;
                }
                else if (qc.Value.Length > qc.Question.MaxSize)
                {
                    qc.ErrorLabel.Text    = settings.UserAnswerLengthErrorMessage;
                    qc.ErrorLabel.Visible = true;
                    valid = false;
                }
            }
            return(valid);
        }
예제 #2
0
 public string MandatoryQuestionErrorMessage(FormGenerationSettings settings)
 {
     return(settings.UserOptionQuestionErrorMessage);
 }
예제 #3
0
        public static List <QuestionWebControl> RenderForm(Poll poll, Control questions, FormGenerationSettings settings)
        {
            var questionsList = new List <QuestionWebControl>();
            var blocks        = new Dictionary <int, BlockWebControl>();

            foreach (var blocksKey in poll.Blocks.Keys)
            {
                var block = new BlockWebControl(poll.Blocks[blocksKey]);
                questions.Controls.Add(block);
                blocks.Add(blocksKey, block);
            }
            foreach (var q in poll.Questions)
            {
                QuestionTypeActionFactory.getActionByName(q.Category)
                .DisplayAction(q, poll, blocks[q.BlockNumber], questionsList);
            }
            return(questionsList);
        }