Ejemplo n.º 1
0
        protected void UpdateAnswerButton_Click(object sender, EventArgs e)
        {
            Page.Validate("AnswerValidation");
            if (Page.IsValid)
            {
                LinkButton updateAnswerButton    = (LinkButton)sender;
                List <SurveyOptionsInfo> answers = Answers;
                if (answers == null)
                {
                    answers = new List <SurveyOptionsInfo>();
                }

                if (Request.Form["SurveyOptionID"] != null)
                {
                    int[] surveyOptionIDs = (from p in Request.Form["SurveyOptionID"].Split(',')
                                             select int.Parse(p)).ToArray();
                    int viewOrder = 1;
                    foreach (int surveyOptionID in surveyOptionIDs)
                    {
                        SurveyOptionsInfo answer = answers.Find(x => x.SurveyOptionID == surveyOptionID);
                        answer.ViewOrder = viewOrder;
                        viewOrder++;
                    }
                }

                if (SurveyOptionID == 0)
                {
                    MaxViewOrder = MaxViewOrder + 1;
                    SurveyOptionsInfo surveyOption = new SurveyOptionsInfo();
                    surveyOption.OptionName      = AnswerTextBox.Text;
                    surveyOption.IsCorrect       = CorrectAnswerCheckBox.Checked;
                    surveyOption.SurveyOptionID  = MaxViewOrder * (-1);
                    surveyOption.ViewOrder       = MaxViewOrder;
                    surveyOption.Votes           = 0;
                    surveyOption.CreatedByUserID = UserId;
                    surveyOption.CreatedDate     = DateTime.Now;
                    answers.Add(surveyOption);
                    answers.OrderBy(so => so.ViewOrder);
                }
                else
                {
                    SurveyOptionsInfo surveyOption = SurveyOption;
                    answers.Remove(answers.Find(so => so.SurveyOptionID == SurveyOptionID));
                    surveyOption.OptionName = AnswerTextBox.Text;
                    surveyOption.IsCorrect  = CorrectAnswerCheckBox.Checked;
                    answers.Add(surveyOption);
                    answers.OrderBy(so => so.ViewOrder);
                    SurveyOptionID             = 0;
                    SurveyOption               = null;
                    AddAnswerButton.Visible    = true;
                    UpdateAnswerButton.Visible = false;
                }
                Answers = answers;
                AnswersGrid.DataSource = Answers;
                AnswersGrid.DataBind();
                AnswerTextBox.Text            = String.Empty;
                CorrectAnswerCheckBox.Checked = false;
            }
        }
Ejemplo n.º 2
0
        protected void DeleteImage_Click(object sender, EventArgs e)
        {
            DnnImageButton deleteImage    = (DnnImageButton)sender;
            int            surveyOptionID = Convert.ToInt32(deleteImage.CommandArgument);

            List <SurveyOptionsInfo> answers = Answers;

            answers.Remove(answers.Find(so => so.SurveyOptionID == surveyOptionID));
            Answers = answers;
            AnswersGrid.DataSource = Answers;
            AnswersGrid.DataBind();
        }
Ejemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            if (!(Page.IsPostBack))
            {
                CreateQuestionTypeEntries();
                CreateRepeatDirectionEntries();
                CreateChartTypeEntries();

                CorrectAnswerPanel.Visible = (SurveyType == SurveyType.Quiz);

                if (SurveyID > 0)
                {
                    Survey  = SurveysController.Get(SurveyID);
                    Answers = SurveyOptionsController.GetAll(SurveyID);
                    QuestionTextBox.Text = Survey.Question;
                    QuestionTypeDropDownList.SelectedValue = Convert.ToInt32(Survey.OptionType).ToString();
                    ChartTypeDropDownList.SelectedValue    = Convert.ToInt32(Survey.ChartType).ToString();
                    IsStatisticalCheckBox.Checked          = (Survey.IsStatistical.HasValue ? Survey.IsStatistical.Value : false);
                    if (Survey.OptionType == QuestionType.RadioButtons || Survey.OptionType == QuestionType.CheckBoxes)
                    {
                        RepeatDirectionDropDownList.SelectedValue = Convert.ToInt32(Survey.RepeatDirection).ToString();
                        RepeatColumnsTextBox.Text = Survey.RepeatColumns.ToString();
                    }
                    else
                    {
                        NumberOfRowsTextBox.Text      = Survey.NumberOfRows.ToString();
                        IsStatisticalCheckBox.Enabled = false;
                        RepeatDirectionPanel.Visible  = false;
                        AnswersPanel.Visible          = false;
                        TextAnswerPanel.Visible       = true;
                    }
                    AnswersGrid.DataSource = Answers;
                    AnswersGrid.DataBind();
                    MaxViewOrder     = Answers.Count;
                    ChartTypeChanged = true;
                }
                if (SurveyType == SurveyType.Quiz)
                {
                    IsStatisticalPanel.Visible = true;
                }
            }
        }