Beispiel #1
0
 protected void lbDel_Click(object sender, EventArgs e)
 {
     surveyQuestionMultiPage.SelectedIndex = 1;
     surveyDataClassDataContext.hitbl_Survey_Answer_Row_SARs.DeleteOnSubmit(currentRowAnswer);
     surveyDataClassDataContext.SubmitChanges();
     Visible = false;
 }
Beispiel #2
0
 public bool SaveSubStep()
 {
     currentQuestion.QuestionText = txtQ.Content;
     litQ.Text = txtQ.Content;
     surveyDataClassDataContext.SubmitChanges();
     return(true);
 }
Beispiel #3
0
        protected void lbOK_Click(object sender, EventArgs e)
        {
            if (currentTestResult == null)
            {
                currentTestResult = new hitbl_Survey_TestResult_STR
                {
                    STR_ID = Guid.NewGuid()
                };
                currentTestResult.OBJ_ID = survey.ObjectID.Value;
                surveyDataClassDataContext.hitbl_Survey_TestResult_STRs.InsertOnSubmit(currentTestResult);
            }
            currentTestResult.ResultText = txtT.Text;
            double value;

            currentTestResult.ValueFrom = double.TryParse(txtPS.Text, out value) ? value : 0;
            currentTestResult.ValueTo   = double.TryParse(txtPE.Text, out value) ? value : 0;
            surveyDataClassDataContext.SubmitChanges();
        }
Beispiel #4
0
        private void FillEditForm()
        {
            FillHiddenFields();

            //Add the "AddNewPage" Tab
            RadPageView rpAddNew = new RadPageView
            {
                ID = "NewPage"
            };

            radMultiPage.PageViews.Add(rpAddNew);
            radTab.Tabs.Add(new RadTab(GuiLanguage.GetGuiLanguage("DataObjectSurvey").GetString("TabAddNewPage"), "NewPage"));

            var allSurveyPages = from allPages in surveyDataClassDataContext.hitbl_Survey_Page_SPGs.Where(x => x.OBJ_ID == survey.ObjectID)
                                 orderby allPages.SortNumber ascending
                                 select allPages;

            if (allSurveyPages.Count() == 0)
            {
                //One Page schould allways exits.. so createit
                hitbl_Survey_Page_SPG firstPage = new hitbl_Survey_Page_SPG
                {
                    OBJ_ID     = survey.ObjectID.Value,
                    Title      = GuiLanguage.GetGuiLanguage("DataObjectSurvey").GetString("StartPageName"),
                    SortNumber = 0,
                    SPG_ID     = Guid.NewGuid()
                };
                surveyDataClassDataContext.hitbl_Survey_Page_SPGs.InsertOnSubmit(firstPage);
                surveyDataClassDataContext.SubmitChanges();
                allSurveyPages = from allPages in surveyDataClassDataContext.hitbl_Survey_Page_SPGs.Where(x => x.OBJ_ID == survey.ObjectID)
                                 orderby allPages.SortNumber ascending
                                 select allPages;
            }
            int i = 0;

            foreach (hitbl_Survey_Page_SPG surveyPage in allSurveyPages)
            {
                CreateTabContext(i++, surveyPage);
            }
        }
