Exemple #1
0
        /// <summary>
        /// Adds the answer.
        /// </summary>
        /// <param name="answer">The answer.</param>
        public void AddAnswer(UPQuestionnaireAnswer answer)
        {
            if (this.answers == null)
            {
                this.answers = new List <IQuestionnaireAnswerOption> {
                    answer
                };
            }
            else
            {
                this.answers.Add(answer);
            }

            if (answer.AnswerId != null)
            {
                if (this.answerDictionary == null)
                {
                    this.answerDictionary = new Dictionary <string, IQuestionnaireAnswerOption> {
                        { answer.AnswerId, answer }
                    };
                }
                else
                {
                    this.answerDictionary[answer.AnswerId] = answer;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Nexts the question with answer.
        /// </summary>
        /// <param name="answer">The answer.</param>
        /// <returns></returns>
        public UPQuestionnaireQuestion NextQuestionWithAnswer(string answer)
        {
            UPQuestionnaireAnswer answerOption = this.answerDictionary.ValueOrDefault(answer) as UPQuestionnaireAnswer;

            if (answerOption != null)
            {
                string nextQuestionId = answerOption.NextQuestionId;
                return(IsEmptyQuestionId(nextQuestionId) ? this.NextQuestion : this.Questionnaire.QuestionForId(nextQuestionId));
            }

            return(this.NextQuestion);
        }
Exemple #3
0
        /// <summary>
        /// Gets the answers.
        /// </summary>
        /// <value>
        /// The answers.
        /// </value>
        public List <IQuestionnaireAnswerOption> Answers()
        {
            if (!this.answersInitialized && this.answers == null)
            {
                if (!string.IsNullOrEmpty(this.InfoAreaId) && this.FieldId >= 0)
                {
                    if (this.FieldInfo.IsCatalogField)
                    {
                        UPCatalog catalog = UPCRMDataStore.DefaultStore.CatalogForCrmField(this.Field);
                        if (!catalog.IsDependent)
                        {
                            Dictionary <string, string> values = catalog.TextValuesForFieldValues(false);
                            if (values.Count > 0)
                            {
                                this.answers = UPQuestionnaireAnswer.AnswersFromCatalogValueDictionary(values);
                            }

                            if (this.multiple && !this.Questionnaire.Manager.MultipleAnswersForCatalogs)
                            {
                                this.multiple = false;
                            }
                        }
                    }
                }

                this.answersInitialized = true;
                if (this.answers?.Count > 0)
                {
                    this.answerDictionary = new Dictionary <string, IQuestionnaireAnswerOption>();
                    foreach (IQuestionnaireAnswerOption answerOption in this.answers)
                    {
                        if (answerOption.AnswerId != null)
                        {
                            this.answerDictionary[answerOption.AnswerId] = answerOption;
                        }
                    }
                }
                else
                {
                    this.multiple = false;
                }
            }

            return(this.answers);
        }
        /// <summary>
        /// Answerses from result.
        /// </summary>
        /// <param name="result">The result.</param>
        private void AnswersFromResult(UPCRMResult result)
        {
            int count = result.RowCount;

            for (int i = 0; i < count; i++)
            {
                UPQuestionnaireAnswer answer = new UPQuestionnaireAnswer((UPCRMResultRow)result.ResultRowAtIndex(i));

                UPQuestionnaireQuestion question = this.QuestionForId(answer.QuestionId);
                question.AddAnswer(answer);
            }

            IQuestionnaireDelegate theDelegate = this.LoadDelegate;

            this.LoadDelegate = null;
            this.Manager.QuestionnaireLoadedError(this, null);
            theDelegate.QuestionnaireDidFinishWithResult(this, this);
        }