コード例 #1
0
        /// <summary>
        /// Pages for mandatory.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns></returns>
        public Page PageForMandatory(Page page)
        {
            Page newPage = this.InstantiatePage();

            foreach (UPMQuestionnaireGroup currentGroup in page.Groups)
            {
                UPMQuestionnaireGroup questionnaireGroup = new UPMQuestionnaireGroup(currentGroup.Identifier)
                {
                    LabelText = currentGroup.LabelText
                };
                bool insertGroup = false;
                foreach (UPMQuestionnaireQuestion currentQuestion in currentGroup.Questions)
                {
                    if (!currentQuestion.Mandatory)
                    {
                        continue;
                    }

                    insertGroup = true;
                    questionnaireGroup.AddQuestion(currentQuestion);
                }

                if (insertGroup)
                {
                    newPage.AddGroup(questionnaireGroup);
                }
            }

            return(newPage);
        }
コード例 #2
0
        private static void ProcessEditField(
            UPMQuestionnaireGroup questionnaireGroup,
            UPQuestionnaireQuestion currentQuestion,
            UPMEditField editField,
            IQuestionnaireEditFieldContext editFieldContext,
            UPQuestionnaireCatalogEditField catalogEditField,
            string surveyAnswer,
            IList <string> answerIds,
            bool multiSelect)
        {
            if (questionnaireGroup == null)
            {
                throw new ArgumentNullException(nameof(questionnaireGroup));
            }

            if (currentQuestion == null)
            {
                throw new ArgumentNullException(nameof(currentQuestion));
            }

            if (editFieldContext == null)
            {
                throw new ArgumentNullException(nameof(editFieldContext));
            }

            if (answerIds == null)
            {
                throw new ArgumentNullException(nameof(answerIds));
            }

            editField.LabelText       = currentQuestion.Label;
            editField.DetailText      = currentQuestion.AdditionalInfo;
            editField.RequiredField   = currentQuestion.Mandatory;
            editFieldContext.Question = currentQuestion;

            if (multiSelect)
            {
                if (catalogEditField != null)
                {
                    foreach (string a in answerIds)
                    {
                        catalogEditField.AddFieldValue(a);
                    }
                }
            }
            else
            {
                editField.FieldValue = surveyAnswer;
            }

            editField.ContinuousUpdate = true;
            var questionnaireQuestion = new UPMQuestionnaireQuestion(editField)
            {
                Mandatory = currentQuestion.Mandatory
            };

            questionnaireGroup.AddQuestion(questionnaireQuestion);
        }
コード例 #3
0
        /// <summary>
        /// Pages for overview.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns></returns>
        public Page PageForOverview(Page page)
        {
            Page newPage = this.InstantiatePage();

            if (this.portfolioGroup != null)
            {
                newPage.AddGroup(this.portfolioGroup);
            }

            foreach (UPMQuestionnaireGroup currentGroup in page.Groups)
            {
                UPMQuestionnaireGroup questionnaireGroup = new UPMQuestionnaireGroup(currentGroup.Identifier)
                {
                    LabelText = currentGroup.LabelText
                };
                bool insertGroup = false;
                foreach (UPMQuestionnaireQuestion currentQuestion in currentGroup.Questions)
                {
                    if (currentQuestion.Field.Empty)
                    {
                        continue;
                    }

                    insertGroup = true;
                    UPMEditField editField = (UPMEditField)currentQuestion.Field;
                    UPMField     field     = new UPMStringField(editField.Identifier)
                    {
                        LabelText = editField.LabelText
                    };
                    if (!editField.Empty)
                    {
                        field.FieldValue = editField.StringDisplayValue;
                    }

                    UPMQuestionnaireQuestion questionnaireQuestion = new UPMQuestionnaireQuestion(field);
                    questionnaireGroup.AddQuestion(questionnaireQuestion);
                }

                if (insertGroup)
                {
                    newPage.AddGroup(questionnaireGroup);
                }
            }

            return(newPage);
        }
