/// <summary>
        /// Save text question
        /// </summary>
        private void SaveQuestionText()
        {
            //儲存題目
            clsTextQuestion myText          = new clsTextQuestion();
            string          strQTextContent = txtQuestionData.Text;
            string          strATextContent = txtAnswerData.Text;

            strQTextContent = strQTextContent.Replace("&lt;", "<");
            strQTextContent = strQTextContent.Replace("&gt;", ">");
            strATextContent = strATextContent.Replace("&lt;", "<");
            strATextContent = strATextContent.Replace("&gt;", ">");

            myText.saveTextQuestion(strQID, strQTextContent, strATextContent, strUserID, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value);

            //儲存問題難易度
            int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(ddlQuestionLevel.SelectedValue);

            AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQID, iQuestionLevel);

            //儲存問題的病徵
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, ddlSymptoms.SelectedValue);

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                DataReceiver myReceiver    = new DataReceiver();
                int          intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString    mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }
        }
Пример #2
0
        /// <summary>
        /// Save text question
        /// </summary>
        private void SaveQuestionText()
        {
            //儲存題目
            clsTextQuestion myText          = new clsTextQuestion();
            string          strQTextContent = txtQuestionData.Text; //get the question description from question textarea
            string          strATextContent = txtAnswerData.Text;   //get the correct answer from answer textarea

            strQTextContent = strQTextContent.Replace("&lt;", "<");
            strQTextContent = strQTextContent.Replace("&gt;", ">");
            strATextContent = strATextContent.Replace("&lt;", "<");
            strATextContent = strATextContent.Replace("&gt;", ">");

            ////use JS alert() in C#
            ScriptManager.RegisterStartupScript(
                this,
                typeof(Page),
                "Alert",
                "<script>alert('aa: " + strATextContent + "');</script>",
                false);
            ///////


            //store the question description and correct answer to the question to DB.
            myText.saveQuestionAnswer(strQID, strAID, strQTextContent, strATextContent, strUserID, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value);

            //儲存問題難易度
            int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(ddlQuestionLevel.SelectedValue);

            AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQID, iQuestionLevel);

            //儲存問題的病徵
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, ddlSymptoms.SelectedValue);

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                DataReceiver myReceiver    = new DataReceiver();
                int          intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString    mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }

            //若從編輯考卷來,直接將問題新增至考卷裡 蕭凱 2014/3/25
            if (Session["IsFromClassExercise"] != null && Session["IsFromClassExercise"].ToString() == "True")
            {
                DataReceiver myReceiver = new DataReceiver();
                SQLString    mySQL      = new SQLString();
                //取得考卷題數
                string strSeq = Convert.ToString(myReceiver.getPaperContentMaxSeq(strPaperID) + 1);
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", "General", strSeq);
            }
        }
        private void btnSaveNextQuestion_ServerClick(object sender, EventArgs e)
        {
            DataReceiver myReceiver = new DataReceiver();

            //儲存題目
            clsTextQuestion myText          = new clsTextQuestion();
            string          strTextQContent = txtQuestionData.Text;
            string          strTextAContent = txtAnswerData.Text;

            strTextQContent = strTextQContent.Replace("&lt;", "<");
            strTextQContent = strTextQContent.Replace("&gt;", ">");
            strTextAContent = strTextAContent.Replace("&lt;", "<");
            strTextAContent = strTextAContent.Replace("&gt;", ">");
            myText.saveTextQuestion(strQID, strTextQContent, strTextAContent, strUserID, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value);

            //儲存問題難易度
            int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(ddlQuestionLevel.SelectedValue);

            AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQID, iQuestionLevel);

            //儲存問題的病徵
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, ddlSymptoms.SelectedValue);

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                int       intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }

            //Redirect至此網頁
            //Response.Redirect("Paper_TextQuestionEditor.aspx?Opener=" + hiddenOpener.Value);

            //建立QID
            strQID = strUserID + "_" + myReceiver.getNowTime();

            //清除TextArea
            txtQuestionData.Text = "";
            txtAnswerData.Text   = "";
            string strScript = "<script language='javascript'>\n";

            strScript += "Clear()\n";
            strScript += "</script>\n";
            Page.RegisterStartupScript("Clear", strScript);

            hrQuestion.Style.Add("display", "none");
            hrAnswer.Style.Add("display", "none");
            BulidInterrogation("Question");
            BulidInterrogation("Answer");
        }
        /// <summary>
        /// Save text question
        /// </summary>
        private void SaveQuestionText()
        {
            //儲存題目
            clsTextQuestion myText          = new clsTextQuestion();
            string          strQTextContent = txtQuestionEdit.Text;

            strQTextContent = strQTextContent.Replace("&lt;", "<");
            strQTextContent = strQTextContent.Replace("&gt;", ">");

            clsConversation.saveConversation_Question(strQID, strQTextContent, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value);

            if (Request.QueryString["OpenGroupID"] != null) // 若從Search頁面開啟,儲存時要額外Insert一筆資料到QuestionMode,表示在OpenGroupID中也要有這類題目  老詹 2015/09/06
            {
                clsHintsDB sqldb = new clsHintsDB();
                string     strGetOpenGroupName = "SELECT cNodeName FROM QuestionGroupTree WHERE cNodeID='" + Request.QueryString["OpenGroupID"].ToString() + "'";
                DataTable  dtGetOpenGroupName  = sqldb.getDataSet(strGetOpenGroupName).Tables[0];
                if (dtGetOpenGroupName.Rows.Count > 0)
                {
                    string    strCheckRepeat = "SELECT * FROM QuestionMode WHERE cQID='" + strQID + "' AND cQuestionGroupID = '" + Request.QueryString["OpenGroupID"].ToString() + "'";
                    DataTable dtCheckRepeat  = sqldb.getDataSet(strCheckRepeat).Tables[0];
                    if (dtCheckRepeat.Rows.Count <= 0)
                    {
                        string strInsertOtherGroupSQL = "INSERT INTO QuestionMode(cQID,cQuestionGroupID,cQuestionGroupName,cQuestionMode,cQuestionType) VALUES ('" + strQID + "','" + Request.QueryString["OpenGroupID"].ToString() + "','" + dtGetOpenGroupName.Rows[0]["cNodeName"].ToString() + "','General','4')";
                        sqldb.ExecuteNonQuery(strInsertOtherGroupSQL);
                    }
                }
            }

            //儲存Problem Type
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, "All");

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                DataReceiver myReceiver    = new DataReceiver();
                int          intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString    mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }
        }
