Example #1
0
        public void RenderAnswers()
        {
            var ds = SQChoices.GetAll(int.Parse(QID));

            if (DisplayControl == "3") //drop down
            {
                ddMultipleChoice.Visible = true;
                ddMultipleChoice.Items.Clear();
                ddMultipleChoice.Items.Add(new ListItem("[ Make a selection ]", "0"));
                foreach (DataRow r  in ds.Tables[0].Rows)
                {
                    ddMultipleChoice.Items.Add(new ListItem(Convert.ToString(r["ChoiceText"]), r["SQCID"].ToString()));
                }
                rfvddMultipleChoice.Enabled = (IsRequired == "yes");
            }

            if (DisplayControl == "1") //check
            {
                rptrChk.DataSource = ds;
                rptrChk.DataBind();
                CheckBoxScripts();
            }//

            if (DisplayControl == "2") //radio
            {
                rptrRadio.DataSource = ds;
                rptrRadio.DataBind();
                if (DisplayDirection != "1")
                {
                    RadioBoxScripts();
                }
            }//
        }
Example #2
0
        protected void btnAddAnswer4_Click(object sender, EventArgs e)
        {
            if (Session["tmpQ4"] == null)
            {
                Session["tmpQ4"] = SQChoices.GetAll(-1);
            }
            var tmpC4 = (int)Session["tmpC4"];

            tmpC4++;
            var     ds     = (DataSet)Session["tmpQ4"];
            DataRow newRow = ds.Tables[0].NewRow();

            newRow["ChoiceOrder"]    = tmpC4;
            newRow["ChoiceText"]     = ChoiceText4.Text;
            newRow["Score"]          = Score4.Text.SafeToInt();
            newRow["JumpToQuestion"] = JumpToQuestion4.Text.SafeToInt();
            ds.Tables[0].Rows.Add(newRow);

            Session["tmpQ4"] = ds;
            Session["tmpC4"] = tmpC4;

            rptrAnswers4.DataSource = ds;
            rptrAnswers4.DataBind();

            ChoiceText4.Text = "";
            Score4.Text      = "";
            JumpToQuestion4.SelectedValue = "0";
        }
Example #3
0
        protected void btnAddAnswer2_Click(object sender, EventArgs e)
        {
            if (Session["tmpQ2"] == null)
            {
                Session["tmpQ2"] = SQChoices.GetAll(-1);
            }
            var tmpC2 = (int)Session["tmpC2"];

            tmpC2++;
            var     ds     = (DataSet)Session["tmpQ2"];
            DataRow newRow = ds.Tables[0].NewRow();

            newRow["ChoiceOrder"]           = tmpC2;
            newRow["ChoiceText"]            = ChoiceText2.Text;
            newRow["Score"]                 = Score2.Text.SafeToInt();
            newRow["JumpToQuestion"]        = JumpToQuestion2.Text.SafeToInt();
            newRow["AskClarification"]      = AskClarification2.Checked;
            newRow["ClarificationRequired"] = ClarificationRequired2.Checked;
            ds.Tables[0].Rows.Add(newRow);

            Session["tmpQ2"] = ds;
            Session["tmpC2"] = tmpC2;

            rptrAnswers2.DataSource = ds;
            rptrAnswers2.DataBind();

            ChoiceText2.Text = "";
            Score2.Text      = "";
            JumpToQuestion2.SelectedValue  = "0";
            AskClarification2.Checked      = false;
            ClarificationRequired2.Checked = false;
        }
Example #4
0
        protected void btnClone_Click(object sender, ImageClickEventArgs e)
        {
            var so = Survey.FetchObject(int.Parse(SID.Text));
            var sn = Survey.FetchObject(int.Parse(SID.Text));

            sn.SID    = 0;
            sn.Name   = txtNewName.Text;
            sn.Status = 1;
            sn.Insert();

            var ds1 = SurveyQuestion.GetAll(so.SID);

            foreach (DataRow r1 in ds1.Tables[0].Rows)
            {
                var QID = Convert.ToInt32(r1["QID"]);

                var q = SurveyQuestion.FetchObject(QID);
                q.SID = sn.SID;
                q.QID = 0;
                q.Insert();

                var ds2 = SQChoices.GetAll(QID);
                foreach (DataRow r2 in ds2.Tables[0].Rows)
                {
                    var SQCID = Convert.ToInt32(r2["SQCID"]);
                    var c     = SQChoices.FetchObject(SQCID);
                    c.SQCID = 0;
                    c.QID   = q.QID;
                    c.Insert();
                }

                var ds3 = SQMatrixLines.GetAll(QID);
                foreach (DataRow r3 in ds3.Tables[0].Rows)
                {
                    var SQMLID = Convert.ToInt32(r3["SQMLID"]);
                    var l      = SQMatrixLines.FetchObject(SQMLID);
                    l.SQMLID = 0;
                    l.QID    = q.QID;
                    l.Insert();
                }
            }
            Session["SID"] = sn.SID;
            Response.Redirect("SurveyList.aspx");
            Response.Redirect("SurveyAddEdit.aspx");
        }
