private void dataShow()
 {
     question question = new question();
     question.GetModel(this.txtDocid.Value);
     this.txtName.Value = question.questioner;
     this.txtEmail.Value = question.quertionerEmail;
     this.txtDetail.Value = question.describe;
     this.txtdt_summary.Value = question.field;
 }
 //批量删除
 protected void btndelinfo_Click(object sender, EventArgs e)
 {
     HyCommon HyCommon = new HyCommon();
     question question = new question();
     String[] v_uids = this.txtuids.Value.Split(',');
     for (int i = 0; i < v_uids.Length; i++)
     {
         question.Delete(v_uids[i]);
     }
     string pageUrl = HyCommon.CombUrlTxt("questionList.aspx", "page={0}&rnd={1}", "" + this.txtPage.Text + "", "" + System.Guid.NewGuid().ToString() + "");
     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>tip('数据已经被成功删除!','" + pageUrl + "');</script>");
 }
Exemple #3
0
            public Exam(XmlNode x, int version)
            {
                start = System.IO.File.ReadAllText(@"C:\Users\khalefa\SkyDrive\Teaching\Programming II\private\Exam\header.tex");
                start = start.Replace("{version}", version.ToString());
                XmlElement qs = x["questions"];

                questions = new List<question>();
                foreach (XmlNode n in qs.ChildNodes)
                {
                    question q = new question(n);
                    questions.Add(q);
                }

                shuffle = getshuffle(qs, questions.Count);
            }
 protected void btn_save_Click(object sender, EventArgs e)
 {
     question question = new question();
     question.id = this.txtDocid.Value;
     question.GetModel(this.txtDocid.Value);
     question.questioner = this.txtName.Value;
     question.quertionerEmail = this.txtEmail.Value;
     question.describe = this.txtDetail.Value;
     question.field = this.txtdt_summary.Value;
     question.Update();
     //写日志
     HyCommon HyCommon = new HyCommon();
     HyCommon.WriteLog("修改", "修改文章记录[id:" + this.txtDocid.Value + "]", Session["uid"].ToString(), Session["uname"].ToString());
     //提示并跳转
     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>success();</script>");
 }
        public void Setup()
        {
            serviceClient = new Mock<ITreasureHuntService>();
            viewModel = new ViewHuntViewModel(serviceClient.Object);

            NewQuestion = newQuestion;

            myFakeHunt = new hunt();
            myFakeHunt.HuntName = "My Fake Hunt";
            myFakeQuestion = new question();
            myFakeQuestion.Question1 = "This is my user";
            myFakeQuestion.URL = "empty url";

            returnedHunts.Add(myFakeHunt);
            returnedIds.Add(one);

            CurrentTreasureHunt = myFakeHunt;
            CurrentQuestion = myFakeQuestion;

            huntQuestions.Add(myFakeQuestion);

            Questions = huntQuestions.AsEnumerable();
        }
Exemple #6
0
        public frmMain()
        {
            InitializeComponent();

            this.Width = 613;       // Set client width
            this.Height = 302;      // Set client height

            mSettings = new Settings();
            mUser = new User();

            mQuestion = new question();
            mAnswer = new Answer();
            mDictionarySerialiser = new DictionarySerialiserMethods();

            if (LoadUserSettings("usersettings.xml") == false)
            {
                mSettings.UserName = "******";
                mSettings.ServerIP = txtServerAddress.Text;
                mSettings.ServerPort = txtServerPort.ToString();
                mSettings.AutoLogin = false;

                SaveUserSettings(mSettings);
            }
            else
            {
                if (mSettings.AutoLogin == true)
                    StartConnectionThread();
                else
                {
                    txtUsername.Text = mSettings.UserName;
                    txtServerAddress.Text = mSettings.ServerIP;
                    txtServerPort.Text = mSettings.ServerPort;
                    chkStayLoggedIn.Checked = mSettings.AutoLogin;
                }
            }
        }
 protected void btn_save_Click(object sender, EventArgs e)
 {
     question question = new question();
     if (this.txtType.Value == "1")
     {
         question.id = System.Guid.NewGuid().ToString();
         question.expertId = strDocid;
         question.questioner = "[匿名]";
         question.describe = this.txtDetail.Value;
         question.quertionerEmail = this.txtEmail.Value;
         question.questionTime = DateTime.Now;
     }
     else
     {
         question.id = System.Guid.NewGuid().ToString();
         question.expertId = strDocid;
         question.describe = this.txtDDetail.Value;
         question.quertionerEmail = this.txtDEmail.Value;
         question.questioner = this.txtName.Value;
         question.questionTime = DateTime.Now;
     }
     question.Add();
     Response.Write("<script>alert('保存成功!');</script>");
 }
