protected void BtnSave_Click(object sender, EventArgs e)
        {
            Page.Validate("survey");
            if (Page.IsValid)
            {
                Question question = new Question(questionGuid);
                SaveQuestion(question);

                if (question.QuestionTypeId != (int) QuestionType.TextBox || question.QuestionTypeId != (int) QuestionType.Date)
                {
                    DeleteOldQuestionOptions();
                    SaveQuestionOptions(question);
                }

                SurveyFeature.Business.Page page = new SurveyFeature.Business.Page(question.SurveyPageGuid);

                WebUtils.SetupRedirect(this, SiteRoot + "/Survey/SurveyQuestions.aspx?SurveyGuid="
                    + page.SurveyGuid.ToString() + "&SurveyPageGuid=" + page.SurveyPageGuid.ToString()
                    + "&pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString());
            }
        }
 public DropDownListQuestion(Question question, Collection<QuestionOption> options)
 {
     _question = question;
     _options = options;
 }
 public RadioButtonListQuestion(Question question, Collection<QuestionOption> options)
 {
     _question = question;
     _options = options;
 }
        private void SaveQuestionOptions(Question question)
        {
            QuestionOption option;
            int order = 0;

            // Save options

            foreach (ListItem item in lbOptions.Items)
            {
                Guid optionGuid = Guid.Empty;
                if (item.Value.Length == 36)
                {
                    try
                    {
                        optionGuid = new Guid(item.Value);
                    }
                    catch (FormatException) {  }
                    catch (OverflowException) { }

                }

                if (optionGuid == Guid.Empty)
                {
                    option = new QuestionOption();
                }
                else
                {
                    option = new QuestionOption(optionGuid);
                }

                //if (item.Text == item.Value)
                //{
                //    option = new QuestionOption();
                //}
                //else
                //{
                //    option = new QuestionOption(new Guid(item.Value));
                //}

                option.Answer = item.Text;
                option.QuestionGuid = question.QuestionGuid;
                option.Order = order++;
                option.Save();
            }
        }
        private void LoadSettings()
        {
            pageId = WebUtils.ParseInt32FromQueryString("PageId", pageId);
            questionGuid = WebUtils.ParseGuidFromQueryString("QuestionGuid", Guid.Empty);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            currentModule = GetModule(moduleId, Survey.FeatureGuid);
            question = new Question(questionGuid);

            if (questionGuid != Guid.Empty)
            {

                surveyPageGuid = question.SurveyPageGuid;

            }
            else
            {
                //we have no question guid so must be a new question
                string questionTypeParam = Request.QueryString["NewQuestionType"];
                questionType = EnumHelper<QuestionType>.Parse(questionTypeParam);
                surveyPageGuid = WebUtils.ParseGuidFromQueryString("SurveyPageGuid", Guid.Empty);
                question.SurveyPageGuid = surveyPageGuid;

            }

            if (surveyPageGuid != Guid.Empty)
            {
                surveyPage = new SurveyFeature.Business.Page(surveyPageGuid);

                survey = new Survey(surveyPage.SurveyGuid);
                surveyGuid = survey.SurveyGuid;

                if (survey.SiteGuid != siteSettings.SiteGuid)
                {
                    surveyGuid = Guid.Empty;
                    survey = null;

                    surveyPageGuid = Guid.Empty;
                    surveyPage = null;

                    questionGuid = Guid.Empty;
                    question = null;

                }
            }

            AddClassToBody("surveyquestionedit");
        }
        //private void SetupBreadCrumb()
        //{
        //    Guid pageRedirectGuid = Guid.Empty;
        //    if (questionGuid == Guid.Empty)
        //    {
        //        Question question = new Question(questionGuid);
        //        pageRedirectGuid = question.SurveyPageGuid;
        //    }
        //    else
        //    {
        //        pageRedirectGuid = surveyPageGuid;
        //    }
        //    SurveyFeature.Business.Page page = new SurveyFeature.Business.Page(pageRedirectGuid);
        //    lnkQuestions.NavigateUrl = "~/Survey/SurveyQuestions.aspx?SurveyPageGuid=" + surveyPageGuid + "&PageId=" + pageId + "&mid=" + moduleId;
        //    lnkPages.NavigateUrl = "~/Survey/SurveyPages.aspx?SurveyGuid=" + page.SurveyGuid + "&PageId=" + pageId + "&mid=" + moduleId;
        //    lnkSurveys.NavigateUrl = "~/Survey/Surveys.aspx?PageId=" + pageId + "&mid=" + moduleId; ;
        //}
        private void SaveQuestion(Question question)
        {
            question.QuestionText = edMessage.Text;
            question.QuestionTypeId = (int)EnumHelper<QuestionType>.Parse(lblQuestionType.Text);
            question.AnswerIsRequired = chkAnswerRequired.Checked;
            question.ValidationMessage = txtValidationMessage.Text;

            if (questionGuid == Guid.Empty)
            {
                //new question so we need to know the page it will live on
                question.SurveyPageGuid = surveyPageGuid;
            }

            question.Save();
        }
        void BtnCancel_Click(object sender, EventArgs e)
        {
            SurveyFeature.Business.Page page;

            if (surveyPageGuid == Guid.Empty)
            {
                Question question = new Question(questionGuid);
                page = new SurveyFeature.Business.Page(question.SurveyPageGuid);
            }
            else
            {
                page = new SurveyFeature.Business.Page(surveyPageGuid);
            }

            WebUtils.SetupRedirect(this, SiteRoot + "/Survey/SurveyQuestions.aspx?SurveyPageGuid=" + page.SurveyPageGuid
                + "&SurveyGuid=" + page.SurveyGuid.ToString() + "&pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString());
        }
Exemple #8
0
        public static List<Question> GetAll(Guid pageGuid)
        {
            List<Question> pageQuestionList
                = new List<Question>();

            using (IDataReader reader = DBQuestion.GetAllByPage(pageGuid))
            {
                while (reader.Read())
                {
                    Question question = new Question();
                    question.questionGuid = new Guid(reader["QuestionGuid"].ToString());
                    question.pageGuid = new Guid(reader["PageGuid"].ToString());
                    question.questionText = reader["QuestionText"].ToString();
                    question.questionTypeId = Convert.ToInt32(reader["QuestionTypeId"]);
                    question.answerIsRequired = Convert.ToBoolean(reader["AnswerIsRequired"]);
                    question.questionOrder = Convert.ToInt32(reader["QuestionOrder"]);
                    question.validationMessage = reader["ValidationMessage"].ToString();
                    pageQuestionList.Add(question);
                }
            }

            return pageQuestionList;
        }
 public CheckBoxListQuestion(Question question, Collection<QuestionOption> options)
 {
     _question = question;
     _options = options;
 }
 public TextBoxQuestion(Question question)
 {
     _question = question;
 }
Exemple #11
0
 public DateQuestion(Question question)
 {
     _question = question;
 }