Пример #5
0
    protected void btnFinish_Click(object sender, EventArgs e)
    {
        if (strSenceID == "")
        {
            strSenceID = Session["SceneID"].ToString();
        }

        //判斷是否有設定VRversion
        if (strSenceID != "")
        {
            //朱君 2012/11/25 將使用者所選擇的特徵值存入暫存陣列中,並儲存於資料庫中。
            clsFeaturevalue clsSaveFeature = new clsFeaturevalue();
            clsSaveFeature.update_FeatureItemIntoDataBase(clsSaveFeature.get_dtFeatureItem_Data(strGroupID, this));

            //將情境題題目存入資料表中
            UpdateQuestion();

            Session["QuestionAccessorParameter"] = null;
            Session["QuestionAccessor"]          = null;
            Session["QuestionSelectionAccessor"] = null;

            //若從編輯考卷來,直接將問題新增至考卷裡 蕭凱 2014/3/25
            if (hiddenPreOpener.Value == "SelectPaperMode")
            {
                DataReceiver myReceiver = new DataReceiver();
                SQLString    mySQL      = new SQLString();
                //取得考卷題數
                string strSeq = Convert.ToString(myReceiver.getPaperContentMaxSeq(strPaperID) + 1);
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "5", "General", strSeq);
            }

            //完成儲存
            FinishSave();
        }
        else
        {
            Response.Write("<script>window.alert('未決定題目VR場景')</script>");
        }
    }
        protected void btSaveNew_Click(object sender, EventArgs e)
        {
            //建立QID
            DataReceiver myReceiver = new DataReceiver();

            strQID = strUserID + "_" + myReceiver.getNowTime();

            //儲存題目
            clsTextQuestion myText          = new clsTextQuestion();
            string          strQTextContent = txtQuestionData.Text;
            string          strATextContent = txtAnswerData.Text;

            strQTextContent = strQTextContent.Replace("&lt;", "<");
            strQTextContent = strQTextContent.Replace("&gt;", ">");
            strATextContent = strATextContent.Replace("&lt;", "<");
            strATextContent = strATextContent.Replace("&gt;", ">");

            myText.saveTextQuestion(strQID, strQTextContent, strATextContent, strUserID, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value);

            //儲存問題難易度
            int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(ddlQuestionLevel.SelectedValue);

            AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQID, iQuestionLevel);

            //儲存問題的病徵
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, ddlSymptoms.SelectedValue);

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                int       intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }

            //Redirect至下一個網頁
            string strSystemFunction = "";

            if (Session["SystemFunction"] != null)
            {
                strSystemFunction = Session["SystemFunction"].ToString();
            }

            switch (strSystemFunction)
            {
            case "EditPaper":
                Response.Redirect("Paper_OtherQuestion.aspx?Opener=Paper_TextQuestionEditor");
                break;

            case "EditQuestion":
                if (Request.QueryString["QID"] != null)
                {
                    Response.Redirect("Paper_QuestionView.aspx?Opener=Paper_TextQuestionEditor");
                }
                else
                {
                    Response.Redirect("Paper_QuestionMain.aspx?Opener=Paper_TextQuestionEditor");
                }
                break;

            case "PreviewPaper":
                Response.Redirect("Paper_MainPage.aspx?Opener=Paper_TextQuestionEditor");
                break;

            default:
                Response.Redirect("Paper_QuestionMain.aspx?Opener=Paper_TextQuestionEditor");
                break;
            }
        }
        protected void btSaveNew_Click(object sender, EventArgs e)
        {
            string strQuestion      = "";
            string strSelection     = "";
            string strResponse      = "";
            int    strCorrectAnswer = 0;

            string[] strQuestionID = null;
            string   strNewQID     = CommonQuestionUtility.GetNewID(this.UserID, "Question");
            string   strNewSID     = CommonQuestionUtility.GetNewID(this.UserID, "Selection");
            string   strSID        = "";
            string   strRID        = "";
            string   strCID        = "";

            for (int i = 0; i < Request.Form.Count; i++)
            {
                if (Request.Form.Keys[i].ToString().IndexOf("QuestionTextBox@" + strQID) != -1)
                {
                    strQuestion = Request.Form[i].ToString();
                    this.qAccessor.QuestionIndex_INSERT(strNewQID, strQuestion);
                    //儲存一筆資料至QuestionMode
                    SQLString mySQL = new SQLString();
                    mySQL.saveIntoQuestionMode(strNewQID, "", "", strGroupID, "General", "1");
                }
                if (Request.Form.Keys[i].ToString().IndexOf("editLevelDdl@" + strQID) != -1)
                {
                    string strQuestionLevel = Request.Form[i].ToString();
                    int    iQuestionLevel   = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(strQuestionLevel);
                    AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strNewQID, iQuestionLevel);
                }
                if (Request.Form.Keys[i].ToString().IndexOf("editGradeTensDdl@" + strQID) != -1)
                {
                    string strQuestionGradeTens  = Request.Form[i].ToString();
                    string strQuestionGradeUnits = Request.Form[i + 1].ToString();

                    AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionGrade_INSERT(strNewQID, strQuestionGradeTens + strQuestionGradeUnits);
                }
                DataTable dtQuestionSelectionIndex = Hints.Learning.Question.SQLString.getSelectionListFromQuestionSelectionIndexByQID(strQID);
                int       iSCount = 0;
                foreach (DataRow drQuestionSelectionIndex in dtQuestionSelectionIndex.Rows)
                {
                    if (Request.Form.Keys[i].ToString().IndexOf("SelectionTextBox@" + drQuestionSelectionIndex["cSelectionID"].ToString()) != -1)
                    {
                        strSelection = Request.Form[i].ToString();
                        strSID       = drQuestionSelectionIndex["cSelectionID"].ToString();
                    }
                    if (Request.Form.Keys[i].ToString().IndexOf("SelectionResponseTextBox@" + drQuestionSelectionIndex["cSelectionID"].ToString()) != -1)
                    {
                        strResponse = Request.Form[i].ToString();
                        strRID      = drQuestionSelectionIndex["cSelectionID"].ToString();
                    }
                    strCorrectAnswer = 0;
                    if (Request.Form.Keys[i].ToString().IndexOf("IsCorrectChkBox@" + strQID + "#" + drQuestionSelectionIndex["cSelectionID"].ToString()) != -1)
                    {
                        strCorrectAnswer = 1;
                        strCID           = drQuestionSelectionIndex["cSelectionID"].ToString();
                    }
                    else
                    {
                        strCID = drQuestionSelectionIndex["cSelectionID"].ToString();
                    }

                    if (strSID != "" && strRID != "" && strCID != "")
                    {
                        if ((strSID == strRID) && (strSID == strCID) && (strCID == strRID))
                        {
                            iSCount = DataReceiver.QuestionSelectionIndex_SELECT_Seq(strQID, drQuestionSelectionIndex["cSelectionID"].ToString());
                            this.qAccessor.QuestionSelectionIndex_INSERT(strNewQID, strNewSID + "_" + iSCount, iSCount, strSelection, strResponse, strCorrectAnswer);
                        }
                    }
                    //朱君 2012/11/25 將使用者所選擇的特徵值存入暫存陣列中,並儲存於資料庫中。
                    // this.qAccessor.update_FeatureItemIntoDataBase(strQID, get_dtFeatureItem_Data(strGroupID));
                }
            }
            //若從編輯考卷來,直接將問題新增至考卷裡 蕭凱 2014/3/25
            if (hiddenPreOpener.Value == "SelectPaperMode")
            {
                DataReceiver myReceiver = new DataReceiver();
                SQLString    mySQL      = new SQLString();
                //取得考卷題數
                string strSeq = Convert.ToString(myReceiver.getPaperContentMaxSeq(strPaperID) + 1);
                mySQL.SaveToQuestionContent(strPaperID, strNewQID, "0", "1", "General", strSeq);
            }
            FinishSave();
        }
        private void finishBtn_Click(object sender, ImageClickEventArgs e)
        {
            //朱君 2012/11/25 將使用者所選擇的特徵值存入暫存陣列中,並儲存於資料庫中。
            clsFeaturevalue clsSaveFeature = new clsFeaturevalue();

            clsSaveFeature.update_FeatureItemIntoDataBase(clsSaveFeature.get_dtFeatureItem_Data(strGroupID, this));
            this.qAccessor.update_DataTableIntoDatabase();  //與問題有關的問題資料存入資料庫
            this.qsAccessor.update_DataTableIntoDatabase(); //與問題選項有關的問題選項資料存入資料庫
            if (this.Question_Edit_Type != "Choice_Question")
            {
                this.qAccessor.update_QuestionSource_In_Database();//將此問題有關的應用領域資料存入相關資料表
            }

            //檢查內容是否為空
            clsHintsDB hintsDB   = new clsHintsDB();
            string     strScript = "";
            string     strSQL    = "";

            strSQL = "SELECT [cQuestion] FROM [NewVersionHintsDB].[dbo].[QuestionIndex] where cQID = '" + strAddNewQID + "'";
            string strQuestionContent = hintsDB.getDataSet(strSQL).Tables[0].Rows[0]["cQuestion"].ToString();

            if (strQuestionContent.Equals(""))
            {
                strScript += "題目內容未填寫";
            }

            strSQL = "SELECT cSelection , bCaseSelect FROM [NewVersionHintsDB].[dbo].[QuestionSelectionIndex] where cQID='" + strAddNewQID + "'";
            DataTable dtQuestionSelection  = hintsDB.getDataSet(strSQL).Tables[0];
            bool      isSelectionNull      = false;
            bool      isSelectionCheckNull = true;

            foreach (DataRow drSelection in dtQuestionSelection.Rows)
            {
                if (drSelection["cSelection"].ToString().Trim().Equals(""))
                {
                    isSelectionNull = true;
                }
                string s = drSelection["bCaseSelect"].ToString();
                if (drSelection["bCaseSelect"].ToString().Equals("True"))
                {
                    isSelectionCheckNull = false;
                }
            }
            if (isSelectionNull)
            {
                if (!strScript.Equals(""))
                {
                    strScript += ",";
                }
                strScript += "選擇題選項內容未填寫";
            }
            if (isSelectionCheckNull)
            {
                if (!strScript.Equals(""))
                {
                    strScript += ",";
                }
                strScript += "選擇題選項答案未選";
            }
            if (!strScript.Equals(""))
            {
                strSQL = "DELETE FROM [NewVersionHintsDB].[dbo].[QuestionIndex] WHERE cQID = '" + strAddNewQID + "'";
                hintsDB.ExecuteNonQuery(strSQL);
                strSQL = "DELETE FROM [NewVersionHintsDB].[dbo].[QuestionSelectionIndex] WHERE cQID = '" + strAddNewQID + "'";
                hintsDB.ExecuteNonQuery(strSQL);
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Refresh", "alert('" + strScript + ",請填寫完整再存檔')", true);
                return;
            }


            Session["QuestionAccessorParameter"] = null;
            Session["QuestionAccessor"]          = null;
            Session["QuestionSelectionAccessor"] = null;
            //若從編輯考卷來,直接將問題新增至考卷裡
            if (Session["IsFromClassExercise"] != null && Session["IsFromClassExercise"].ToString().Equals("True"))
            {
                DataReceiver myReceiver = new DataReceiver();
                SQLString    mySQL      = new SQLString();
                //取得考卷題數
                string strSeq = Convert.ToString(myReceiver.getPaperContentMaxSeq(strPaperID) + 1);
                mySQL.SaveToQuestionContent(strPaperID, strAddNewQID, "0", "6", "General", strSeq);
            }
            FinishSave();

            //移除Session
            Session.Remove("PreOpener");

            bool bIsZero = true;//用來判斷使用者是否有設定分數

            for (int i = 0; i < Request.Form.Count; i++)
            {
                if (Request.Form.Keys[i].ToString().IndexOf("editLevelDdl@") != -1)
                {
                    string   strQuestionLevel = Request.Form[i].ToString();
                    string[] strQuestionID    = Request.Form.Keys[i].ToString().Split('@');
                    int      iQuestionLevel   = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(strQuestionLevel);
                    AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQuestionID[1], iQuestionLevel);
                }

                if (Request.Form.Keys[i].ToString().IndexOf("editGradeTensDdl@") != -1)
                {
                    string   strQuestionGradeTens  = Request.Form[i].ToString();
                    string   strQuestionGradeUnits = Request.Form[i + 1].ToString();
                    string[] strQuestionID         = Request.Form.Keys[i].ToString().Split('@');
                    AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionGrade_INSERT(strQuestionID[1], strQuestionGradeTens + strQuestionGradeUnits);

                    if (strQuestionGradeUnits != "0" || strQuestionGradeTens != "0")
                    {
                        bIsZero = false;
                    }
                }
            }

            //如果使用者都無設定分數 系統自己以題數去算每題平均
            if (bIsZero)
            {
                string strQuestionGradeTens  = "";
                string strQuestionGradeUnits = "";
                int    iQuestionCount        = 0;
                if (Session["GroupID"] != null)
                {
                    DataTable dtQuestionLevelNum = PaperSystem.DataReceiver.GetQuestionLevelNum(Session["GroupID"].ToString());
                    if (dtQuestionLevelNum.Rows.Count > 0)
                    {
                        iQuestionCount = Convert.ToInt32(dtQuestionLevelNum.Rows[0]["QuestionLevelNum"].ToString());
                    }
                }
                else
                {
                    iQuestionCount = qAccessor.QuestionIndex.Rows.Count;
                }


                for (int i = 0; i < Request.Form.Count; i++)
                {
                    if (Request.Form.Keys[i].ToString().IndexOf("editGradeTensDdl@") != -1)
                    {
                        string[] strQuestionID = Request.Form.Keys[i].ToString().Split('@');
                        AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionGrade_INSERT(strQuestionID[1], strQuestionGradeTens + strQuestionGradeUnits);
                    }
                }
            }
        }
        protected void btSaveNew_Click(object sender, EventArgs e)
        {
            //建立QID
            DataReceiver myReceiver = new DataReceiver();

            strQID = strUserID + "_Q_" + myReceiver.getNowTime();
            System.Threading.Thread.Sleep(1000);
            strAID = strUserID + "_A_" + myReceiver.getNowTime();

            //儲存題目
            clsProgramQuestion myText          = new clsProgramQuestion();
            string             strQTextContent = txtQuestionData.Text;
            string             strATextContent = txtAnswerData.Text;

            strQTextContent = strQTextContent.Replace("&lt;", "<");
            strQTextContent = strQTextContent.Replace("&gt;", ">");
            strATextContent = strATextContent.Replace("&lt;", "<");
            strATextContent = strATextContent.Replace("&gt;", ">");

            myText.saveQuestionAnswer(strQID, strAID, strQTextContent, strATextContent, strUserID, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value);

            //儲存問題難易度
            int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(ddlQuestionLevel.SelectedValue);

            AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQID, iQuestionLevel);

            //儲存問題的病徵
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, ddlSymptoms.SelectedValue);

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                int       intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }

            //若從編輯考卷來,直接將問題新增至考卷裡 蕭凱 2014/3/25
            if (hiddenPreOpener.Value == "SelectPaperMode" && hiddenQuestionMode.Value != "Specific")
            {
                SQLString mySQL = new SQLString();
                //取得考卷題數
                string strSeq = Convert.ToString(myReceiver.getPaperContentMaxSeq(strPaperID) + 1);
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", "General", strSeq);
                Session.Remove("PreOpener");
            }

            //Redirect至下一個網頁
            string strSystemFunction = "";

            if (Session["SystemFunction"] != null)
            {
                strSystemFunction = Session["SystemFunction"].ToString();
            }

            switch (strSystemFunction)
            {
            case "EditPaper":
                Response.Redirect("Paper_OtherQuestion.aspx?Opener=Paper_TextQuestionEditor");
                break;

            case "EditQuestion":
                if (Request.QueryString["QID"] != null)
                {
                    Response.Redirect("Paper_QuestionViewNew.aspx?Opener=Paper_TextQuestionEditor");
                }
                else
                {
                    Response.Redirect("Paper_QuestionMain.aspx?Opener=Paper_TextQuestionEditor");
                }
                break;

            case "PreviewPaper":
                if (hiddenPreOpener.Value == "SelectPaperMode")
                {
                    Response.Redirect("Paper_MainPage.aspx?Opener=SelectPaperMode&cCaseID=" + strCaseID + "&cSectionName=" + strSectionName + "&cPaperID=" + strPaperID);
                }
                else
                {
                    Response.Redirect("Paper_MainPage.aspx?Opener=Paper_TextQuestionEditor");
                }
                break;

            default:
                Response.Redirect("Paper_QuestionMain.aspx?Opener=Paper_TextQuestionEditor");
                break;
            }
        }
        /// <summary>
        /// Save text question
        /// </summary>
        //Save Question , Answer Edit to DB Ben2017
        private void SaveQuestionText()
        {
            //儲存題目
            clsProgramQuestion myText                     = new clsProgramQuestion();
            string             strQTextContent            = txtQuestionData.Text;
            string             strATextContent            = txtAnswerData.Text;
            string             strTextTestDataContent     = txtTestData.Text;           //get test data from textarea
            string             strTextOutputFormatContent = txtOutputFormatExData.Text; //get output format from textarea



            strQTextContent            = strQTextContent.Replace("&lt;", "<");
            strQTextContent            = strQTextContent.Replace("&gt;", ">");
            strATextContent            = strATextContent.Replace("&lt;", "<");
            strATextContent            = strATextContent.Replace("&gt;", ">");
            strTextTestDataContent     = strTextTestDataContent.Replace("&lt;", "<");
            strTextTestDataContent     = strTextTestDataContent.Replace("&gt;", ">");
            strTextOutputFormatContent = strTextOutputFormatContent.Replace("&lt;", "<");
            strTextTestDataContent     = strTextOutputFormatContent.Replace("&gt;", ">");


            /*
             * //#######use JS alert() in C#
             * ScriptManager.RegisterStartupScript(
             * this,
             * typeof(Page),
             * "Alert",
             * "<script>alert('strTextOutputFormatContent: " + strATextContent + "');</script>",
             * false);
             * ///////
             */

            //#######you can now store
            //#####strTextQContent,strTextAContent,strTextTestDataContent,strTextOutputFormatContent
            //#######to DB by passing them to function "saveProgramQuestionAnswer" below, and modify that function
            //#######to meet your need.

            //#######Also,you have to keep the  format of  strATextContent,strTextTestDataContent,and strTextTestDataContent,
            //#######which matters when comparing the result of the program execution.
            myText.saveProgramQuestionAnswer(strQID, strAID, strQTextContent, strATextContent, strUserID, strPaperID, strGroupDivisionID, strGroupID, hiddenQuestionMode.Value, strTextTestDataContent, strTextOutputFormatContent);

            //儲存問題難易度
            int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(ddlQuestionLevel.SelectedValue);

            AuthoringTool.QuestionEditLevel.QuestionLevel.INSERT_QuestionLevel(strQID, iQuestionLevel);

            //儲存問題的病徵
            AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_INSERT_QuestionSymptoms(strQID, ddlSymptoms.SelectedValue);

            //如果是Specific題目則需儲存一筆資料至Paper_Content
            if (hiddenQuestionMode.Value == "Specific")
            {
                DataReceiver myReceiver    = new DataReceiver();
                int          intContentSeq = myReceiver.getPaperContentMaxSeq(strPaperID) + 1;
                SQLString    mySQL         = new SQLString();
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", hiddenQuestionMode.Value, intContentSeq.ToString());
            }

            //若從編輯考卷來,直接將問題新增至考卷裡 蕭凱 2014/3/25
            if (Session["IsFromClassExercise"] != null && Session["IsFromClassExercise"].ToString() == "True")
            {
                DataReceiver myReceiver = new DataReceiver();
                SQLString    mySQL      = new SQLString();
                //取得考卷題數
                string strSeq = Convert.ToString(myReceiver.getPaperContentMaxSeq(strPaperID) + 1);
                mySQL.SaveToQuestionContent(strPaperID, strQID, "0", "2", "General", strSeq);
            }
        }