Exemplo n.º 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);
        }
Exemplo n.º 2
0
 protected override void OnInit(EventArgs e)
 {
     Control    = WidgetActionFactory.getWidgetActionByName(Question.ControlType).QuestionWebControlAction(Question);
     ErrorLabel = new Label
     {
         Visible  = false,
         CssClass = "has-error server-control"
     };
     base.OnInit(e);
 }
Exemplo n.º 3
0
        public static List <Question> QuestionsWebControlToQuestions(List <QuestionWebControl> ctrls)
        {
            var questions = new List <Question>();

            foreach (var ctrl in ctrls)
            {
                WidgetActionFactory.getWidgetActionByName(ctrl.Question.ControlType).SetQuestionAnswer(
                    ctrl.Question,
                    ctrl.Value
                    );
                questions.Add(ctrl.Question);
            }
            return(questions);
        }