Beispiel #5
0
        protected void lbtnNT_OnClick(object sender, EventArgs e)
        {
            if (numberOfResultTexts == 0)
            {
                phTextResults.Controls.Add(new LiteralControl(headerText));
            }
            hitbl_Survey_TestResult_STR testResult = new hitbl_Survey_TestResult_STR
            {
                OBJ_ID = survey.ObjectID.Value,
                STR_ID = Guid.NewGuid()
            };

            surveyDataClassDataContext.hitbl_Survey_TestResult_STRs.InsertOnSubmit(testResult);
            surveyDataClassDataContext.SubmitChanges();
            LoadTestResultsControl(testResult);
        }
        private void lbtnFinish_Click(object sender, EventArgs e)
        {
            bool          isInputComplete = true;
            StringBuilder sbMailText      = new StringBuilder();
            double        calculatePoints = 0.0;
            var           surveyPages     = from allPages in surveyDataClassDataContext.hitbl_Survey_Page_SPGs.Where(x => x.OBJ_ID == dataObjectSurvey.ObjectID.Value)
                                            orderby allPages.SortNumber ascending
                                            select allPages;

            countSurveyPages = surveyPages.Count();
            string answerKey = string.Empty;
            //Save The Test for The user
            hitbl_Survey_User_Result_SUR hitblSurveyUserResult = new hitbl_Survey_User_Result_SUR
            {
                SUR_ID    = Guid.NewGuid(),
                OBJ_ID    = dataObjectSurvey.ObjectID.Value,
                TestTitle = dataObjectSurvey.Title,
                TestDate  = DateTime.Now,
                Status    = 1,
                IsContest = dataObjectSurvey.IsContest
            };

            if (Request.IsAuthenticated && !dataObjectSurvey.ShowForm)
            {
                DataObjectUser dataObjectSurveyUser = DataObject.Load <DataObjectUser>(UserDataContext.GetUserDataContext().UserID);

                if (dataObjectSurveyUser.State != ObjectState.Added)
                {
                    hitblSurveyUserResult.Email   = dataObjectSurveyUser.GetMail;
                    hitblSurveyUserResult.Name    = dataObjectSurveyUser.Name;
                    hitblSurveyUserResult.Vorname = dataObjectSurveyUser.Vorname;
                    hitblSurveyUserResult.USR_ID  = dataObjectSurveyUser.ObjectID.Value;
                }
            }
            surveyDataClassDataContext.hitbl_Survey_User_Result_SURs.InsertOnSubmit(hitblSurveyUserResult);

            foreach (hitbl_Survey_Page_SPG surveyPage in surveyPages)
            {
                foreach (hitbl_Survey_Question_SQU surveyQuestion in surveyPage.hitbl_Survey_Question_SQUs.OrderBy(x => x.SortNumber))
                {
                    sbMailText.AppendFormat("{0} <br/>", surveyQuestion.QuestionText);
                    if (surveyQuestion.QuestionType != SurveyAnswersType.NotSelected && surveyQuestion.QuestionType != SurveyAnswersType.NoAnswers)
                    {
                        hitbl_Survey_User_ResultItem_SUI hitblSurveyUserResultItem = new hitbl_Survey_User_ResultItem_SUI
                        {
                            SUI_ID       = Guid.NewGuid(),
                            SQU_ID       = surveyQuestion.SQU_ID,
                            QuestionText = surveyQuestion.QuestionText,
                            Answer       = string.Empty,
                            AnswerWeight = 0.0
                        };
                        switch (surveyQuestion.QuestionType)
                        {
                        case SurveyAnswersType.SingleTextbox:
                            answerKey = string.Format("txt_{0}", surveyQuestion.SQU_ID);
                            TextBox txtAnswer = AnswerControls[answerKey] as TextBox;
                            if (txtAnswer.Text.Trim().Length > 0)
                            {
                                try
                                {
                                    hitblSurveyUserResultItem.AnswerWeight = (surveyQuestion.hitbl_Survey_Answer_Row_SARs[0].AnswerWeight.HasValue ? surveyQuestion.hitbl_Survey_Answer_Row_SARs[0].AnswerWeight.Value : 0.0);
                                    calculatePoints = calculatePoints + hitblSurveyUserResultItem.AnswerWeight.Value;
                                    hitblSurveyUserResultItem.Answer = txtAnswer.Text;
                                    sbMailText.AppendFormat("{0} <br/><hr/>", txtAnswer.Text);
                                }
                                catch (Exception exception)
                                {
                                }
                            }
                            break;

                        case SurveyAnswersType.Textarea:
                            answerKey = string.Format("txtArea_{0}", surveyQuestion.SQU_ID);
                            TextBox txtAreaAnswer = AnswerControls[answerKey] as TextBox;
                            if (txtAreaAnswer.Text.Trim().Length > 0)
                            {
                                try
                                {
                                    hitblSurveyUserResultItem.AnswerWeight = (surveyQuestion.hitbl_Survey_Answer_Row_SARs[0].AnswerWeight.HasValue ? surveyQuestion.hitbl_Survey_Answer_Row_SARs[0].AnswerWeight.Value : 0.0);
                                    calculatePoints = calculatePoints + hitblSurveyUserResultItem.AnswerWeight.Value;
                                    hitblSurveyUserResultItem.Answer = txtAreaAnswer.Text;
                                    sbMailText.AppendFormat("{0} <br/><hr/>", txtAreaAnswer.Text);
                                }
                                catch (Exception exception)
                                {
                                }
                            }
                            break;

                        case SurveyAnswersType.MultipleChoiceMultipleAnswers:
                            answerKey = string.Format("cbl{0}", surveyQuestion.SQU_ID);
                            CheckBoxList cbl = AnswerControls[answerKey] as CheckBoxList;
                            foreach (ListItem item in cbl.Items)
                            {
                                if (item.Selected)
                                {
                                    try
                                    {
                                        hitblSurveyUserResultItem.AnswerWeight = +Convert.ToDouble(item.Value.Split('_')[0]);
                                        calculatePoints = calculatePoints + hitblSurveyUserResultItem.AnswerWeight.Value;
                                        hitblSurveyUserResultItem.Answer += item.Text + ",";
                                    }
                                    catch (Exception exception)
                                    {
                                    }
                                }
                            }
                            hitblSurveyUserResultItem.Answer = hitblSurveyUserResultItem.Answer.TrimEnd(',');
                            sbMailText.AppendFormat("{0} <br/><hr/>", hitblSurveyUserResultItem.Answer);

                            break;

                        case SurveyAnswersType.MultipleChoiceOnlyOneAnswer:
                            answerKey = string.Format("rbl{0}", surveyQuestion.SQU_ID);
                            RadioButtonList rbl = AnswerControls[answerKey] as RadioButtonList;
                            if (rbl.SelectedIndex >= 0)
                            {
                                try
                                {
                                    hitblSurveyUserResultItem.AnswerWeight = +Convert.ToDouble(rbl.SelectedValue.Split('_')[0]);
                                    calculatePoints = calculatePoints + Convert.ToDouble(rbl.SelectedValue.Split('_')[0]);

                                    hitblSurveyUserResultItem.Answer += rbl.SelectedItem.Text;
                                    sbMailText.AppendFormat("{0} <br/><hr/>", rbl.SelectedItem.Text);
                                }
                                catch (Exception exception)
                                {
                                }
                            }
                            else
                            {
                                isInputComplete = false;
                            }
                            break;

                        default:
                            break;
                        }
                        hitblSurveyUserResult.hitbl_Survey_User_ResultItem_SUIs.Add(hitblSurveyUserResultItem);
                    }
                }
            }
            if (isInputComplete)
            {
                hitblSurveyUserResult.TotalTestResult = calculatePoints;
                if (dataObjectSurvey.PunkteGruen > dataObjectSurvey.PunkteRot)
                {
                    //The more points the "greener"
                    if (calculatePoints >= 0.0 && calculatePoints <= dataObjectSurvey.PunkteRot)
                    {
                        hitblSurveyUserResult.Light = SurveySemaphore.Red.ToString();
                    }
                    else if (calculatePoints > dataObjectSurvey.PunkteRot && calculatePoints <= dataObjectSurvey.PunkteGelb)
                    {
                        hitblSurveyUserResult.Light = SurveySemaphore.Yellow.ToString();
                    }
                    else
                    {
                        hitblSurveyUserResult.Light = SurveySemaphore.Green.ToString();
                    }
                }
                else
                {
                    //The more points the "reder"
                    if (calculatePoints >= 0.0 && calculatePoints <= dataObjectSurvey.PunkteGruen)
                    {
                        hitblSurveyUserResult.Light = SurveySemaphore.Red.ToString();
                    }
                    else if (calculatePoints > dataObjectSurvey.PunkteGruen && calculatePoints <= dataObjectSurvey.PunkteGelb)
                    {
                        hitblSurveyUserResult.Light = SurveySemaphore.Yellow.ToString();
                    }
                    else
                    {
                        hitblSurveyUserResult.Light = SurveySemaphore.Green.ToString();
                    }
                }
                radMP.Visible = false;
                pager.Controls.Clear();
                litHeader.Controls.Clear();
                litFooter.Controls.Clear();
                var surveyResult = (from allResults in surveyDataClassDataContext.hitbl_Survey_TestResult_STRs.Where(x => x.OBJ_ID == dataObjectSurvey.ObjectID.Value && calculatePoints >= x.ValueFrom && calculatePoints <= x.ValueTo)
                                    orderby allResults.ValueFrom ascending
                                    select allResults).SingleOrDefault();
                if (surveyResult != null)
                {
                    litHeader.Text = surveyResult.ResultText;
                }
                else
                {
                    litHeader.Text = !dataObjectSurvey.IsContest ? string.Format(GuiLanguage.GetGuiLanguage("DataObjectSurvey").GetString("DefaultTestResult"), dataObjectSurvey.Title) : string.Format(GuiLanguage.GetGuiLanguage("DataObjectSurvey").GetString("DefaultContestResult"), dataObjectSurvey.Title);
                }
                if (dataObjectSurvey.ShowForm)
                {
                    hidResult.Value               = litHeader.Text;
                    hidQA.Value                   = sbMailText.ToString();
                    hidSURID.Value                = hitblSurveyUserResult.SUR_ID.ToString();
                    pnlFormular.Visible           = true;
                    RevEMail.ValidationExpression = Constants.REGEX_EMAIL;
                    FillFormData();
                    litHeader.Text = string.Empty;
                }
                hitblSurveyUserResult.TestResultText = litHeader.Text;
                surveyDataClassDataContext.SubmitChanges(ConflictMode.FailOnFirstConflict);
            }
            else
            {
                litFooter.Text = "<div class=\"errorText\" style=\"margin-top:10px;\">Bitte beantworten Sie alle Fragen!</div>";
            }
        }