Beispiel #1
0
        private void RenderQuestions()
        {
            IQuestion control = null;
            Collection <QuestionOption> options;

            foreach (Question question in questions)
            {
                switch ((QuestionType)question.QuestionTypeId)
                {
                case QuestionType.TextBox:
                    control = new TextBoxQuestion(question);
                    break;

                case QuestionType.DropDownList:
                    options = QuestionOption.GetAll(question.QuestionGuid);
                    control = new DropDownListQuestion(question, options);
                    break;

                case QuestionType.RadioButtonList:
                    options = QuestionOption.GetAll(question.QuestionGuid);
                    control = new RadioButtonListQuestion(question, options);
                    break;

                case QuestionType.CheckBoxList:
                    options = QuestionOption.GetAll(question.QuestionGuid);
                    control = new CheckBoxListQuestion(question, options);
                    break;

                case QuestionType.Date:
                    control = new DateQuestion(question);
                    break;

                default:
                    throw new ArgumentException("Invalid question type");
                }

                PopulateAnswer(control);

                FormGroupPanel row = new FormGroupPanel
                {
                    CssClass = "settingrow"
                };

                row.Controls.Add((CompositeControl)control);

                pnlQuestions.Controls.Add(row);
            }
        }
Beispiel #2
0
        private void RenderQuestions()
        {
            IQuestion control = null;
            Collection <QuestionOption> options;

            foreach (Question question in questions)
            {
                switch ((QuestionType)question.QuestionTypeId)
                {
                case QuestionType.TextBox:
                    control = new TextBoxQuestion(question);
                    break;

                case QuestionType.DropDownList:
                    options = QuestionOption.GetAll(question.QuestionGuid);
                    control = new DropDownListQuestion(question, options);
                    break;

                case QuestionType.RadioButtonList:
                    options = QuestionOption.GetAll(question.QuestionGuid);
                    control = new RadioButtonListQuestion(question, options);
                    break;

                case QuestionType.CheckBoxList:
                    options = QuestionOption.GetAll(question.QuestionGuid);
                    control = new CheckBoxListQuestion(question, options);
                    break;

                case QuestionType.Date:
                    control = new DateQuestion(question);
                    break;

                default:
                    throw new ArgumentException("Invalid question type");
                }

                PopulateAnswer(control);

                HtmlGenericControl row    = new HtmlGenericControl("div");
                HtmlGenericControl spacer = new HtmlGenericControl("div");
                row.Attributes.Add("class", "settingrow");
                spacer.Attributes.Add("class", "clearpanel");
                row.Controls.Add((CompositeControl)control);

                pnlQuestions.Controls.Add(row);
                pnlQuestions.Controls.Add(spacer);
            }
        }
Beispiel #3
0
        private void PopulateControls()
        {
            if (survey != null)
            {
                lnkPages.Text = string.Format(CultureInfo.InvariantCulture,
                                              SurveyResources.SurveyPagesLabelFormatString,
                                              survey.SurveyName);

                litHeading.Text = string.Format(CultureInfo.InvariantCulture,
                                                SurveyResources.QuestionEditFormatString,
                                                survey.SurveyName);
            }

            if (currentModule != null)
            {
                lnkSurveys.Text = string.Format(CultureInfo.InvariantCulture,
                                                SurveyResources.ChooseActiveSurveyFormatString,
                                                currentModule.ModuleTitle);
            }

            if (surveyPage != null)
            {
                lnkQuestions.Text = string.Format(CultureInfo.InvariantCulture,
                                                  SurveyResources.QuestionsPageFormatString,
                                                  surveyPage.PageTitle);
            }



            if (Page.IsPostBack)
            {
                return;
            }

            if (questionGuid == Guid.Empty)
            {
                lblQuestionType.Text = questionType.ToString();

                if (questionType == QuestionType.TextBox || questionType == QuestionType.Date)
                {
                    addOptionRow.Visible = false;
                    itemsRow.Visible     = false;
                }
                return;
            }

            lblQuestionType.Text      = ((QuestionType)question.QuestionTypeId).ToString();
            edMessage.Text            = question.QuestionText;
            chkAnswerRequired.Checked = question.AnswerIsRequired;
            txtValidationMessage.Text = question.ValidationMessage;

            if ((QuestionType)question.QuestionTypeId == QuestionType.TextBox || questionType == QuestionType.Date)
            {
                addOptionRow.Visible = false;
                itemsRow.Visible     = false;
            }

            foreach (QuestionOption option in QuestionOption.GetAll(questionGuid))
            {
                lbOptions.Items.Add(new ListItem(option.Answer, option.QuestionOptionGuid.ToString()));
            }
        }