Beispiel #1
0
        private bool ValidateQuestion(Form_question q, form_question_answer a)
        {
            if (q.question_type == Form_question_type.heading || q.question_type == Form_question_type.subheading)
            {
                return(true);
            }
            var valid = true;

            if (q.question_type == Form_question_type.shorttext)
            {
                valid = !string.IsNullOrEmpty(a.textValue);
            }
            else if (q.question_type == Form_question_type.date)
            {
                valid = a.dateValue != null;
            }
            else if (q.question_type == Form_question_type.singlechoice)
            {
                valid = a.intValue != null && a.intValue > 0;
            }
            else if (q.question_type == Form_question_type.multiplechoice)
            {
                valid = a.AnswerChoices != null && a.AnswerChoices.Any(ac => ac.selected);
            }
            a.Validation = new Validation
            {
                valid   = valid,
                message = ValidationRequiredMessage
            };
            return(valid);
        }
Beispiel #2
0
 private form_question_answer CreateEmptyQuestionAnswer(Form_question q)
 {
     return(ProcessAnswerChoices(new form_question_answer
     {
         question_id = q.id,
         Question = q,
         AnswerChoices = new List <Form_submission_answer_choice>()
     }));
 }