コード例 #4
0
        /// <summary>
        /// Progresses the type for group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public QuestionnaireProgressType ProgressTypeForGroup(UPMQuestionnaireGroup group)
        {
            QuestionnaireProgressType progressType = QuestionnaireProgressType.NoQuestions;
            int countMandatory       = 0;
            int countMandatoryAnswer = 0;
            int countAll             = 0;
            int countAllAnswer       = 0;

            foreach (UPMQuestionnaireQuestion questionnaireQuestion in group.Questions)
            {
                countAll++;
                if (questionnaireQuestion.Mandatory)
                {
                    countMandatory++;
                }

                if (!questionnaireQuestion.Empty)
                {
                    countAllAnswer++;
                    if (questionnaireQuestion.Mandatory)
                    {
                        countMandatoryAnswer++;
                    }
                }
            }

            if (countAllAnswer == 0)
            {
                progressType = QuestionnaireProgressType.NoQuestions;
            }
            else if (countAll == countAllAnswer)
            {
                progressType = QuestionnaireProgressType.AllQuestions;
            }
            else if (countMandatory == countMandatoryAnswer)
            {
                progressType = QuestionnaireProgressType.AllMandatory;
            }
            else if (countMandatory > countMandatoryAnswer)
            {
                progressType = QuestionnaireProgressType.NotAllMandatory;
            }

            return(progressType);
        }
コード例 #5
0
        /// <summary>
        /// Completes for group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public int CompleteForGroup(UPMQuestionnaireGroup group)
        {
            if (group.Questions.Count == 0)
            {
                return(0);
            }

            int countEmpty = 0;

            foreach (UPMQuestionnaireQuestion currentQuestion in group.Questions)
            {
                if (currentQuestion.Field.Empty)
                {
                    countEmpty++;
                }
            }

            return(Convert.ToInt32((float)(group.Questions.Count - countEmpty) / group.Questions.Count * 100));
        }
コード例 #6
0
        private void ProcessGroup(UPMQuestionnairePage page, int index, UPQuestionnaireQuestionGroup currentGroup)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            if (currentGroup == null)
            {
                throw new ArgumentNullException(nameof(currentGroup));
            }

            bool firstQuestion      = true;
            var  questionnaireGroup = new UPMQuestionnaireGroup(StringIdentifier.IdentifierWithStringId($"group_{currentGroup.Label}"))
            {
                LabelText = currentGroup.Label
            };

            page.AddGroup(questionnaireGroup);
            var questions = this.Survey.VisibleQuestionsForGroup(currentGroup);

            foreach (var currentQuestion in questions)
            {
                if (currentQuestion.Hide)
                {
                    continue;
                }

                UPMEditField editField = null;
                IQuestionnaireEditFieldContext  editFieldContext = null;
                UPQuestionnaireCatalogEditField catalogEditField = null;
                if (firstQuestion)
                {
                    if (string.IsNullOrEmpty(questionnaireGroup.LabelText))
                    {
                        questionnaireGroup.LabelText = currentQuestion.Label;
                    }

                    firstQuestion = false;
                }

                var  fieldIdentifier  = StringIdentifier.IdentifierWithStringId($"{currentQuestion.RecordIdentification}_{index}");
                var  surveyAnswer     = this.Survey.SurveyAnswerForQuestion(currentQuestion);
                var  answerIds        = surveyAnswer.AnswerIds;
                bool multiSelect      = currentQuestion.Multiple;
                var  explicitKeyOrder = new List <string>();

                CreateFields(
                    currentQuestion,
                    out editField,
                    out editFieldContext,
                    out catalogEditField,
                    fieldIdentifier,
                    multiSelect,
                    explicitKeyOrder);

                if (editField != null)
                {
                    ProcessEditField(
                        questionnaireGroup,
                        currentQuestion,
                        editField,
                        editFieldContext,
                        catalogEditField,
                        surveyAnswer.Answer,
                        answerIds,
                        multiSelect);
                }
            }
        }