Example #5
0
        public int JumpLogicActivated()
        {
            int qtype = 0;

            int.TryParse(lblQType.Text, out qtype);

            switch (qtype)
            {
            case 1:
                return(-1);

            case 3:
                return(-1);

            case 2:
                var ds1 = SQChoices.GetAll(int.Parse(QID));
                if (DisplayControl == "1")
                {
                    foreach (RepeaterItem rChkI in rptrChk.Items)
                    {
                        var SQCID  = rChkI.FindControl("SQCID") as Label;
                        var chkAns = rChkI.FindControl("chkAns") as CheckBox;
                        if (chkAns.Checked)
                        {
                            foreach (DataRow dr1 in ds1.Tables[0].Rows)
                            {
                                if (Convert.ToString(dr1["SQCID"]) == SQCID.Text && Convert.ToInt32(dr1["JumpToQuestion"]) > 0)
                                {
                                    return(Convert.ToInt32(dr1["JumpToQuestion"]));
                                }
                            }
                        }
                    }
                }
                if (DisplayControl == "2")
                {
                    foreach (RepeaterItem rRdoI in rptrRadio.Items)
                    {
                        var SQCID = rRdoI.FindControl("SQCID") as Label;
                        var rbAns = rRdoI.FindControl("rbAns") as RadioButton;
                        if (rbAns.Checked)
                        {
                            foreach (DataRow dr1 in ds1.Tables[0].Rows)
                            {
                                if (Convert.ToString(dr1["SQCID"]) == SQCID.Text && Convert.ToInt32(dr1["JumpToQuestion"]) > 0)
                                {
                                    return(Convert.ToInt32(dr1["JumpToQuestion"]));
                                }
                            }
                        }
                    }
                }
                if (DisplayControl == "3")
                {
                    var SQCID = ddMultipleChoice.SelectedValue;
                    foreach (DataRow dr1 in ds1.Tables[0].Rows)
                    {
                        if (Convert.ToString(dr1["SQCID"]) == SQCID && Convert.ToInt32(dr1["JumpToQuestion"]) > 0)
                        {
                            return(Convert.ToInt32(dr1["JumpToQuestion"]));
                        }
                    }
                }
                return(-1);

            case 4:
                var ds2 = SQChoices.GetAll(int.Parse(QID));
                foreach (RepeaterItem rLine in rptrMRows.Items)
                {
                    if (DisplayControl == "1")
                    {
                        var rptrCheckCols = rLine.FindControl("rptrCheckCols") as Repeater;
                        foreach (RepeaterItem rChkI in rptrCheckCols.Items)
                        {
                            var chkAns      = rChkI.FindControl("rbChoice") as CheckBox;
                            var ChoiceOrder = rChkI.FindControl("ChoiceOrder") as Label;
                            var JumpQ       = Convert.ToInt32(ds2.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["JumpToQuestion"]);
                            if (chkAns.Checked && JumpQ > 0)
                            {
                                return(JumpQ);
                            }
                        }
                    }
                    if (DisplayControl == "2")
                    {
                        var rptrRadioCols = rLine.FindControl("rptrRadioCols") as Repeater;
                        foreach (RepeaterItem rRdoI in rptrRadioCols.Items)
                        {
                            var rbAns       = rRdoI.FindControl("rbChoice") as RadioButton;
                            var ChoiceOrder = rRdoI.FindControl("ChoiceOrder") as Label;
                            var JumpQ       = Convert.ToInt32(ds2.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["JumpToQuestion"]);
                            if (rbAns.Checked && JumpQ > 0)
                            {
                                return(JumpQ);
                            }
                        }
                    }
                }
                return(-1);

            case 5:
                return(-1);

            case 6:
                return(-1);
            }
            return(-1);
        }