Exemple #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region loadData

        qset.qset_id = "2";
        qset.loadQuestionSet();
        qset.loadQuestionL1();
        lbl_qset_text.Text = qset.qset_text;

        for (int q1_i = 0; q1_i < qset.qL1_list.Count; q1_i++)
        {
            question q1 = qset.qL1_list[q1_i];
            q1.loadQuestionL2();
            for (int q2_i = 0; q2_i < q1.qL2_list.Count; q2_i++)
            {
                questionL2 q2 = q1.qL2_list[q2_i];
                q2.loadQuestionL3();
            }
        }
        #endregion
        #region MapQuestion to Interface
        //--------------ประเด็น3---------------------------
        lblQuestion_1.Text = qset.qL1_list[0].q1_text;

        lblAssumption_1.Text = qset.qL1_list[0].q1_assumption;

        lblQuestion_id_1.Text        = qset.qL1_list[0].q1_id;
        lblQuestion_id_praden_1.Text = lblQuestion_id_1.Text;

        //---------------คำถาม----------------------------
        lblQuestion2_1.Text = Q2Seq + qset.qL1_list[0].qL2_list[0].q2_order + " " + qset.qL1_list[0].qL2_list[0].q2_text;

        //--------------คำถามย่อย--------------------------------
        lblQuestion3_1_1.Text = qset.qL1_list[0].qL2_list[0].qL3_list[0].q3_order + " " + qset.qL1_list[0].qL2_list[0].qL3_list[0].q3_text;
        lblQuestion3_1_2.Text = qset.qL1_list[0].qL2_list[0].qL3_list[1].q3_order + " " + qset.qL1_list[0].qL2_list[0].qL3_list[1].q3_text;
        lblQuestion3_1_3.Text = qset.qL1_list[0].qL2_list[0].qL3_list[2].q3_order + " " + qset.qL1_list[0].qL2_list[0].qL3_list[2].q3_text;

        //---------------คำถาม----------------------------
        lblQuestion2_2.Text = Q2Seq + qset.qL1_list[0].qL2_list[1].q2_order + " " + qset.qL1_list[0].qL2_list[1].q2_text;
        //--------------คำถามย่อย--------------------------------
        lblQuestion3_2_1.Text = qset.qL1_list[0].qL2_list[1].qL3_list[0].q3_order + " " + qset.qL1_list[0].qL2_list[1].qL3_list[0].q3_text;

        //---------------คำถาม----------------------------
        lblQuestion2_3.Text = Q2Seq + qset.qL1_list[0].qL2_list[2].q2_order + " " + qset.qL1_list[0].qL2_list[2].q2_text;
        //--------------คำถามย่อย--------------------------------
        lblQuestion3_3_1.Text = qset.qL1_list[0].qL2_list[2].qL3_list[0].q3_order + " " + qset.qL1_list[0].qL2_list[2].qL3_list[0].q3_text;

        //---------------คำถาม----------------------------
        lblQuestion2_4.Text = Q2Seq + qset.qL1_list[0].qL2_list[3].q2_order + " " + qset.qL1_list[0].qL2_list[3].q2_text;
        //--------------คำถามย่อย--------------------------------
        lblQuestion3_4_1.Text = qset.qL1_list[0].qL2_list[3].qL3_list[0].q3_order + " " + qset.qL1_list[0].qL2_list[3].qL3_list[0].q3_text;
        lblQuestion3_4_2.Text = qset.qL1_list[0].qL2_list[3].qL3_list[1].q3_order + " " + qset.qL1_list[0].qL2_list[3].qL3_list[1].q3_text;
        lblQuestion3_4_3.Text = qset.qL1_list[0].qL2_list[3].qL3_list[2].q3_order + " " + qset.qL1_list[0].qL2_list[3].qL3_list[2].q3_text;
        lblQuestion3_4_4.Text = qset.qL1_list[0].qL2_list[3].qL3_list[3].q3_order + " " + qset.qL1_list[0].qL2_list[3].qL3_list[3].q3_text;

        //-----------จบ ประเด็น3--------------------------------

        //--------------ประเด็น4---------------------------
        lblQuestion_2.Text = qset.qL1_list[1].q1_text;

        lblAssumption_2.Text = qset.qL1_list[1].q1_assumption;

        lblQuestion_id_2.Text        = qset.qL1_list[1].q1_id;
        lblQuestion_id_praden_2.Text = lblQuestion_id_2.Text;

        lblQuestion2_5_1.Text = Q2Seq + qset.qL1_list[1].qL2_list[0].q2_order + " " + qset.qL1_list[1].qL2_list[0].q2_text;

        lblQuestion3_4_1_1.Text = qset.qL1_list[1].qL2_list[0].qL3_list[0].q3_order + " " + qset.qL1_list[1].qL2_list[0].qL3_list[0].q3_text;
        //-----------จบ ประเด็น4--------------------------------

        //--------------ประเด็น5---------------------------
        lblQuestion_3.Text = qset.qL1_list[2].q1_text;

        lblAssumption_3.Text = qset.qL1_list[2].q1_assumption;

        lblQuestion_id_3.Text        = qset.qL1_list[2].q1_id;
        lblQuestion_id_praden_3.Text = lblQuestion_id_3.Text;

        lblQuestion2_6_1.Text = Q2Seq + qset.qL1_list[2].qL2_list[0].q2_order + " " + qset.qL1_list[2].qL2_list[0].q2_text;

        lblQuestion3_5_1_1.Text = qset.qL1_list[2].qL2_list[0].qL3_list[0].q3_order + " " + qset.qL1_list[2].qL2_list[0].qL3_list[0].q3_text;
        lblQuestion3_5_1_2.Text = qset.qL1_list[2].qL2_list[0].qL3_list[1].q3_order + " " + qset.qL1_list[2].qL2_list[0].qL3_list[1].q3_text;
        //-----------จบ ประเด็น5--------------------------------

        #endregion

        ManageCookie mgCookie = new ManageCookie();
        users        ck       = mgCookie.ReadCookies();
        string       max      = "";
        if (ck != null)
        {
            mgCookie.UpdateCookies("qset_id", qset.qset_id); //คำถามชุด ข.
            answer ans = new answer();
            max = ans.getLatestAnswerQ2(ck.pj_id, ans.getLatestAnswerQSetID(ck.pj_id));

            //if (pnlQL1_3.Visible == true)
            //{
            //    //ประเด็น 3
            //    mgCookie.UpdateCookies("q1_id", qset.qL1_list[0].q1_id);
            //    mgCookie.UpdateCookies("q2_id", qset.qL1_list[0].qL2_list[0].q2_id);
            //}
            //else if (pnlQL1_4.Visible == true)
            //{
            //    //ประเด็นที่ 4
            //    mgCookie.UpdateCookies("q1_id", qset.qL1_list[1].q1_id);
            //    mgCookie.UpdateCookies("q2_id", qset.qL1_list[1].qL2_list[0].q2_id);
            //}
            //else if (pnlQL1_5.Visible == true)
            //{
            //    //ประเด็นที่ 5
            //    mgCookie.UpdateCookies("q1_id", qset.qL1_list[2].q1_id);
            //    mgCookie.UpdateCookies("q2_id", qset.qL1_list[2].qL2_list[0].q2_id);
            //}
        }
        else
        {
            Response.Redirect(ton.config.Global_config.RootURL);
        }

        //ไม่ใช่
        if ((!Page.IsPostBack) && (ck != null))
        {
            //-------get latest------
            string strQ2ID = max;
            //ton.JavaScript.MessageBox(strQ2ID);
            if (strQ2ID != null)
            {
                if (strQ2ID == "2")
                {
                    // Origin Q2_1
                    pnlQL1_3.Visible = true;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = true;
                    pnlQL2_2.Visible = false;
                    pnlQL2_3.Visible = false;
                    pnlQL2_4.Visible = false;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = false;
                }
                else if (strQ2ID == "3")
                {
                    // Next is Q2_2
                    pnlQL1_3.Visible = true;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = false;
                    pnlQL2_2.Visible = true;
                    pnlQL2_3.Visible = false;
                    pnlQL2_4.Visible = false;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = false;
                }
                else if (strQ2ID == "4")
                {
                    // Next is Q2_3
                    pnlQL1_3.Visible = true;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = false;
                    pnlQL2_2.Visible = false;
                    pnlQL2_3.Visible = true;
                    pnlQL2_4.Visible = false;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = false;
                }
                else if (strQ2ID == "5")
                {
                    // Next is Q2_4
                    pnlQL1_3.Visible = true;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = false;
                    pnlQL2_2.Visible = false;
                    pnlQL2_3.Visible = false;
                    pnlQL2_4.Visible = true;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = false;
                }
                else if (strQ2ID == "6")
                {
                    // Next is Q2_5
                    pnlQL1_3.Visible = false;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = false;
                    pnlQL2_2.Visible = false;
                    pnlQL2_3.Visible = false;
                    pnlQL2_4.Visible = false;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = true;
                    pnlQL1_5.Visible = false;
                }
                else if (strQ2ID == "7")
                {
                    // Next is Q2_6
                    pnlQL1_3.Visible = false;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = false;
                    pnlQL2_2.Visible = false;
                    pnlQL2_3.Visible = false;
                    pnlQL2_4.Visible = false;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = true;
                }
                else if (strQ2ID == "8")
                {
                    // Next is QSet C ค.
                    litfinish.Text    = "เสร็จสิ้นการแก้ไขประเมิน" + qset.qset_text;
                    litfinish.Visible = true;
                    btnToQB.Visible   = true;

                    pnlQL1_3.Visible = false;
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = false;
                }
                else
                {
                    // Origin Q2_1
                    pnlQL1_3.Visible = false;
                    // Nested Panel inside pnlQL1_3
                    //--Only 1st Question visible
                    pnlQL2_1.Visible = false;
                    pnlQL2_2.Visible = false;
                    pnlQL2_3.Visible = false;
                    pnlQL2_4.Visible = false;
                    //-----End Nested  Panel -----
                    pnlQL1_4.Visible = false;
                    pnlQL1_5.Visible = false;
                }
            }
            //------------------


            /*
             #region LoadData_from_DB
             *  // Load and Map DB Data For Edit Mode only
             *  string strSQL1 = "";
             *  SqlCommand cmd = new SqlCommand();
             *  DataView dv1 = new DataView();
             *  // Load and Map Data from DB to interface
             *  //คำตอบ
             *  // ประเด็นที่ 3
             #region คำตอบ คำถามที่ 1
             *  strSQL1 = "select * from dbo.answer_q2 q2, answer_q3 q3 "
             + " where q2.qset_id = @qset_id and "
             + "q2.pj_id = @pj_id and "
             + "q2.q2_id = @q2_id and "
             + "q2.answer_q2_id = q3.answer_q2_id";
             +
             +  cmd = new SqlCommand(strSQL1);
             +  cmd.Parameters.AddWithValue("@qset_id", qset.qset_id);
             +  cmd.Parameters.AddWithValue("@pj_id", ck.pj_id);
             +  cmd.Parameters.AddWithValue("@q2_id", qset.qL1_list[0].qL2_list[0].q2_id);
             +
             +
             +  dv1 = ton.Data.DBHelper.getDataSet(cmd).Tables[0].DefaultView;
             +
             +
             +  radanswer2_1.SelectedValue = dv1.Table.Rows[0]["answer_q2_text"].ToString();
             +  txtAnswerQuestion3_1_1.Text = dv1.Table.Rows[0]["answer_q3_text"].ToString();
             +  txtAnswerQuestion3_1_2.Text = dv1.Table.Rows[1]["answer_q3_text"].ToString();
             +  txtAnswerQuestion3_1_3.Text = dv1.Table.Rows[2]["answer_q3_text"].ToString();
             #endregion
             +
             #region คำตอบ คำถามที่ 2
             +  strSQL1 = "select * from dbo.answer_q2 q2, answer_q3 q3 "
             + " where q2.qset_id = @qset_id and "
             + "q2.pj_id = @pj_id and "
             + "q2.q2_id = @q2_id and "
             + "q2.answer_q2_id = q3.answer_q2_id";
             +
             +  cmd = new SqlCommand(strSQL1);
             +  cmd.Parameters.AddWithValue("@qset_id", qset.qset_id);
             +  cmd.Parameters.AddWithValue("@pj_id", ck.pj_id);
             +  cmd.Parameters.AddWithValue("@q2_id", qset.qL1_list[0].qL2_list[1].q2_id);
             +
             +
             +  dv1 = ton.Data.DBHelper.getDataSet(cmd).Tables[0].DefaultView;
             +
             +  radanswer2_2.SelectedValue = dv1.Table.Rows[0]["answer_q2_text"].ToString();
             +  txtAnswerQuestion3_2_1.Text = dv1.Table.Rows[0]["answer_q3_text"].ToString();
             #endregion
             +
             #region คำตอบ คำถามที่ 3
             +  strSQL1 = "select * from dbo.answer_q2 q2, answer_q3 q3 "
             + " where q2.qset_id = @qset_id and "
             + "q2.pj_id = @pj_id and "
             + "q2.q2_id = @q2_id and "
             + "q2.answer_q2_id = q3.answer_q2_id";
             +
             +  cmd = new SqlCommand(strSQL1);
             +  cmd.Parameters.AddWithValue("@qset_id", qset.qset_id);
             +  cmd.Parameters.AddWithValue("@pj_id", ck.pj_id);
             +  cmd.Parameters.AddWithValue("@q2_id", qset.qL1_list[0].qL2_list[2].q2_id);
             +
             +
             +  dv1 = ton.Data.DBHelper.getDataSet(cmd).Tables[0].DefaultView;
             +
             +  radanswer2_3.SelectedValue = dv1.Table.Rows[0]["answer_q2_text"].ToString();
             +  txtAnswerQuestion3_3_1.Text = dv1.Table.Rows[0]["answer_q3_text"].ToString();
             #endregion
             +
             #region คำตอบ คำถามที่ 4
             +  strSQL1 = "select * from dbo.answer_q2 q2, answer_q3 q3 "
             + " where q2.qset_id = @qset_id and "
             + "q2.pj_id = @pj_id and "
             + "q2.q2_id = @q2_id and "
             + "q2.answer_q2_id = q3.answer_q2_id";
             +
             +  cmd = new SqlCommand(strSQL1);
             +  cmd.Parameters.AddWithValue("@qset_id", qset.qset_id);
             +  cmd.Parameters.AddWithValue("@pj_id", ck.pj_id);
             +  cmd.Parameters.AddWithValue("@q2_id", qset.qL1_list[0].qL2_list[3].q2_id);
             +
             +
             +  dv1 = ton.Data.DBHelper.getDataSet(cmd).Tables[0].DefaultView;
             +
             +  radanswer2_4.SelectedValue = dv1.Table.Rows[0]["answer_q2_text"].ToString();
             +  txtAnswerQuestion3_4_1.Text = dv1.Table.Rows[0]["answer_q3_text"].ToString();
             +  txtAnswerQuestion3_4_2.Text = dv1.Table.Rows[1]["answer_q3_text"].ToString();
             +  txtAnswerQuestion3_4_3.Text = dv1.Table.Rows[2]["answer_q3_text"].ToString();
             +  txtAnswerQuestion3_4_4.Text = dv1.Table.Rows[3]["answer_q3_text"].ToString();
             #endregion
             +
             +  //ประเด็นที่ 4
             #region คำตอบ คำถามที่ 5
             +  strSQL1 = "select * from dbo.answer_q2 q2, answer_q3 q3 "
             + " where q2.qset_id = @qset_id and "
             + "q2.pj_id = @pj_id and "
             + "q2.q2_id = @q2_id and "
             + "q2.answer_q2_id = q3.answer_q2_id";
             +
             +  cmd = new SqlCommand(strSQL1);
             +  cmd.Parameters.AddWithValue("@qset_id", qset.qset_id);
             +  cmd.Parameters.AddWithValue("@pj_id", ck.pj_id);
             +  cmd.Parameters.AddWithValue("@q2_id", qset.qL1_list[1].qL2_list[0].q2_id);
             +
             +
             +  dv1 = ton.Data.DBHelper.getDataSet(cmd).Tables[0].DefaultView;
             +
             +  radanswer2_5_1.SelectedValue = dv1.Table.Rows[0]["answer_q2_text"].ToString();
             +  txtAnswerQuestion3_4_1_1.Text = dv1.Table.Rows[0]["answer_q3_text"].ToString();
             #endregion
             +
             +  //ประเด็นที่ 5
             #region คำตอบ คำถามที่ 6
             +  strSQL1 = "select * from dbo.answer_q2 q2, answer_q3 q3 "
             + " where q2.qset_id = @qset_id and "
             + "q2.pj_id = @pj_id and "
             + "q2.q2_id = @q2_id and "
             + "q2.answer_q2_id = q3.answer_q2_id";
             +
             +  cmd = new SqlCommand(strSQL1);
             +  cmd.Parameters.AddWithValue("@qset_id", qset.qset_id);
             +  cmd.Parameters.AddWithValue("@pj_id", ck.pj_id);
             +  cmd.Parameters.AddWithValue("@q2_id", qset.qL1_list[2].qL2_list[0].q2_id);
             +
             +
             +  dv1 = ton.Data.DBHelper.getDataSet(cmd).Tables[0].DefaultView;
             +
             +  radanswer2_6_1.SelectedValue = dv1.Table.Rows[0]["answer_q2_text"].ToString();
             +  txtAnswerQuestion3_5_1_1.Text = dv1.Table.Rows[0]["answer_q3_text"].ToString();
             +  txtAnswerQuestion3_5_1_2.Text = dv1.Table.Rows[1]["answer_q3_text"].ToString();
             +
             #endregion
             #endregion
             */
        }

        // set cookies to keep the lastest question Set , Q2
        #region set cookies follow to visible panel

        #region ไม่ใช้
        //if (pnlQL1_3.Visible == true)
        //{
        //    mgCookie.UpdateCookies("q1_id", "3"); //ประเด็นที่สาม

        //    if (pnlQL2_1.Visible == true)
        //    {
        //        mgCookie.UpdateCookies("q2_id", "3"); //คำถามที่1 , IDคำถามเริ่มที่3
        //    }
        //    else if (pnlQL2_2.Visible == true)
        //    {
        //        mgCookie.UpdateCookies("q2_id", "4"); //คำถามที่2
        //    }
        //    else if (pnlQL2_3.Visible == true)
        //    {
        //        mgCookie.UpdateCookies("q2_id", "5"); //คำถามที่3
        //    }
        //    else if (pnlQL2_4.Visible == true)
        //    {
        //        mgCookie.UpdateCookies("q2_id", "6"); //คำถามที่3
        //    }
        //}
        //else if (pnlQL1_4.Visible == true)
        //{
        //    mgCookie.UpdateCookies("q1_id", "4");  //ประเด็นที่สี่
        //    mgCookie.UpdateCookies("q2_id", "7");  //คำถามที่ห้า
        //}
        //else if (pnlQL1_5.Visible == true)
        //{
        //    mgCookie.UpdateCookies("q1_id", "5");  //ประเด็นที่ห้า
        //    mgCookie.UpdateCookies("q2_id", "8");  //คำถามที่หก
        //}
        #endregion

        #endregion
        //----------------------------------------


        //คำถามที่ 1
        if (radanswer2_1.SelectedValue == "มี") // ตอบว่า มี
        {
            txtAnswerQuestion3_1_1.Enabled = txtAnswerQuestion3_1_2.Enabled = txtAnswerQuestion3_1_3.Enabled = true;
            reqvld_3_1_1.Enabled           = reqvld_3_1_2.Enabled = reqvld_3_1_3.Enabled = true;
        }
        else
        {
            txtAnswerQuestion3_1_1.Enabled = txtAnswerQuestion3_1_2.Enabled = txtAnswerQuestion3_1_3.Enabled = false;
            reqvld_3_1_1.Enabled           = reqvld_3_1_2.Enabled = reqvld_3_1_3.Enabled = false;
        }

        //คำถามที่ 2
        if (radanswer2_2.SelectedValue == "มี") // ตอบว่า มี
        {
            txtAnswerQuestion3_2_1.Enabled = true;
            reqvld_3_2_1.Enabled           = true;
        }
        else
        {
            txtAnswerQuestion3_2_1.Enabled = false;
            reqvld_3_2_1.Enabled           = false;
        }

        //คำถามที่ 3
        if (radanswer2_3.SelectedValue == "มี") // ตอบว่า มี
        {
            txtAnswerQuestion3_3_1.Enabled = true;
            reqvld_3_3_1.Enabled           = true;
        }
        else
        {
            txtAnswerQuestion3_3_1.Enabled = false;
            reqvld_3_3_1.Enabled           = false;
        }

        //คำถามที่ 4
        if (radanswer2_4.SelectedValue == "มี") // ตอบว่า มี
        {
            txtAnswerQuestion3_4_1.Enabled = txtAnswerQuestion3_4_2.Enabled = txtAnswerQuestion3_4_3.Enabled = txtAnswerQuestion3_4_4.Enabled = true;
            reqvld_3_4_1.Enabled           = reqvld_3_4_2.Enabled = reqvld_3_4_3.Enabled = reqvld_3_4_4.Enabled = true;
        }
        else
        {
            txtAnswerQuestion3_4_1.Enabled = txtAnswerQuestion3_4_2.Enabled = txtAnswerQuestion3_4_3.Enabled = txtAnswerQuestion3_4_4.Enabled = false;
            reqvld_3_4_1.Enabled           = reqvld_3_4_2.Enabled = reqvld_3_4_3.Enabled = reqvld_3_4_4.Enabled = false;
        }

        //คำถามที่ 5
        if ((radanswer2_5_1.SelectedValue == "มี") || (radanswer2_5_1.SelectedValue == "มีบางส่วน"))  // ตอบว่า มี หรือ มีบางส่วน
        {
            txtAnswerQuestion3_4_1_1.Enabled = true;
            reqvld3_4_1_1.Enabled            = true;
        }
        else
        {
            txtAnswerQuestion3_4_1_1.Enabled = false;
            reqvld3_4_1_1.Enabled            = false;
        }

        //คำถามที่ 6
        if (radanswer2_6_1.SelectedValue == "มี")   // ตอบว่า มี หรือ มีบางส่วน
        {
            txtAnswerQuestion3_5_1_1.Enabled = txtAnswerQuestion3_5_1_2.Enabled = true;
            reqvld_3_5_1_1.Enabled           = reqvld_3_5_1_2.Enabled = true;
        }
        else
        {
            txtAnswerQuestion3_5_1_1.Enabled = txtAnswerQuestion3_5_1_2.Enabled = false;
            reqvld_3_5_1_1.Enabled           = reqvld_3_5_1_2.Enabled = false;
        }
    }
Exemple #9
0
 internal abstract Task <answer> z_get_answer(question question);
 public attemptedAnswer(bool correct, question question, answer answer)
 {
     this.correct  = correct;
     this.question = question;
     this.answer   = answer;
 }
Exemple #11
0
        private void LoadQuestion(int questionid)
        {
            IsQLSave = true; IsSaved = true;
            DataTable dt = gridControlQuestions.DataSource as DataTable;
            m_oQuestion = BPContext.questions.Include("questions_text_language").FirstOrDefault(p => p.id == questionid);

            if (m_oQuestion.general_value != null && !string.IsNullOrEmpty(m_oQuestion.general_value.ToString()))
                comboBoxEditQuestionGeneralValue.SelectedText = m_oQuestion.general_value.ToString();
            var qtl = m_oQuestion.questions_text_language;

            DataRow dr = null;
            qtl.ForEach(delegate(questions_text_language dqtl) {
                dr = dt.NewRow();
                dr["language"] = dqtl.language_id;
                dr["question"] = dqtl.question_text;
                dr["description"] = dqtl.question_description;
                dr["helptext"] = dqtl.question_help_text;
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();

            dictionarySelectedTags = new Dictionary<string, int>();
            var qqt = m_oQuestion.questions_questiontags;
            questiontag qt = null;
            qqt.ForEach(delegate(questions_questiontags dqts) {
                qt = dqts.questiontag;
                dictionarySelectedTags.Add(qt.title, qt.id);
            });

            groupControlAnswerForm.Enabled = true;
            simpleButtonSaveQuestion.Enabled = true;

            dt = gridControlAnswerForm.DataSource as DataTable;
            m_oQuestionLayouts = BPContext.questionlayouts.Include("questionlayout_language").Where(p => p.questions_id == questionid);
            CampaignQuestionnaire cQ = null;
            var cbeItems = comboBoxEditComponentType.Properties.Items;
            string componentType = string.Empty;
            questionlayout_language qlang = null;
            m_oQuestionLayouts.ForEach(delegate(questionlayout ql) {
                cQ = CampaignQuestionnaire.InstanciateWith(ql.content_json);
                for (int x = 0; x < cbeItems.Count; ++x) {
                    if (cbeItems[x].ToString().ToLower() == cQ.Type.ToLower())
                        componentType = cbeItems[x].ToString();
                }
                dr = dt.NewRow();
                dr["title"] = ql.title;
                dr["component_type"] = componentType;
                dr["general_value"] = ql.general_value;
                dr["properties"] = cQ;
                qlang = ql.questionlayout_language.FirstOrDefault();
                if (qlang != null) {
                    dr["language"] = qlang.language.name;
                    dr["language_id"] = qlang.language_id;
                } else {
                    dr["language"] = null;
                    dr["language_id"] = null;
                }
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();
        }
Exemple #12
0
        public Tuple <string, bool> JudgeSql(string username, question ques, string ans, string back_name)
        {
            string except    = "";
            bool   iscorrect = false;
            bool   isNonQue  = true;

            if (ques.q_type == 1)
            {
                isNonQue = false;
            }
            else if (ques.q_type == 2)
            {
                isNonQue = true;
            }
            var ansres = RunSql(username, ans, back_name, isNonQue, false);

            if (!ansres.Item3)  //语句执行出错
            {
                iscorrect = false;
                except    = ansres.Item2;
                return(new Tuple <string, bool>(except, iscorrect));
            }
            if (isNonQue)  //执行检测语句,得出结果并删除副本数据库
            {
                ansres = RunSql(username, ques.check_sentence, back_name, false, true);
            }
            var rightans = RunSql(username, ques.right_answer, back_name, isNonQue, false);

            if (isNonQue)
            {
                rightans = RunSql(username, ques.check_sentence, back_name, false, true);
            }
            var res = DataTableCompare(ansres.Item1, rightans.Item1);

            if (res.Item1.Length > 0 || res.Item2.Length > 0)
            {
                iscorrect = false;
                if (isNonQue == true)
                {
                    except += $"验证语句{ques.check_sentence}下\n";
                }
                if (res.Item1.Length > 0)
                {
                    var str = "";
                    foreach (var item in res.Item1[0].ItemArray)
                    {
                        str += item.ToString().TrimEnd(' ') + ' ';
                    }
                    except += $"比正确结果少{res.Item1.Length}个,如:{str}\n";
                }
                if (res.Item2.Length > 0)
                {
                    var str = "";
                    foreach (var item in res.Item2[0].ItemArray)
                    {
                        str += item.ToString().TrimEnd(' ') + ' ';
                    }
                    except += $"比正确结果多{res.Item2.Length}个,如:{str}\n";
                }
            }
            else
            {
                var DifInOrder = Equals(ansres.Item1.Rows[0].ItemArray[0], rightans.Item1.Rows[0].ItemArray[0]);
                if (!DifInOrder)
                {
                    except = $"输出行序有误";
                }
                else
                {
                    iscorrect = true;
                    except    = "congratulations!!";
                }
            }
            var re = new Tuple <string, bool>(except, iscorrect);

            return(re);
        }
        public void AddCategory(question q)
        {
            if (categories.ContainsKey(q.id))
            {
                MessageBox.Show(this, "Programmer error: Attempting to view the same category more than once.");
            }
            else
            {
                List <question> questionsToAdd          = q.GetCategoryQuestions();
                List <int>      requiredAnswerParentIDs = new List <int>();
                question        qToUse       = q;
                string          categoryText = "";;
                List <string>   categoryTree = new List <string>();
                categoryTree.Add(q.text);
                while (qToUse.parent > 0)
                {
                    qToUse = qToUse.ParentQuestion;
                    categoryTree.Add(qToUse.text);
                }

                for (int i = categoryTree.Count - 1; i >= 0; i--)
                {
                    if (i < categoryTree.Count - 1)
                    {
                        categoryText += " - ";
                    }
                    categoryText += categoryTree[i];
                }
                if (lblCategoryInfo.Text == "")
                {
                    categoryText = "Claim Status: " + categoryText;
                }
                else
                {
                    categoryText = " - " + categoryText;
                }

                lblCategoryInfo.Text += categoryText;


                bool isRoot = true;

                pnlControls.AutoScroll = false;
                pnlControls.SuspendLayout();

                currentParentCategory = q;
                categories.Add(q.id, 0);
                formControls.Add(q.id, new List <Control>());
                AddCategoryLabel(q, false);
                foreach (question aQuestion in questionsToAdd)
                {
                    bool hideQuestion = false;
                    if (aQuestion.required_answer != "")
                    {
                        // Need to not show this entire tree of questions
                        requiredAnswerParentIDs.Add(aQuestion.id);
                        hideQuestion = true;
                    }
                    else
                    {
                        if (requiredAnswerParentIDs.Contains(aQuestion.parent))
                        {
                            requiredAnswerParentIDs.Add(aQuestion.id);
                            hideQuestion = true;
                        }
                        else if (aQuestion.parent > 0)
                        {
                            if (aQuestion.ParentQuestion.required_answer != "")
                            {
                                requiredAnswerParentIDs.Add(aQuestion.parent);
                                requiredAnswerParentIDs.Add(aQuestion.id);
                                hideQuestion = true;
                            }
                            else
                            {
                                List <int> allParentIDs = aQuestion.GetParentIDs();
                                foreach (int aParentID in allParentIDs)
                                {
                                    // Loop through all parent IDs and verify nothing is "banned"
                                    if (requiredAnswerParentIDs.Contains(aParentID))
                                    {
                                        requiredAnswerParentIDs.Add(aQuestion.id);
                                        requiredAnswerParentIDs.Add(aQuestion.parent);
                                        hideQuestion = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    AddQuestion(aQuestion, isRoot, hideQuestion);
                    isRoot = false;
                }
                pnlControls.ResumeLayout();
                pnlControls.AutoScroll = true;
            }
        }
Exemple #14
0
        public string AddTestQuestion(string data, long testInfoId)
        {
            string[]        datas  = data.Split('#');
            string          stem   = datas[0];
            Question        Q      = new Question();
            List <question> ques   = Q.Search(u => u.qusetion_Stem == stem);
            string          qclass = datas[1];

            if (ques.Count < 1)
            {
                //Create new
                question q = new question();


                List <@class> c = new _Class().Search(u => u.class_Class == qclass);
                if (c.Count < 1)
                {
                    return("不存在次类别,添加失败!");
                }
                q.question_IsDel   = false;
                q.qusetion_Stem    = datas[0];
                q.question_ClassId = c[0].class_Id;
                q.question_Option1 = datas[2];
                q.question_Option2 = datas[3];
                q.question_Option3 = datas[4];
                q.question_Option4 = datas[5];
                q.question_Option5 = datas[6];
                q.question_Option6 = datas[7];
                q.question_Option7 = datas[8];
                try
                {
                    new Question().Add(q);
                }
                catch
                {
                    return("数据插入异常!");
                }

                test t = new test();
                t.test_QuestionId = q.question_Id;
                t.test_TestInfoId = testInfoId;
                try
                {
                    Add(t);
                }
                catch
                {
                    return("数据插入异常!");
                }
            }
            else
            {
                long qId   = ques[0].question_Id;
                long tests = new Test().SearchCount(k => k.test_QuestionId == qId);
                if (tests > 1)
                {
                    return("此问卷中已包含此问题,请勿重复添加!");
                }
                List <@class> c = new _Class().Search(u => u.class_Class == qclass);
                if (c.Count < 1)
                {
                    return("不存在次类别,添加失败!");
                }
                test t = new test();
                t.test_QuestionId = ques[0].question_Id;
                t.test_TestInfoId = testInfoId;

                try
                {
                    Add(t);
                }
                catch
                {
                    return("数据插入异常!");
                }
            }
            return("ok");
        }
Exemple #15
0
 public void MarkAsModified(question item)
 {
 }
 // 数据绑定
 private void RptBind()
 {
     HyCommon HyCommon = new HyCommon();
     //获取当前页数
     if (this.Request.QueryString["page"] != null)
     {
         this.page = int.Parse(HyCommon.Filter(this.Request.QueryString["page"].ToString()));
     }
     this.txtPageNum.Text = this.pageSize.ToString();
     question question = new question();
     string strWhere = "";
     if (this.txtNmae.Text.Trim() != "")
     {
         strWhere += "  and questioner like '%" + this.txtNmae.Text.Trim() + "%'";
     }
     //获取数据
     DataSet dt = question.GetDataPage(this.pageSize, this.page, strWhere);
     //获取数据条数
     this.totalCount = question.GetList(strWhere).Tables[0].Rows.Count;
     this.lblcount.Text = totalCount.ToString();
     rptList.DataSource = dt;
     rptList.DataBind();
     //地址传递数据
     string pageUrl = HyCommon.CombUrlTxt(ls_url, "page={0}&rnd={1}&txtNmae={2}", "__id__", System.Guid.NewGuid().ToString(), this.txtNmae.Text);
     PageContent.InnerHtml = HyCommon.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
 }
Exemple #17
0
        //Результаты. Статистическая информация
        public ActionResult ExportStatistics(int form_id)
        {
            int cols = 1;
            List <answer_text>    answer_text    = db.answer_text.Where(p => p.question.id_form == form_id).ToList();
            List <answer_variant> answer_variant = db.answer_variant.Where(p => p.variant.question.id_form == form_id).ToList();
            List <answer_table>   answer_table   = db.answer_table.Where(p => p.table_question.question.id_form == form_id).ToList();
            List <answer_file>    answer_file    = db.answer_file.Where(p => p.variant_file.question.id_form == form_id).ToList();
            List <answer_else>    answer_else    = db.answer_else.Where(p => p.question_else.question.id_form == form_id).ToList();
            ExcelPackage          excel          = new ExcelPackage();
            var             workSheet            = excel.Workbook.Worksheets.Add("Статистическая информация");
            List <question> list  = db.question.Where(p => p.id_form == form_id).ToList();
            List <user>     users = db.user.Where(p => p.answer_text.Count(s => s.question.id_form == form_id) > 0 || p.answer_variant.Count(s => s.variant.question.id_form == form_id) > 0 || p.answer_table.Count(s => s.table_question.question.id_form == form_id) > 0 || p.answer_file.Count(s => s.variant_file.question.id_form == form_id) > 0).ToList();

            for (int i = 0; i < list.Count(); ++i)
            {
                question q = list.ElementAt(i);
                workSheet.Cells[1, cols].Value = list.ElementAt(i).name;
                if (list.ElementAt(i).id_type_question == 1)
                {
                    workSheet.Cells[4, cols].Value = answer_text.Count(p => p.id_question == q.id);
                    cols++;
                }
                else if (list.ElementAt(i).id_type_question == 2 || list.ElementAt(i).id_type_question == 3 || list.ElementAt(i).id_type_question == 4)
                {
                    List <variant> a2 = db.variant.Where(p => p.id_question == q.id).ToList();
                    for (int j = 0; j < a2.Count(); ++j)
                    {
                        variant v = a2.ElementAt(j);
                        workSheet.Cells[3, cols].Value = v.name;
                        workSheet.Cells[4, cols].Value = users.Count(p => p.answer_variant.Count(d => d.id_variant == v.id) > 0);
                        cols++;
                    }
                    if (q.question_else.Count() > 0)
                    {
                        question_else q_e = db.question_else.First(p => p.id_question == q.id);
                        workSheet.Cells[3, cols].Value = q_e.name;
                        workSheet.Cells[4, cols].Value = users.Count(p => p.answer_else.Count(d => d.id_question_else == q_e.id) > 0);
                        cols++;
                    }
                }
                else if (list.ElementAt(i).id_type_question == 5 || list.ElementAt(i).id_type_question == 6)
                {
                    List <table_question> table_question = db.table_question.Where(p => p.id_question == q.id).ToList();
                    for (int k = 0; k < table_question.Count(); ++k)
                    {
                        table_question t_q = table_question.ElementAt(k);
                        workSheet.Cells[2, cols].Value = t_q.name;
                        List <table_variant> t_V = db.table_variant.Where(p => p.id_question == t_q.id_question).ToList();
                        for (int l = 0; l < t_V.Count(); ++l)
                        {
                            table_variant t = t_V.ElementAt(l);
                            workSheet.Cells[3, cols].Value = t.name;
                            workSheet.Cells[4, cols].Value = users.Count(p => p.answer_table.Count(d => d.id_table_variant == t.id && d.id_table_question == t_q.id) > 0);
                            cols++;
                        }
                    }
                }
                else if (list.ElementAt(i).id_type_question == 7)
                {
                    workSheet.Cells[4, cols].Value = answer_file.Count(p => p.variant_file.question_id == q.id);
                    cols++;
                }
            }
            var path = Path.Combine(Server.MapPath("~/Content/files/"), "static_information_" + form_id + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");

            using (var memoryStream = new MemoryStream())
            {
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment; filename=" + path);
                excel.SaveAs(memoryStream);
                memoryStream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }

            FileInfo fi = new FileInfo(path);
            long     sz = fi.Length;

            Response.ClearContent();
            Response.ContentType = Path.GetExtension(path);
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", System.IO.Path.GetFileName(path)));
            Response.AddHeader("Content-Length", sz.ToString("F0"));
            Response.TransmitFile(path);
            Response.End();

            System.IO.File.Delete(path);
            return(Redirect("/Forms/Details?id=" + form_id));
        }
Exemple #18
0
        //Страница для просмотра видео
        public ActionResult video(int id)
        {
            question q = db.question.Find(id);

            return(View(q));
        }
Exemple #19
0
        //Результаты (ответы) по выбранной анкете в файле .excel
        public ActionResult ExportExcel(int form_id)
        {
            int rows = 1;
            int cols = 5;
            List <answer_text>    answer_text    = db.answer_text.Where(p => p.question.id_form == form_id).ToList();
            List <answer_variant> answer_variant = db.answer_variant.Where(p => p.variant.question.id_form == form_id).ToList();
            List <answer_table>   answer_table   = db.answer_table.Where(p => p.table_question.question.id_form == form_id).ToList();
            List <answer_file>    answer_file    = db.answer_file.Where(p => p.variant_file.question.id_form == form_id).ToList();
            List <answer_else>    answer_else    = db.answer_else.Where(p => p.question_else.question.id_form == form_id).ToList();
            ExcelPackage          excel          = new ExcelPackage();
            var             workSheet            = excel.Workbook.Worksheets.Add("Результаты");
            List <question> list  = db.question.Where(p => p.id_form == form_id).OrderBy(p => p.number).ToList();
            List <user>     users = db.user.Where(p => p.answer_text.Count(s => s.question.id_form == form_id) > 0 || p.answer_variant.Count(s => s.variant.question.id_form == form_id) > 0 || p.answer_table.Count(s => s.table_question.question.id_form == form_id) > 0 || p.answer_file.Count(s => s.variant_file.question.id_form == form_id) > 0).ToList();

            workSheet.Cells[1, 1].Value = "Область";
            workSheet.Cells[1, 2].Value = "Район";
            workSheet.Cells[1, 3].Value = "Школа";
            workSheet.Cells[1, 4].Value = "Предмет";
            rows = 3;
            for (int s = 0; s < users.Count(); ++s)
            {
                user u = users.ElementAt(s);
                workSheet.Cells[rows, 1].Value   = u.schools.districts.areas.name;
                workSheet.Cells[rows, 2].Value   = u.schools.districts.name;
                workSheet.Cells[rows, 3].Value   = u.schools.name;
                workSheet.Cells[rows++, 4].Value = u.subjects.name;
            }
            for (int i = 0; i < list.Count(); ++i)
            {
                question q = list.ElementAt(i);
                workSheet.Cells[1, cols].Value = list.ElementAt(i).name;
                rows = 3;
                if (list.ElementAt(i).id_type_question == 1)
                {
                    for (int j = 0; j < users.Count(); ++j)
                    {
                        user        u  = users.ElementAt(j);
                        answer_text a1 = answer_text.FirstOrDefault(p => p.id_user == u.id && p.id_question == q.id);
                        workSheet.Cells[rows++, cols].Value = (a1 != null) ? a1.name : "";
                    }
                    cols++;
                }
                else if (list.ElementAt(i).id_type_question == 2 || list.ElementAt(i).id_type_question == 4)
                {
                    for (int j = 0; j < users.Count(); ++j)
                    {
                        user           u   = users.ElementAt(j);
                        answer_variant a2  = answer_variant.FirstOrDefault(p => p.id_user == u.id && p.variant.id_question == q.id);
                        string         ask = (a2 != null) ? a2.variant.name : "";
                        if (answer_else.FirstOrDefault(p => p.question_else.id_question == q.id && p.id_user == u.id) != null)
                        {
                            if (a2 != null)
                            {
                                ask += ", ";
                            }
                            ask += answer_else.FirstOrDefault(p => p.question_else.id_question == q.id && p.id_user == u.id).name;
                        }
                        workSheet.Cells[rows++, cols].Value = ask;
                    }
                    cols++;
                }
                else if (list.ElementAt(i).id_type_question == 3)
                {
                    for (int j = 0; j < users.Count(); ++j)
                    {
                        user u = users.ElementAt(j);
                        List <answer_variant> a2 = answer_variant.Where(p => p.id_user == u.id && p.variant.id_question == q.id).ToList();
                        string res = "";
                        for (int k = 0; k < a2.Count(); ++k)
                        {
                            res += a2.ElementAt(k).variant.name;
                            if (k != (a2.Count() - 1))
                            {
                                res += ", ";
                            }
                        }
                        answer_else el = answer_else.FirstOrDefault(p => p.question_else.id_question == q.id && p.id_user == u.id);
                        if (el != null)
                        {
                            res += ", " + el.name;
                        }
                        workSheet.Cells[rows++, cols].Value = res;
                    }
                    cols++;
                }
                else if (list.ElementAt(i).id_type_question == 5)
                {
                    List <table_question> table_question = db.table_question.Where(p => p.id_question == q.id).ToList();
                    for (int k = 0; k < table_question.Count(); ++k)
                    {
                        table_question t_q = table_question.ElementAt(k);
                        workSheet.Cells[2, cols].Value = t_q.name;
                        rows = 3;
                        for (int j = 0; j < users.Count(); ++j)
                        {
                            user         u  = users.ElementAt(j);
                            answer_table a3 = answer_table.FirstOrDefault(p => p.id_user == u.id && p.id_table_question == t_q.id);
                            workSheet.Cells[rows++, cols].Value = (a3 != null) ? a3.table_variant.name : "";
                        }
                        cols++;
                    }
                }
                else if (list.ElementAt(i).id_type_question == 6)
                {
                    List <table_question> table_question = db.table_question.Where(p => p.id_question == q.id).ToList();
                    for (int k = 0; k < table_question.Count(); ++k)
                    {
                        table_question t_q = table_question.ElementAt(k);
                        workSheet.Cells[2, cols].Value = t_q.name;
                        rows = 3;
                        for (int j = 0; j < users.Count(); ++j)
                        {
                            user u = users.ElementAt(j);
                            List <answer_table> a3 = answer_table.Where(p => p.id_user == u.id && p.id_table_question == t_q.id).ToList();
                            string res             = "";
                            for (int w = 0; w < a3.Count(); ++w)
                            {
                                res += a3.ElementAt(w).table_variant.name;
                                if (w < (a3.Count() - 1))
                                {
                                    res += ", ";
                                }
                            }
                            workSheet.Cells[rows++, cols].Value = res;
                        }
                        cols++;
                    }
                }
                else if (list.ElementAt(i).id_type_question == 7)
                {
                    for (int j = 0; j < users.Count(); ++j)
                    {
                        user        u  = users.ElementAt(j);
                        answer_file a4 = answer_file.FirstOrDefault(p => p.user_id == u.id && p.variant_file.question_id == q.id);
                        workSheet.Cells[rows++, cols].Value = (a4 != null) ? a4.link : "";
                    }
                    cols++;
                }
            }
            var path = Path.Combine(Server.MapPath("~/Content/files/"), "ask_" + form_id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx");

            using (var memoryStream = new MemoryStream())
            {
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment; filename=" + path);
                excel.SaveAs(memoryStream);
                memoryStream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }

            FileInfo fi = new FileInfo(path);
            long     sz = fi.Length;

            Response.ClearContent();
            Response.ContentType = Path.GetExtension(path);
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", System.IO.Path.GetFileName(path)));
            Response.AddHeader("Content-Length", sz.ToString("F0"));
            Response.TransmitFile(path);
            Response.End();

            System.IO.File.Delete(path);
            return(Redirect("/Forms/Details?id=" + form_id));
        }
 public int EditQuestion(int id, question EditQuestion)
 {
     return(bllService.EditQuestion(EditQuestion, id));
 }
 public List<tag> gettagsbyname(question questionone)
 {
     string[] names = questionone.tags.Split(',');
        List<tag> result = new List<tag>();
        foreach (string item in names)
        {
        var onetag = TagRY.GetTagByID(item);
        result.Add(onetag);
        }
        return result;
 }
        private void AddQuestion(question q, bool isRoot, bool hideQuestion)
        {
            int lastBottom;

            if (isRoot)
            {
                questionCount++;

                // Slight hack here because sometimes the root category does not have
                // a question in it, and the root level is deeper. Will have problems
                // with deeply nested questions, should be addressed at some point
                if (q.parent == currentParentCategory.id)
                {
                    displayDepth = 0;
                }
                else
                {
                    displayDepth = 1;
                }

                if (!categories.ContainsKey(q.parent))
                {
                    categories.Add(q.parent, displayDepth);
                }
            }
            else if (!categories.ContainsKey(q.parent))
            {
                questionCount++;

                if (categories.ContainsKey(q.ParentQuestion.parent))
                {
                    displayDepth = categories[q.ParentQuestion.parent] + 1;
                }
                else
                {
                    displayDepth++;
                }
                categories.Add(q.parent, displayDepth);
            }
            else
            {
                questionCount++;
                displayDepth = categories[q.parent];
            }

            if (q.is_fork)
            {
                if (!categories.ContainsKey(q.id))
                {
                    categories.Add(q.id, displayDepth);
                }
            }

            if (lastAdded == null)
            {
                lastBottom = 0;
            }
            else
            {
                lastBottom = lastAdded.Bottom;
            }

            if (q.type == question.QuestionTypes.Category)
            {
                AddCategoryLabel(q, hideQuestion);
            }
            else
            {
                CallQuestionAnswerDisplay cqad = new CallQuestionAnswerDisplay(q, null, CurrentCall);

                cqad.Location = new Point(DEFAULTX + (DEFAULTINDENT * displayDepth), lastBottom + SPACER);

                if (q.is_fork)
                {
                    cqad.Top += CATEGORYSPACER;
                }
                cqad.TabIndex          = controlCount;
                cqad.Name              = "cqad" + controlCount;
                cqad.Size              = new Size(Width - DEFAULTX - 15 - (DEFAULTINDENT * displayDepth), cqad.DefaultHeight);
                cqad.Anchor            = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                cqad.BorderStyle       = BorderStyle.FixedSingle;
                cqad.QuestionAnswered += new EventHandler <QuestionAnsweredEventArgs>(cqad_QuestionAnswered);
                cqad.QuestionCleared  += new EventHandler <QuestionAnsweredEventArgs>(cqad_QuestionCleared);
                cqad.IsHidden          = hideQuestion;
                cqad.Size              = new Size(Width - DEFAULTX - 15 - (DEFAULTINDENT * displayDepth), cqad.DefaultHeight);
                cqad.DisplayDepth      = displayDepth;

                controlCount++;

                lastAdded = cqad;
                pnlControls.Controls.Add(cqad);
                formControls[currentParentCategory.id].Add(cqad);
            }
        }
Exemple #23
0
 public void add(question entity)
 {
     que.Insert(entity.Subject, entity.Question, entity.Answer, entity.Status);
 }
 private List <Control> GetChildQuestionsRecursive(question parentQuestion, string givenAnswer)
 {
     return(GetChildQuestionsRecursive(parentQuestion, givenAnswer, true));
 }
Exemple #25
0
        private void simpleButtonSaveQuestion_Click(object sender, EventArgs e)
        {
            //if (BackgroundWorker != null)
            //    BackgroundWorker.StartWork("Saving Question");
            Cursor currentCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            int rowcount = 0;

            DataTable dt = gridControlQuestions.DataSource as DataTable;
            rowcount = dt.Rows.Count;
            if (!IsSaved) {
                m_oQuestion = new question();
            } else {
                if (m_oQuestion == null) {
                    m_oQuestion = BPContext.questions.Include("questions_text_language").FirstOrDefault(p => p.id == QuestionID);
                }
            }

            m_oQuestion.modified_date = DateTime.Now;
            if (!string.IsNullOrEmpty(comboBoxEditQuestionGeneralValue.SelectedText))
                m_oQuestion.general_value = Convert.ToByte(comboBoxEditQuestionGeneralValue.SelectedText);

            if (IsSaved) {
                //m_oQuestion exisiting questions
                m_oQuestion.questions_text_language.ToList().ForEach(qt => BPContext.questions_text_language.DeleteObject(qt));
            }

            DataRowView rowView = null;
            questions_text_language qtextlang;
            for (int x = 0; x < rowcount; ++x) {
                rowView = (DataRowView)gridViewQuestion.GetRow(x);
                qtextlang = new questions_text_language();
                qtextlang.language_id = int.Parse(rowView.Row["language"].ToString());
                qtextlang.question_text = rowView.Row["question"].ToString();
                qtextlang.question_description = rowView.Row["description"].ToString();
                qtextlang.question_help_text = rowView.Row["helptext"].ToString();
                m_oQuestion.questions_text_language.Add(qtextlang);
            }
            if (IsSaved) {
                //delete existing tags in this question
                m_oQuestion.questions_questiontags.ToList().ForEach(qt => BPContext.questions_questiontags.DeleteObject(qt));
            }
            if (dictionarySelectedTags != null) {
                foreach (KeyValuePair<string, int> kvp in dictionarySelectedTags) {
                    m_oQuestion.questions_questiontags.Add(
                            new questions_questiontags() {
                                questiontags_id = kvp.Value
                            }
                        );

                }
            }
            if (!IsSaved) {
                BPContext.questions.AddObject(m_oQuestion);
                IsSaved = true;
            }
            BPContext.SaveChanges();
            if (QuestionID <= 0)
                QuestionID = m_oQuestion.id;

            groupControlAnswerForm.Enabled = true;
            simpleButtonSaveQuestion.Enabled = true;

            Cursor.Current = currentCursor;
            MessageBox.Show("Questions has been saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //if (BackgroundWorker != null) BackgroundWorker.StopWork();
        }
Exemple #26
0
        public ActionResult soruOlustur(question quest)
        {
            string           baslik = veriAl("https://www.wired.com", "//*[@id='app-root']" + quest.baslik);
            SQLiteConnection baglan = new SQLiteConnection();

            baglan.ConnectionString = ("Data Source=Entities/KonusarakOgren.db");
            baglan.Open();
            string        sql = "INSERT INTO text(baslik,icerik) VALUES (@baslik,@icerik)";
            SQLiteCommand cmd = new SQLiteCommand(sql, baglan);

            cmd.Parameters.AddWithValue("@baslik", baslik);
            cmd.Parameters.AddWithValue("@icerik", quest.icerik);
            cmd.ExecuteNonQuery();

            string        sql2 = "SELECT id FROM text WHERE baslik=@baslik";
            SQLiteCommand cmd2 = new SQLiteCommand(sql2, baglan);

            cmd2.Parameters.AddWithValue("@baslik", baslik);
            var reader = cmd2.ExecuteReader();
            int id     = 0;

            while (reader.Read())
            {
                id = reader.GetInt32(0);
            }

            string sql3 = "INSERT INTO question(textid,soru,secenekA,secenekB,secenekC,secenekD,dogruCevap) VALUES (@textid,@soru,@secenekA,@secenekB,@secenekC,@secenekD,@dogruCevap)";

            SQLiteCommand cmd3 = new SQLiteCommand(sql3, baglan);

            for (int i = 0; i < 4; i++)
            {
                cmd3.Parameters.AddWithValue("@textid", id);
                cmd3.Parameters.AddWithValue("@soru", quest.soru[i]);
                cmd3.Parameters.AddWithValue("@secenekA", quest.secenekA[i]);
                cmd3.Parameters.AddWithValue("@secenekB", quest.secenekB[i]);
                cmd3.Parameters.AddWithValue("@secenekC", quest.secenekC[i]);
                cmd3.Parameters.AddWithValue("@secenekD", quest.secenekD[i]);
                switch (quest.dogruCevap[i])
                {
                case "A":
                    cmd3.Parameters.AddWithValue("@dogruCevap", quest.secenekA[i]);
                    break;

                case "B":
                    cmd3.Parameters.AddWithValue("@dogruCevap", quest.secenekB[i]);
                    break;

                case "C":
                    cmd3.Parameters.AddWithValue("@dogruCevap", quest.secenekC[i]);
                    break;

                case "D":
                    cmd3.Parameters.AddWithValue("@dogruCevap", quest.secenekD[i]);
                    break;
                }

                cmd3.ExecuteNonQuery();
            }

            return(RedirectToAction("index", "Test"));
        }
 public question(string[] texts, int viewInt, question nex)
 {
     questionText = texts;
     viewIndex    = viewInt;
     next         = nex;
 }
        private IQuestion convert(question xmlQuestion) {
            var question = questionFactory.Create();

            question.Description = "Answer the Question.";
            question.Question = xmlQuestion.text;
            question.IsAnswered = false;

            foreach (var xmlAnswer in xmlQuestion.answer) {
                question.Answers.Add(convert(xmlAnswer));
            }
            return question;
        }
Exemple #29
0
        private void LoadQuestion(int questionid)
        {
            IsQLSave = true; IsSaved = true;

            #region Load Questions
            DataTable dt = gridControlQuestions.DataSource as DataTable;
            m_oQuestion = BPContext.questions.Include("questions_text_language").FirstOrDefault(p => p.id == questionid);
            if (m_oQuestion == null) {
                return;
            }
            btnEditQuestion.Enabled = true;
            btnDeleteQuestion.Enabled = true;

            if (m_oQuestion.general_value != null && !string.IsNullOrEmpty(m_oQuestion.general_value.ToString()))
                comboBoxEditQuestionGeneralValue.EditValue = m_oQuestion.general_value.ToString();
            var qtl = m_oQuestion.questions_text_language.Where(p => p.MGC == false);

            DataRow dr = null;
            qtl.ForEach(delegate(questions_text_language dqtl) {
                dr = dt.NewRow();
                dr["question_id"] = dqtl.questions_id;
                dr["question_text_language_id"] = dqtl.id;
                dr["language_id"] = dqtl.language_id;
                dr["question"] = dqtl.question_text;
                dr["description"] = dqtl.question_description;
                dr["helptext"] = dqtl.question_help_text;
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();

            dictionarySelectedTags = new Dictionary<string, int>();
            var qqt = m_oQuestion.questions_questiontags;
            questiontag qt = null;
            KeyValuePair<string, int> ItemToAdd = new KeyValuePair<string, int>(); //[@jeff 09.15.2011 #462]: added
            qqt.ForEach(delegate(questions_questiontags dqts) {
                qt = dqts.questiontag;
                //[@jeff 09.15.2011 #462]: check key val pair if exists in the dictionary, before insert
                ItemToAdd = new KeyValuePair<string, int>(qt.title, qt.id);
                if (!dictionarySelectedTags.ContainsKey(qt.title))
                    dictionarySelectedTags.Add(qt.title, qt.id);
            });

            simpleButtonSaveQuestion.Enabled = true;
            groupControlAnswerForm.Enabled = true;
            #endregion

            #region Load Answer forms
            dt = gridControlAnswerForm.DataSource as DataTable;
            m_oQuestionLayouts = BPContext.questionlayouts.Include("questionlayout_language").Where(p => p.questions_id == questionid);
            if (m_oQuestionLayouts != null && m_oQuestionLayouts.Count() > 0) {
                btnEditAnswerform.Enabled = true;
                btnDeleteAnswerform.Enabled = true;
            } else {
                btnEditAnswerform.Enabled = false;
                btnDeleteAnswerform.Enabled = false;
            }
            CampaignQuestionnaire cQ = null;
            var cbeItems = comboBoxEditComponentType.Properties.Items;
            string componentType = string.Empty;
            questionlayout_language qlang = null;
            m_oQuestionLayouts.ForEach(delegate(questionlayout ql) {
                cQ = CampaignQuestionnaire.InstanciateWith(ql.content_json);
                for (int x = 0; x < cbeItems.Count; ++x) {
                    if (cbeItems[x].ToString().ToLower() == cQ.Type.ToLower())
                        componentType = cbeItems[x].ToString();
                }
                dr = dt.NewRow();
                dr["question_id"] = ql.questions_id;
                dr["question_layout_id"] = ql.id;
                dr["title"] = ql.title;
                dr["component_type"] = componentType;
                dr["general_value"] = ql.general_value;
                dr["account_level"] = ql.account_level;
                dr["properties"] = cQ;
                qlang = ql.questionlayout_language.FirstOrDefault();
                if (qlang != null) {
                    dr["language"] = qlang.language.name;
                    dr["language_id"] = qlang.language_id;
                } else {
                    dr["language"] = null;
                    dr["language_id"] = null;
                }
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();
            if (dt.Rows.Count <= 0) {
                btnEditAnswerform.Enabled = false;
                btnDeleteAnswerform.Enabled = false;
            }
            #endregion
        }
Exemple #30
0
        private void simpleButtonSaveAnswerForm_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate()) {
                return;
            }

            Cursor currentCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            DataView dtView = gridViewAnswerForm.DataSource as DataView;
            CampaignQuestionnaire oQuestionnaire = propertyGridControl1.SelectedObject as CampaignQuestionnaire;
            if (dtView != null && dtView.Table != null) {
                DataTable dtAF = dtView.Table as DataTable;
                DataRow dr;
                if (eSaveMode == SaveMode.Add) {
                    dr = dtAF.NewRow();
                } else {
                    dr = dtAF.Rows[gridViewAnswerForm.FocusedRowHandle];
                }
                dr["language"] = lookUpEditLanguage.GetColumnValue("name");
                dr["language_id"] = lookUpEditLanguage.EditValue;
                dr["title"] = textEditAnswerFormName.EditValue;
                dr["component_type"] = comboBoxEditComponentType.SelectedItem;
                dr["general_value"] = comboBoxEditAnswerFormGeneralValue.SelectedItem;
                dr["properties"] = oQuestionnaire;
                if (eSaveMode == SaveMode.Add)
                    dtAF.Rows.Add(dr);
                dtAF.AcceptChanges();
                gridControlAnswerForm.DataSource = dtAF;
            }

            int rowcount = 0;
            DataTable dt = gridControlAnswerForm.DataSource as DataTable;
            rowcount = dt.Rows.Count;
            if(m_oQuestionLayouts == null)
                m_oQuestionLayouts = BPContext.questionlayouts.Include("questionlayout_language").Where(p => p.questions_id == QuestionID);
            if(m_oQuestion == null)
                m_oQuestion = BPContext.questions.FirstOrDefault(p => p.id == QuestionID);

            if (IsQLSave) {
                //delete existing questionlayout in this question
                m_oQuestionLayouts.ToList().ForEach(delegate(questionlayout qt) {
                    BPContext.questionlayout_language.DeleteObject(qt.questionlayout_language.FirstOrDefault());
                    BPContext.questionlayouts.DeleteObject(qt);
                });
            }

            DataRowView rowView = null;
            questionlayout qlayout;
            questionlayout_language qlang;
            object general = null;
            for (int x = 0; x < rowcount; ++x) {
                rowView = (DataRowView)gridViewAnswerForm.GetRow(x);
                qlayout = new questionlayout();
                qlayout.modified_date = DateTime.Now;
                qlayout.modified_by = 0;
                qlayout.created_by = 0;
                qlayout.default_setting = false;
                qlayout.title = rowView.Row["title"].ToString();
                qlayout.content_json = (rowView["properties"] as CampaignQuestionnaire).ToJSONString();
                general = rowView["general_value"];
                qlayout.general_value = general != null && !string.IsNullOrEmpty(general.ToString()) ? byte.Parse(general.ToString()) : byte.Parse("0");
                qlang = new questionlayout_language();
                qlang.language_id = int.Parse(rowView.Row["language_id"].ToString());
                qlayout.questionlayout_language.Add(qlang);
                m_oQuestion.questionlayouts.Add(qlayout);
            }
            BPContext.SaveChanges();
            IsQLSave = true;

            lookUpEditLanguage.ItemIndex = -1;
            textEditAnswerFormName.EditValue = "";
            comboBoxEditComponentType.SelectedIndex = -1;
            comboBoxEditAnswerFormGeneralValue.SelectedIndex = -1;
            propertyGridControl1.SelectedObject = null;
            //layoutControlGroupPreview.Clear();
            DisposeGroupControls(this.layoutControlGroupPreview);
            layoutControlPreview.Refresh();
            ForceCellValueChange();
            Cursor.Current = currentCursor;
            MessageBox.Show("Answer forms has been saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public Tuple <string, bool> JudgeSql(string username, question ques, string ans, string back_name)
        {
            ans = ans.Trim();
            ans = ans.TrimEnd(';');
            string            except     = null;
            var               nback_name = CopyBack(username, back_name);
            bool              iscorrect  = false;
            KingbaseESCommand cmd        = new KingbaseESCommand("SET search_path TO " + '"' + nback_name + '"' + ",public", conn);

            cmd.ExecuteNonQuery();
            cmd.CommandText = ques.right_answer;
            DataSet right_ds = new DataSet();

            if (ques.q_type == 1)
            {
                KingbaseESDataAdapter da = new KingbaseESDataAdapter(cmd);
                da.Fill(right_ds);
                da.Dispose();
            }
            else if (ques.q_type == 2)
            {
                cmd.ExecuteNonQuery();
                cmd.CommandText = ques.check_sentence;
                KingbaseESDataAdapter da = new KingbaseESDataAdapter(cmd);
                da.Fill(right_ds);
                da.Dispose();
                DeleteBack(nback_name);
                nback_name = CopyBack(username, back_name);
            }
            cmd.CommandText    = ans;
            cmd.CommandTimeout = 5;
            DataTable ans_dt = new DataTable();

            if (ques.q_type == 2)
            {
                try { cmd.ExecuteNonQuery(); }
                catch (System.Exception e) {
                    except          = e.Message;
                    iscorrect       = false;
                    cmd.CommandText = $"DROP SCHEMA \"{nback_name}\" CASCADE";
                    cmd.ExecuteNonQuery();
                    return(new Tuple <string, bool>(except, iscorrect));
                }
                cmd.CommandText = ques.check_sentence;
            }
            else
            {
                cmd.CommandText = ans + " limit 100";
            }
            //KingbaseESDataReader dr = null;
            int count = 0;

            try {
                /*
                 * dr = cmd.ExecuteReader();
                 * for (var i = 0; i < dr.FieldCount; i++) {
                 *  DataColumn column = new DataColumn();
                 *  column.DataType = dr.GetFieldType(i);
                 *  column.ColumnName = dr.GetName(i);
                 *  ans_dt.Columns.Add(column);
                 * }
                 * while (dr.Read() && count<=60) {
                 *  DataRow row = ans_dt.NewRow();
                 *  for(var i = 0; i < dr.FieldCount; i++) {
                 *      row[i] = dr[i].ToString();
                 *  }
                 *  ans_dt.Rows.Add(row);
                 *  row = null;
                 *  count++;
                 * }
                 * dr.Close();
                 */
                KingbaseESDataAdapter da = new KingbaseESDataAdapter(cmd);
                da.Fill(0, 100, ans_dt);
                da.Dispose();
                var res = DataTableCompare(ans_dt, right_ds.Tables[0]);
                if (res.Item1.Length > 0 || res.Item2.Length > 0)
                {
                    iscorrect = false;
                    if (ques.q_type == 2)
                    {
                        except += $"验证语句{ques.check_sentence}下\n";
                    }
                    if (res.Item1.Length > 0)
                    {
                        var str = "";
                        foreach (var item in res.Item1[0].ItemArray)
                        {
                            str += item.ToString().TrimEnd(' ') + ' ';
                        }
                        except += $"比正确结果少{res.Item1.Length}个,如:{str}\n";
                    }
                    if (res.Item2.Length > 0)
                    {
                        var str = "";
                        foreach (var item in res.Item2[0].ItemArray)
                        {
                            str += item.ToString().TrimEnd(' ') + ' ';
                        }
                        except += $"比正确结果多{res.Item2.Length}个,如:{str}\n";
                    }
                }
                else
                {
                    iscorrect = true;
                    except    = "congratulations!!";
                }
            }
            catch (System.Exception e) {
                except    = e.Message;
                iscorrect = false;
            }
            cmd.CommandText = $"DROP SCHEMA \"{nback_name}\" CASCADE";
            try { cmd.ExecuteNonQuery(); }
            catch (System.Exception e) {
                except    = "执行超时";
                iscorrect = false;
            }
            var re = new Tuple <string, bool>(except, iscorrect);

            return(re);
        }
Exemple #32
0
        private void simpleButtonSaveAnswerForm_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate()) {
                return;
            }

            Cursor currentCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            DataView dtView = gridViewAnswerForm.DataSource as DataView;
            CampaignQuestionnaire oQuestionnaire = propertyGridControl1.SelectedObject as CampaignQuestionnaire;
            oQuestionnaire.Form.Settings.QuestionText = "";
            oQuestionnaire.Form.Settings.QuestionHelp = "";
            oQuestionnaire.Form.Settings.DataBindings.account_level = (bool)rgLevel.EditValue;

            if (dtView != null && dtView.Table != null) {
                m_oQuestion = BPContext.questions.FirstOrDefault(p => p.id == QuestionID);

                DataTable dtAF = dtView.Table;
                DataRow dr;
                questionlayout qlayout;
                questionlayout_language qlang;
                object general = null;

                if (eSaveMode == SaveMode.Add) {
                    qlayout = new questionlayout();
                    qlang = new questionlayout_language();
                    qlayout.created_by = UserSession.CurrentUser.UserId;

                    dr = dtAF.NewRow();
                } else {
                    dr = dtAF.Rows[gridViewAnswerForm.FocusedRowHandle];
                    if (dr == null) return;

                    int qlid = Convert.ToInt32(dr["question_layout_id"]);
                    qlayout = BPContext.questionlayouts
                                .Include("questionlayout_language")
                                .FirstOrDefault(p => p.id == qlid);
                    qlang = qlayout.questionlayout_language.FirstOrDefault();
                    qlayout.modified_by = UserSession.CurrentUser.UserId;
                }
                qlayout.modified_date = DateTime.Now;
                qlayout.default_setting = false;
                qlayout.title = textEditAnswerFormName.EditValue.ToString();
                qlayout.content_json = oQuestionnaire.ToJSONString();
                qlayout.account_level = (bool)rgLevel.EditValue;
                general = comboBoxEditAnswerFormGeneralValue.SelectedItem;
                qlayout.general_value = general != null && !string.IsNullOrEmpty(general.ToString()) ? byte.Parse(general.ToString()) : byte.Parse("0");
                qlang.language_id = int.Parse(lookUpEditLanguage.EditValue.ToString());

                if (eSaveMode == SaveMode.Add) {
                    qlayout.questionlayout_language.Add(qlang);
                    m_oQuestion.questionlayouts.Add(qlayout);
                }
                BPContext.SaveChanges();
                IsQLSave = true;

                dr["question_id"] = QuestionID;
                dr["question_layout_id"] = qlayout.id;
                dr["language"] = lookUpEditLanguage.GetColumnValue("name");
                dr["language_id"] = lookUpEditLanguage.EditValue;
                dr["title"] = textEditAnswerFormName.EditValue;
                dr["component_type"] = comboBoxEditComponentType.SelectedItem;
                dr["general_value"] = comboBoxEditAnswerFormGeneralValue.SelectedItem;
                dr["account_level"] = (bool)rgLevel.EditValue;
                dr["properties"] = oQuestionnaire;
                if (eSaveMode == SaveMode.Add)
                    dtAF.Rows.Add(dr);
                dtAF.AcceptChanges();
                gridControlAnswerForm.DataSource = dtAF;
            }
            lcgAnswerForm.Enabled = false;
            btnEditAnswerform.Enabled = true;
            btnDeleteAnswerform.Enabled = true;
            btnAddAnswerform.Enabled = true;
            eSaveMode = SaveMode.Unspecified;

            lookUpEditLanguage.ItemIndex = -1;
            textEditAnswerFormName.EditValue = "";
            comboBoxEditComponentType.SelectedIndex = -1;
            comboBoxEditAnswerFormGeneralValue.SelectedIndex = -1;
            propertyGridControl1.SelectedObject = null;
            //layoutControlGroupPreview.Clear();
            DisposeGroupControls(this.layoutControlGroupPreview);
            layoutControlPreview.Refresh();
            ForceCellValueChange();
            Cursor.Current = currentCursor;
            if (sender != null && sender.ToString() != "skip")
                MessageBox.Show("Answer forms has been saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //if (this.ParentForm != null) {
            //    this.ParentForm.DialogResult = DialogResult.OK;
            //}
        }
 public void nextQuestion()
 {
     numOfQuestionsToAsk--;
     currentQuestion = currentQuestion.getNext();
 }
        /// <summary>
        /// Method that attempts to save a new question for the given treasure hunt.
        /// </summary>
        public async void ExecuteSaveQuestionCommand()
        {
            PopupMessage = "Saving...";
            PopupDisplayed = true;
            if (connectionChecker.IsInternetConnected())
            {
                //If the question does not already exist for this treasure hunt
                if (!DoesQuestionAlreadyExist(NewQuestion))
                {
                    //The location of where the new QR code image associated with this question will be stored.
                    String locationOfQrCodeImage = myFileDirectory + "QRCodes\\" + 
                        this.CurrentTreasureHunt.HuntId + " " + this.newQuestion + ".png";

                    //Then save the question to the database 
                    question brandNewQuestion = new question();
                    brandNewQuestion.Question1 = this.newQuestion;
                    brandNewQuestion.URL = locationOfQrCodeImage;
                    long questionId = await this.serviceClient.SaveQuestionAsync(brandNewQuestion);

                    SaveHuntQuestion(questionId);
                    EncodeQRCode(locationOfQrCodeImage);        
                }
                else
                {
                    PopupDisplayed = false;
                    String messageBoxText = "This question already exists!";
                    String caption = "Question Already Exists";
                    MessageBoxResult box = MessageBox.Show(messageBoxText, caption);
                    NewQuestion = String.Empty;
                }
            }
            else
            {
                MessageBoxResult messageBox = MessageBox.Show(connectionChecker.ShowConnectionErrorMessage());
            }

            
        }
        //Страница редактирования вопроса
        public ActionResult EditQuestion(int id)
        {
            question question = db.question.Find(id);

            return(View(question));
        }
        public ActionResult EditQuestion(int id, string text_quest, int is_required, int number_ask, string comment)
        {
            question question = db.question.Find(id);

            question.name        = text_quest;
            question.is_required = (is_required == 1) ? true : false;
            question.number      = number_ask;
            question.comment     = comment;
            question.video_url   = Request.Form["video"];
            var f = Request.Files["file"];

            if (f != null && f.ContentLength > 0)
            {
                string newName  = String.Format("File_{0}_{1}{2}", DateTime.Now.ToString("yyyyMMddHHmmssfff"), Guid.NewGuid(), Path.GetExtension(f.FileName));
                var    fileName = Path.GetFileName(f.FileName);
                var    path     = Path.Combine(Server.MapPath("~/Content/quest_file/"), newName);
                f.SaveAs(path);
                question.img_url = "/Content/quest_file/" + newName;
            }
            else
            {
                question.img_url = null;
            }
            db.question.AddOrUpdate(question);
            db.SaveChanges();
            if (question.id_type_question == 2 || question.id_type_question == 3 || question.id_type_question == 4)   //RADIO, CHECKBOX, SELECT
            {
                string         result  = Request.Unvalidated.Form["variant"];
                String[]       variant = result.Split(','); //список вариантов в виде массива
                List <variant> v       = db.variant.Where(p => p.id_question == id).ToList();
                for (int i = 0; i < variant.Count(); ++i)
                {
                    if (!variant[i].Equals(""))
                    {
                        int k = 0;
                        variant[i] = variant[i].Replace("&#044", ",");
                        foreach (var item in v)
                        {
                            if (item.name.CompareTo(variant[i]) == 0)
                            {
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0)
                        {
                            variant quest = new variant();
                            quest.id          = (db.variant.Count() > 0) ? (db.variant.Max(p => p.id) + 1) : 1;
                            quest.name        = variant[i];
                            quest.number      = i + 1;
                            quest.id_question = question.id;
                            db.variant.Add(quest);
                            db.SaveChanges();
                        }
                    }
                }
                for (int j = 0; j < v.Count(); ++j)
                {
                    int k = 0;
                    for (int i = 0; i < variant.Count(); ++i)
                    {
                        if (v.ElementAt(j).name.CompareTo(variant[i]) == 0)
                        {
                            k = 1;
                            break;
                        }
                    }
                    if (k == 0)
                    {
                        int var_id = v.ElementAt(j).id;
                        List <answer_variant> a = db.answer_variant.Where(p => p.variant.id == var_id).ToList();
                        db.answer_variant.RemoveRange(a);
                        db.SaveChanges();
                        variant del = v.ElementAt(j);
                        db.variant.Remove(del);
                        v.RemoveAt(j);
                        db.SaveChanges();
                        --j;
                    }
                }

                //Вариант ДРУГОЕ
                string else_v  = Request.Form["else"];
                int    db_else = db.question_else.Count(p => p.id_question == id);
                if (db_else > 0 && else_v == null)
                {
                    if (db.answer_else.Count(p => p.question_else.id_question == id) > 0)
                    {
                        List <answer_else> a = db.answer_else.Where(p => p.question_else.id_question == id).ToList();
                        db.answer_else.RemoveRange(a);
                        db.SaveChanges();
                    }
                    List <question_else> b = db.question_else.Where(p => p.id_question == id).ToList();
                    db.question_else.RemoveRange(b);
                    db.SaveChanges();
                }
                else if (db_else == 0 && else_v != null)
                {
                    question_else q_else = new question_else();
                    q_else.id          = (db.question_else.Count() > 0) ? (db.question_else.Max(p => p.id) + 1) : 1;
                    q_else.id_question = question.id;
                    q_else.name        = else_v;
                    db.question_else.Add(q_else);
                    db.SaveChanges();
                }
                else if (db_else > 0 && else_v != null)
                {
                    question_else q_else = db.question_else.First(p => p.id_question == id);
                    q_else.name = else_v;
                    db.question_else.AddOrUpdate(q_else);
                    db.SaveChanges();
                }
                //Вариант ДРУГОЕ (end)
            }

            else if (question.id_type_question == 5 || question.id_type_question == 6) //TYPE TABLE_RADIO AND TABLE_CHECKBOX
            {
                //DEL TABLE ROW
                string   row            = Request.Unvalidated.Form["table_row"];
                string[] rows           = row.Split(',');
                List <table_question> q = db.table_question.Where(p => p.id_question == question.id).ToList();
                for (int i = 0; i < rows.Count(); ++i)
                {
                    int k = 0;
                    foreach (var item in q)
                    {
                        if (item.name.CompareTo(rows[i]) == 0)
                        {
                            k = 1;
                            break;
                        }
                    }
                    if (k == 0)
                    {
                        table_question t_q = new table_question();
                        t_q.id          = (db.table_question.Count() > 0) ? (db.table_question.Max(p => p.id) + 1) : 1;;
                        t_q.id_question = question.id;
                        t_q.number      = i + 1;
                        t_q.name        = rows[i].Replace("&#044", ",");
                        db.table_question.Add(t_q);
                        db.SaveChanges();
                    }
                }
                for (int i = 0; i < q.Count(); ++i)
                {
                    int k = 0;
                    foreach (var item in rows)
                    {
                        string name = q.ElementAt(i).name;
                        if (item.CompareTo(name) == 0)
                        {
                            k = 1;
                            break;
                        }
                    }
                    if (k == 0)
                    {
                        int var_id            = q.ElementAt(i).id;
                        List <answer_table> a = db.answer_table.Where(p => p.id_table_question == var_id).ToList();
                        db.answer_table.RemoveRange(a);
                        db.SaveChanges();
                        table_question del = q.ElementAt(i);
                        db.table_question.Remove(del);
                        q.RemoveAt(i);
                        db.SaveChanges();
                        --i;
                    }
                }
                //DEL TABLE ROW (END)

                //DEL TABLE COL
                string               col  = Request.Unvalidated.Form["table_col"];
                string[]             cols = col.Split(',');
                List <table_variant> v    = db.table_variant.Where(p => p.id_question == question.id).ToList();
                for (int i = 0; i < cols.Count(); ++i)
                {
                    int k = 0;
                    foreach (var item in v)
                    {
                        if (item.name.CompareTo(cols[i]) == 0)
                        {
                            k = 1;
                            break;
                        }
                    }
                    if (k == 0)
                    {
                        table_variant t_v = new table_variant();
                        t_v.id          = (db.table_variant.Count() > 0) ? (db.table_variant.Max(p => p.id) + 1) : 1;;
                        t_v.id_question = question.id;
                        t_v.number      = i + 1;
                        t_v.name        = cols[i].Replace("&#044", ",");
                        db.table_variant.Add(t_v);
                        db.SaveChanges();
                    }
                }
                for (int i = 0; i < v.Count(); ++i)
                {
                    int k = 0;
                    foreach (var item in cols)
                    {
                        string name = v.ElementAt(i).name;
                        if (item.CompareTo(name) == 0)
                        {
                            k = 1;
                            break;
                        }
                    }
                    if (k == 0)
                    {
                        int var_id            = v.ElementAt(i).id;
                        List <answer_table> a = db.answer_table.Where(p => p.id_table_variant == var_id).ToList();
                        db.answer_table.RemoveRange(a);
                        db.SaveChanges();
                        table_variant del = v.ElementAt(i);
                        db.table_variant.Remove(del);
                        v.RemoveAt(i);
                        db.SaveChanges();
                        --i;
                    }
                }
                //DEL TABLE COL (END)
            }

            if (question.id_type_question == 7) //TYPE FILE
            {
                string row = Request.Form["file"];
                if (row != null)
                {
                    variant_file file = db.variant_file.First(p => p.question_id == question.id);
                    file.max_size_file = Convert.ToInt32(row);
                    db.variant_file.AddOrUpdate(file);
                    db.SaveChanges();
                }
            }

            return(View(question));
        }
        public ActionResult AddQuestion(int type_q, int form_id)
        {
            question q = new question();                                                                                                                       //Создание нового вопроса

            q.id               = (db.question.Count() > 0) ? (db.question.Max(p => p.id) + 1) : 1;                                                             //идентификатор для нового вопроса
            q.id_form          = form_id;                                                                                                                      //для какой формы создается вопрос
            q.id_type_question = type_q;                                                                                                                       //тип вопроса
            q.number           = Convert.ToInt32(Request.Form["number_ask"]);                                                                                  //номер вопроса в форме
            q.name             = Request.Unvalidated.Form["text_quest"];                                                                                       //вопрос
            q.video_url        = Request.Form["video"];                                                                                                        //ссылка на видео (если есть)
            q.is_required      = (Convert.ToInt32(Request.Form["is_required"]) == 1) ? true : false;                                                           //обязательно или нет отвечать на вопрос
            var f = Request.Files["file"];                                                                                                                     //прикреплен ли файл (картинка)

            if (f != null && f.ContentLength > 0)                                                                                                              //если файл прикреплен и он не пустой
            {
                string newName  = String.Format("File_{0}_{1}{2}", DateTime.Now.ToString("yyyyMMddHHmmssfff"), Guid.NewGuid(), Path.GetExtension(f.FileName)); //изменение имени файла
                var    fileName = Path.GetFileName(f.FileName);
                var    path     = Path.Combine(Server.MapPath("~/Content/quest_file/"), newName);                                                              //путь для сохранения файла с новым именем
                f.SaveAs(path);                                                                                                                                //сохранение файла
                q.img_url = "/Content/quest_file/" + newName;                                                                                                  //относительный путь к файлу
            }
            q.comment = Request.Unvalidated.Form["comment"];                                                                                                   //комментарий к вопросу
            db.question.Add(q);                                                                                                                                //добавление вопроса в бд
            db.SaveChanges();                                                                                                                                  //сохранение
            if (type_q == 2 || type_q == 3 || type_q == 4)                                                                                                     //если тип вопроса от 2 до 4
            {
                string         result     = Request.Unvalidated.Form["variant"];                                                                               //список вариантов для ответа в одной строке через запятую
                String[]       variant    = result.Split(',');                                                                                                 //преобразуем из строки в массив вариантов ответов
                List <variant> list_q     = new List <variant>();                                                                                              //для хранения вариантов ответа в экземплярах класса variant, для дальнейшего сохранения в бд
                int            id_variant = (db.variant.Count() > 0) ? (db.variant.Max(p => p.id) + 1) : 1;                                                    //идентификатор варианта
                for (int i = 0; i < variant.Count(); ++i)                                                                                                      //перебор вариантов ответов из массива
                {
                    if (!variant[i].Equals(""))                                                                                                                //если вариант не пустой
                    {
                        variant quest = new variant();                                                                                                         //создание нового экземпляра класса variant
                        quest.id          = id_variant++;                                                                                                      //уникальный идентификатор
                        quest.name        = variant[i].Replace("&#044", ",").Trim();;                                                                          //вариант (текст)
                        quest.number      = i + 1;                                                                                                             //номер варианта
                        quest.id_question = q.id;                                                                                                              //идентификатор вопроса, одним из возможных ответов которого может быть данный вариант
                        list_q.Add(quest);                                                                                                                     //добавление созданного и проинициализированного варианта в список
                    }
                }
                db.variant.AddRange(list_q);                                                                         //добавления всех вариантов списка в бд
                db.SaveChanges();                                                                                    //сохранение
                string else_v = Request.Unvalidated.Form["else"];                                                    //вариант "другое"
                if (else_v != null)                                                                                  //если добавлен вариант "другой"
                {
                    question_else q_else = new question_else();                                                      //создание экземпляра класса question_else
                    q_else.id          = (db.question_else.Count() > 0) ? (db.question_else.Max(p => p.id) + 1) : 1; //идентификатор
                    q_else.id_question = q.id;                                                                       //идентификатор вопроса, у коготого будет в вариантах ответа поле "другое"
                    q_else.name        = else_v.Trim();                                                              //название для поля "другое"
                    db.question_else.Add(q_else);                                                                    //добавление в бд
                    db.SaveChanges();                                                                                //сохранение
                }
            }
            else if (type_q == 5 || type_q == 6)                       //если тип вопроса 5 или 6
            {
                string   row  = Request.Unvalidated.Form["table_row"]; //список вопросов в виде строки через запятую
                string[] rows = row.Split(',');                        //список вопросов в виде массива
                string   col  = Request.Unvalidated.Form["table_col"]; //список вариантов ответов через запятую
                string[] cols = col.Split(',');                        //список вариантов ответов в виде массива
                List <table_question> list_rows = new List <table_question>();
                int id = (db.table_question.Count() > 0) ? (db.table_question.Max(p => p.id) + 1) : 1;
                for (int i = 0; i < rows.Count(); ++i)
                {
                    table_question t_q = new table_question();
                    t_q.id          = id++;
                    t_q.id_question = q.id;
                    t_q.number      = i + 1;
                    t_q.name        = rows[i].Replace("&#044", ",").Trim();
                    list_rows.Add(t_q);
                }
                List <table_variant> list_cols = new List <table_variant>();
                id = (db.table_variant.Count() > 0) ? (db.table_variant.Max(p => p.id) + 1) : 1;
                for (int i = 0; i < cols.Count(); ++i)
                {
                    table_variant t_v = new table_variant();
                    t_v.id          = id++;
                    t_v.id_question = q.id;
                    t_v.number      = i + 1;
                    t_v.name        = cols[i].Replace("&#044", ",").Trim();
                    list_cols.Add(t_v);
                }
                db.table_question.AddRange(list_rows);
                db.table_variant.AddRange(list_cols);
                db.SaveChanges();
            }
            else if (type_q == 7) //если тип вопроса = 7
            {
                string row = Request.Form["file"];
                if (row != null)
                {
                    variant_file file = new variant_file();
                    file.id            = (db.variant_file.Count() > 0) ? (db.variant_file.Max(p => p.id) + 1) : 1;
                    file.question_id   = q.id;
                    file.max_size_file = Convert.ToInt32(row);
                    db.variant_file.Add(file);
                    db.SaveChanges();
                }
            }
            return(Redirect("/forms/details?id=" + form_id + "#addask"));
        }
Exemple #38
0
        private void simpleButtonSaveQuestion_Click(object sender, EventArgs e)
        {
            //if (BackgroundWorker != null)
            //    BackgroundWorker.StartWork("Saving Question");
            Cursor currentCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            int rowcount = 0;

            DataTable dt = gridControlQuestions.DataSource as DataTable;
            rowcount = dt.Rows.Count;
            if (!IsSaved) {
                m_oQuestion = new question();
                m_oQuestion.created_by_user_id = UserSession.CurrentUser.UserId;
            } else {
                if (m_oQuestion == null) {
                    m_oQuestion = BPContext.questions.Include("questions_text_language").FirstOrDefault(p => p.id == QuestionID);
                }
            }

            m_oQuestion.modified_by = UserSession.CurrentUser.UserId;
            m_oQuestion.modified_date = DateTime.Now;
            if (comboBoxEditQuestionGeneralValue.EditValue != null && !string.IsNullOrEmpty(comboBoxEditQuestionGeneralValue.EditValue.ToString()))
                m_oQuestion.general_value = Convert.ToByte(comboBoxEditQuestionGeneralValue.EditValue);

            DataRowView rowView = null;
            questions_text_language qtextlang;
            int question_id, question_text_language_id;
            bool exists = false;

            if (gridViewQuestion.RowCount > 0) {
                for (int x = 0; x < rowcount; ++x) {
                    rowView = (DataRowView)gridViewQuestion.GetRow(x);
                    if (rowView == null)
                        continue;

                    if (int.TryParse(rowView.Row["question_id"].ToString(), out question_id) &&
                       int.TryParse(rowView.Row["question_text_language_id"].ToString(), out question_text_language_id)) {
                        qtextlang = m_oQuestion.questions_text_language.FirstOrDefault(p => p.questions_id == question_id && p.id == question_text_language_id);
                        exists = true;
                    } else {
                        qtextlang = new questions_text_language();
                        exists = false;
                    }
                    qtextlang.question_text = rowView.Row["question"].ToString();
                    qtextlang.question_description = rowView.Row["description"].ToString();
                    qtextlang.question_help_text = rowView.Row["helptext"].ToString();
                    qtextlang.language_id = Convert.ToInt32(rowView.Row["language_id"]);
                    if (!exists) {
                        m_oQuestion.questions_text_language.Add(qtextlang);
                    }
                }
            } else {
                BPContext.FIDeleteQuestion(string.Join(",", dataRowIds.ToArray()));
                if (this.ParentForm != null) {
                    this.ParentForm.DialogResult = DialogResult.OK;
                }
                return;
            }
            //clean up non existent questions in the collection
            //m_oQuestion.questions_text_language.ToList().ForEach(delegate(questions_text_language qtl) {
            //    if (dataRowIds.Contains(qtl.id)) {
            //        BPContext.questions_text_language.DeleteObject(qtl);
            //    }
            //});
            BPContext.FIDeleteQuestion(string.Join(",", dataRowIds.ToArray()));
            dataRowIds.Clear();
            m_oQuestion.questions_questiontags.ToList().ForEach(delegate(questions_questiontags _qqt)
            {
                    BPContext.questions_questiontags.DeleteObject(_qqt);
            });
            //var listqqts = m_oQuestion.questions_questiontags.ToList().Clone();
            //List<int> listQQTIds = new List<int>();
            questions_questiontags mQQT = null;
            if (dictionarySelectedTags != null) {
                foreach (KeyValuePair<string, int> kvp in dictionarySelectedTags) {
                    //mQQT = listqqts.FirstOrDefault(p => p.questiontags_id == kvp.Value);
                    //if (mQQT == null) {
                        m_oQuestion.questions_questiontags.Add(new questions_questiontags() { questiontags_id = kvp.Value });
                    //}
                    //listQQTIds.Add(kvp.Value);
                }
                //m_oQuestion.questions_questiontags.ToList().ForEach(delegate(questions_questiontags _qqt) {
                //    if (!listQQTIds.Contains(_qqt.questiontags_id))
                //        BPContext.questions_questiontags.DeleteObject(_qqt);
                //});
            }
            if (!IsSaved) {
                BPContext.questions.AddObject(m_oQuestion);
                IsSaved = true;
            }
            BPContext.SaveChanges();
            //ParentControl.QuestionId = m_oQuestion.id;
            dt.Rows.Clear();
            DataRow dr = null;
            m_oQuestion.questions_text_language.ForEach(delegate(questions_text_language dqtl) {
                dr = dt.NewRow();
                dr["question_id"] = dqtl.questions_id;
                dr["question_text_language_id"] = dqtl.id;
                dr["language_id"] = dqtl.language_id;
                dr["question"] = dqtl.question_text;
                dr["description"] = dqtl.question_description;
                dr["helptext"] = dqtl.question_help_text;
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();

            if (QuestionID <= 0)
                QuestionID = m_oQuestion.id;

            groupControlAnswerForm.Enabled = true;
            simpleButtonSaveQuestion.Enabled = true;
            if (gridViewAnswerForm.RowCount > 0) {
                if(eSaveMode != SaveMode.Edit)
                    btnEditAnswerform.Enabled = true;
                btnDeleteAnswerform.Enabled = true;
            } else {
                btnEditAnswerform.Enabled = false;
                btnDeleteAnswerform.Enabled = false;
            }
            Cursor.Current = currentCursor;
            //if (sender != null && sender.ToString() != "skip")
            //    MessageBox.Show("Questions has been saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //if (BackgroundWorker != null) BackgroundWorker.StopWork();
        }
        private void ExecuteSaveQuestionCommand()
        {
            if (!DoesQuestionAlreadyExist(NewQuestion))
            {
                String locationOfQrCodeImage = myFileDirectory + "QRCodes\\" + this.CurrentTreasureHunt.HuntId + " " + this.newQuestion + ".png";

                question brandNewQuestion = new question();
                brandNewQuestion.Question1 = this.newQuestion;
                brandNewQuestion.URL = locationOfQrCodeImage;
                long questionId = this.serviceClient.SaveQuestion(brandNewQuestion);

                SaveHuntQuestion(questionId);
                EncodeQRCode(locationOfQrCodeImage);

                this.NewQuestion = String.Empty;
            }
            else 
            {
                String messageBoxText = "This question already exists.";
                String caption = "Question Already Exists";
                MessageBoxResult box = MessageBox.Show(messageBoxText, caption);
                NewQuestion = String.Empty;
            }
        }
 public userinfo setFounderuserinfo(question obj)
 {
     return UserinfoRY.GetuserinfoSmall(obj.siteid, obj.userid);
 }
Exemple #41
0
 public ActionResult EditQuestion(question item)
 {
     quesrepo.UpdateByObject(item);
     return(RedirectToAction("ViewQuestions", new { course_id = item.course_id, course_name = Request.QueryString["course_name"] }));
 }