Example #6
0
        public void SaveMatrix()
        {
            int SRPK = int.Parse(SRID);
            var ds   = SQChoices.GetAll(int.Parse(QID));

            foreach (RepeaterItem rLine in rptrMRows.Items)
            {
                var obj1 = SurveyResults.FetchObject(SRPK);
                var obj2 = new SurveyAnswers();

                obj2.SRID  = obj1.SRID;
                obj2.TenID = obj1.TenID;
                obj2.PID   = obj1.PID;
                obj2.SID   = obj1.SID;

                obj2.QID          = int.Parse(QID);
                obj2.DateAnswered = DateTime.Now;
                obj2.QType        = 4;

                var SQMLID = rLine.FindControl("SQMLID") as Label;
                obj2.SQMLID = int.Parse(SQMLID.Text);

                if (DisplayControl == "1")
                {
                    var rptrCheckCols = rLine.FindControl("rptrCheckCols") as Repeater;
                    foreach (RepeaterItem rChkI in rptrCheckCols.Items)
                    {
                        var SQCID       = rChkI.FindControl("SQCID") as Label;
                        var chkAns      = rChkI.FindControl("rbChoice") as CheckBox;
                        var ChoiceOrder = rChkI.FindControl("ChoiceOrder") as Label;
                        var AnsText     = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString();
                        if (chkAns.Checked)
                        {
                            obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);


                            obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText);
                        }
                    }
                }
                if (DisplayControl == "2")
                {
                    var rptrRadioCols = rLine.FindControl("rptrRadioCols") as Repeater;
                    foreach (RepeaterItem rRdoI in rptrRadioCols.Items)
                    {
                        var SQCID       = rRdoI.FindControl("SQCID") as Label;
                        var rbAns       = rRdoI.FindControl("rbChoice") as RadioButton;
                        var ChoiceOrder = rRdoI.FindControl("ChoiceOrder") as Label;
                        var AnsText     = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString();


                        if (rbAns.Checked)
                        {
                            obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                            obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText);
                        }
                    }
                }

                obj2.Insert();
            }
        }
        public string DisplayAnswers(int QType, int QID, int SQMLID, string ChoiceAnswerIDs, string ChoiceAnswerText, string ClarificationText, bool MXShowChoices)
        {
            var displayString = string.Empty;

            if (QType == 2) // Multiple Choice
            {
                string[] separators = { "~|~" };
                var      mcIDs      = ChoiceAnswerIDs.Split(',');
                var      mcTXs      = ChoiceAnswerIDs.Split(separators, StringSplitOptions.None);
                var      mcCLs      = ClarificationText.Split(separators, StringSplitOptions.None);

                var ds4 = SQChoices.GetAll(QID);
                foreach (DataRow dr4 in ds4.Tables[0].Rows)
                {
                    var idx4      = -1;
                    var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                    var ansString = string.Format("<tr><td valign='top'><b>{2}</b></td><td valign='top' nowrap>{0}</td><td nowrap style='padding-right: 5px;' align='right' valign='top'>({1} pts)</td><td style='padding-left:10px;' valign='top'>{3}</td></tr>"
                                                  , dr4["ChoiceText"].ToString(), ((int)dr4["Score"])
                                                  , match ? " X " : ""
                                                  , match ? mcCLs[idx4] : ""

                                                  );
                    displayString = string.Format("{0}{1}", displayString, ansString);
                }

                displayString = string.Format("<table cellpadding=5> {0} </table>", displayString);
            }

            if (QType == 4) // Matrix
            {
                string[] separators = { "~|~" };
                var      mcIDs      = ChoiceAnswerIDs.Split(',');
                var      mcTXs      = ChoiceAnswerIDs.Split(separators, StringSplitOptions.None);
                var      mcCLs      = ClarificationText.Split(separators, StringSplitOptions.None);


                var ds4 = SQChoices.GetAll(QID);
                var ml  = SQMatrixLines.FetchObject(SQMLID);

                displayString = string.Format("<tr><td valign='top' style='padding-right: 5px;' width='50%'>{0}</td>", ml.LineText);
                var w = (int)(50 / ds4.Tables[0].Rows.Count);

                if (MXShowChoices)
                {
                    foreach (DataRow dr4 in ds4.Tables[0].Rows)
                    {
                        var idx4      = -1;
                        var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                        var ansString = string.Format("<td valign='top' align='center' width='{4}%' >{0} ({1} pts) <br> <b>{2}</b> <br> <div style='text-align: left;'>{3}</div></td>"
                                                      , dr4["ChoiceText"].ToString()
                                                      , ((int)dr4["Score"])
                                                      , match ? " X " : ""
                                                      , match ? mcCLs[idx4] : ""
                                                      , w
                                                      );
                        displayString = string.Format("{0}{1}", displayString, ansString);
                    }
                }
                else
                {
                    foreach (DataRow dr4 in ds4.Tables[0].Rows)
                    {
                        var idx4      = -1;
                        var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                        var ansString = string.Format("<td valign='top' align='center' width='{2}%' ><b>{0}</b> <br> <div style='text-align: left;'>{1}</div></td>"
                                                      , match ? " X " : ""
                                                      , match ? mcCLs[idx4] : ""
                                                      , w
                                                      );
                        displayString = string.Format("{0}{1}", displayString, ansString);
                    }
                }

                displayString = string.Format("<table cellpadding=5 width='100%'> {0} </tr></table>", displayString);
            }

            return(displayString);
        }