// /// <summary> // /// 修改文字處理方塊的事件 // /// </summary> // private void tb_TextChanged(object sender, EventArgs e) // { // string tmpQID = ((TextBox)sender).ID.Split('@')[1];//取得問題ID // TextBox tb = (TextBox)this.FindControl("Form1").FindControl("QuestionTextBox@" + tmpQID); // ((QuestionAccessor)this.Page.Session["QuestionAccessor"]).modifyQuestionText(tmpQID,tb.Text); // } private Table getScriptCategorySelectionSelection() { Label scriptSelectionLabel = new Label(); scriptSelectionLabel.Text = "<b>Please select a script category.</b> "; DropDownList ddl = new DropDownList(); ddl.ID = "ScriptCategorySelection@" + this.strQID; ddl.AutoPostBack = true; ddl.SelectedIndexChanged += new EventHandler(ret_SelectedIndexChanged); DataTable dt = ((QuestionAccessor)this.Page.Session["QuestionAccessor"]).VocabularyCategoryIndex; ddl.Items.Add(new ListItem("Select a script category")); foreach (DataRow dr in dt.Rows) { ddl.Items.Add(new ListItem(dr["cVocabularyCategory"].ToString(), dr["cUsedUnitScriptID"].ToString())); } // DataRow[] drs = dt.Select("cUsedUnitScriptID = '"+dr["cUsedUnitScriptID"].ToString()+"'"); // foreach(DataRow dr in drs) // { // dr["IsSelect"] = "N"; // } Table container = CommonQuestionUtility.get_HTMLTable(1, 2); container.Rows[0].Cells[0].Controls.Add(scriptSelectionLabel); container.Rows[0].Cells[0].Controls.Add(ddl); return(container); }
/// <summary> /// 增加問題選項的事件 /// </summary> private void addSelection_Btn_Click(object sender, EventArgs e) { string new_SelectionID = CommonQuestionUtility.GetNewID(this.author_UserID, "Selection"); //新增的選項ID ((QuestionSelectionAccessor)this.Page.Session["QuestionSelectionAccessor"]).add_new_selection(this.strQID, new_SelectionID); addSelection(new_SelectionID); }
/// <summary> /// 建構本身的HTML Table /// </summary> /// <param name="QuestionItemDataTable"></param> private void constructQuestionItemTable() { if (this.Question_Edit_Type == "Script_Question") { this.Rows.Add(new TableRow()); this.Rows[this.Rows.Count - 1].Cells.Add(new TableCell()); this.Rows[this.Rows.Count - 1].Cells[0].Wrap = false; this.Rows[this.Rows.Count - 1].Cells[0].HorizontalAlign = HorizontalAlign.Center; this.Rows[this.Rows.Count - 1].Cells[0].Controls.Add(getScriptCategorySelectionSelection()); } this.Rows.Add(new TableRow()); this.Rows[this.Rows.Count - 1].Cells.Add(new TableCell()); this.Rows[this.Rows.Count - 1].Cells[0].Wrap = false; this.Rows[this.Rows.Count - 1].Cells[0].VerticalAlign = VerticalAlign.Middle; Table controlContainer = CommonQuestionUtility.get_HTMLTable(1, 3); controlContainer.BorderWidth = Unit.Pixel(2); controlContainer.BorderColor = Color.Purple; controlContainer.GridLines = GridLines.Both; controlContainer.Width = Unit.Parse("100%"); this.Rows[this.Rows.Count - 1].Cells[0].Controls.Add(controlContainer); //增加Button addQuestionLabel(0); addQuestionTextBox(1); addButtonControl(2); setTableStyle(); addSelections_SubQuestion(); //朱君 暫時拿掉LEVEL和分數功能 2013/1/2 //addQuestionLevel(); //addQuestionGrade(); }
private void add_Sub_Question_Btn_Click(object sender, EventArgs e) { string tmpQID = ((Table)this.Parent.Parent.Parent).ID.Split('@')[1]; //取得要選項所屬的問題的ID string new_Sub_QID = CommonQuestionUtility.GetNewID(this.author_UserID, "Question"); //選項所要新增的問題ID ((QuestionAccessor)this.Page.Session["QuestionAccessor"]).add_New_Sub_Question(tmpQID, strSelectionID, new_Sub_QID, this.intLevel + 1); add_sub_question(new_Sub_QID); addPlusImage(false); }
/// <summary> /// 若使用者有新增選項,會將新增的選項暫存在"new_Selection_DataRow"資料列中,等到下次網頁PostBack時在處理 /// </summary> /// <param name="QID">問題ID</param> /// <param name="new_selectionID">新增的選項ID</param> public void add_new_selection(string QID, string new_SelectionID) { DataRow new_Selection_DataRow = this.QuestionSelectionIndex.NewRow(); new_Selection_DataRow["cQID"] = QID; new_Selection_DataRow["cSelectionID"] = new_SelectionID; new_Selection_DataRow["sSeq"] = CommonQuestionUtility.GetMaxSequence(QID, QuestionSelectionIndex, qAccessor.QuestionLinkQID); new_Selection_DataRow["cSelection"] = ""; new_Selection_DataRow["bCaseSelect"] = false; QuestionSelectionIndex.Rows.Add(new_Selection_DataRow); }
/// <summary> /// 增加子問題的button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void add_SubQuestion_Btn_Click(object sender, EventArgs e) { string new_Sub_QID = CommonQuestionUtility.GetNewID(this.author_UserID, "Question"); //選項所要新增的問題ID ((QuestionAccessor)this.Page.Session["QuestionAccessor"]).add_New_Sub_Question(this.strQID, new_Sub_QID, this.intLevel + 1); // the following is failed by dolphin, currently removed @ 2006-08-20 //if (Question_Edit_Type == "Choice_Question") { // try { // string strSQL = "INSERT INTO SubQuestionMap VALUES('" + "hsmokCase200607090009459062500" + "','" + this.strQID + "','" + new_Sub_QID + "')"; // Hints.DB.clsHintsDB hintsDB = new Hints.DB.clsHintsDB(); // hintsDB.ExecuteNonQuery(strSQL); // } // catch { } //} add_sub_question(new_Sub_QID); }
/// <summary> /// 新增父問題後面的後續問題 /// </summary> /// <param name="QID">問題ID</param> /// <param name="new_Sub_QID">要新增後續問題的ID</param> public void add_New_Sub_Question(string QID, string new_Sub_QID, int intLevel) { //新增資料到QuestionIndex DataRow new_Sub_QID_DataRow = this.QuestionIndex.NewRow(); new_Sub_QID_DataRow["cQID"] = new_Sub_QID; new_Sub_QID_DataRow["cQuestion"] = ""; new_Sub_QID_DataRow["sLevel"] = intLevel; QuestionIndex.Rows.Add(new_Sub_QID_DataRow); //新增資料到QuestionLinkQID new_Sub_QID_DataRow = this.QuestionLinkQID.NewRow(); new_Sub_QID_DataRow["cParentQID"] = QID; new_Sub_QID_DataRow["cSubQID"] = new_Sub_QID; new_Sub_QID_DataRow["sSeq"] = CommonQuestionUtility.GetMaxSequence(QID, qsAccessor.QuestionSelectionIndex, QuestionLinkQID); QuestionLinkQID.Rows.Add(new_Sub_QID_DataRow); }
private void newFirstLevelQuestion() { QuestionItemControlTable qItemControlTable = null; //QuestionItemControlTable string QID = CommonQuestionUtility.GetNewID(this.UserID, "Question"); //下面回圈所處理問題ID qItemControlTable = new QuestionItemControlTable(this.Question_Edit_Type, this.UserID, QID, "", this, 1, recordDisplayItemID, CaseID); this.LayoutTable.Rows.Add(new TableRow()); this.LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells.Add(new TableCell()); this.LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells[0].Controls.Add(qItemControlTable); this.qAccessor.add_New_Question(QID); qItemControlTable.addQuestionAnswer(this.Page); if ((Question_Edit_Type == "Group_Question" || Question_Edit_Type == "Choice_Question") && !Convert.ToBoolean(Session["bModify"])) { Session["CurrentEditQuestionNum"] = Convert.ToInt32(Session["totalQuestionNum"]); } Session["totalQuestionNum"] = Convert.ToInt32(Session["totalQuestionNum"]) + 1; }
// /// <summary> // /// 若問題的編輯模式是"GroupQuestion",則需設定其一些額外的Session變數,以決定其呈現的方式 // /// </summary> // private void setGroupQuestionSessionVariableForDeleteQuestion() // { // if(this.Question_Edit_Type=="Group_Question" && this.intLevel==1) // { // if(this.Page.Session["totalQuestionNum"]==null) // { // Session.Add("totalQuestionNum",drs.Length); // } // else // { // Session["totalQuestionNum"] = drs.Length; // } // if(!Convert.ToBoolean(Session["bModify"])) // { // Session["CurrentEditQuestionNum"] = Convert.ToInt32(Session["totalQuestionNum"])-1; // } // } // } /// <summary> /// 用在問診中按新增子問題連帶也會產生子問題的回答 /// </summary> public void addQuestionAnswer(Page page) { this.Page = page; if (this.Question_Edit_Type == "Group_Question" || this.Question_Edit_Type == "Choice_Question") { string[] new_SelectionID = CommonQuestionUtility.GetNewID(this.author_UserID, "Selection", 4); //新增的選項ID for (int i = 0; i < 4; i++) { ((QuestionSelectionAccessor)this.Page.Session["QuestionSelectionAccessor"]).add_new_selection(this.strQID, new_SelectionID[i]); addSelection(new_SelectionID[i]); } } else { string new_SelectionID = CommonQuestionUtility.GetNewID(this.author_UserID, "Selection"); //新增的選項ID ((QuestionSelectionAccessor)this.Page.Session["QuestionSelectionAccessor"]).add_new_selection(this.strQID, new_SelectionID); addSelection(new_SelectionID); } }
/// <summary> /// 建構本身的HTML Table /// </summary> /// <param name="QuestionItemDataTable"></param> private void constructSelectionItemTable() { this.Rows.Add(new TableRow()); this.Rows[this.Rows.Count - 1].Cells.Add(new TableCell()); this.Rows[this.Rows.Count - 1].Cells[0].Wrap = false; this.Rows[this.Rows.Count - 1].Cells[0].VerticalAlign = VerticalAlign.Middle; Table controlContainer = CommonQuestionUtility.get_HTMLTable(2, 4); if (intNumber > 0) { controlContainer.Rows[0].Visible = false; } controlContainer.BorderWidth = Unit.Pixel(2); controlContainer.BorderColor = Color.Purple; controlContainer.GridLines = GridLines.Both; controlContainer.Width = Unit.Parse("100%"); this.Rows[this.Rows.Count - 1].Cells[0].Controls.Add(controlContainer); addSelectionLabel(0, 0); addSelectionResponseLabel(0, 1); addSelectionCorrectAnswerLabel(0, 2); if (intNumber > 0) { addButtonControl(1, 3); } else { addButtonControl(0, 3); } addSelectionTextBox(1, 0); addSelectionResponseTextBox(1, 1); addCheckBox(1, 2); addPlusImage(true); add_sub_question(); setTableStyle(); }
/// <summary> /// 新增父問題後面的後續問題 /// </summary> /// <param name="QID">問題ID</param> /// <param name="new_Sub_QID">要新增後續問題的ID</param> public void add_New_Sub_Question(string QID, string new_Sub_QID, int intLevel, string question_type, string case_id) { //新增資料到QuestionIndex DataRow new_Sub_QID_DataRow = this.QuestionIndex.NewRow(); new_Sub_QID_DataRow["cQID"] = new_Sub_QID; new_Sub_QID_DataRow["cQuestion"] = ""; new_Sub_QID_DataRow["sLevel"] = intLevel; QuestionIndex.Rows.Add(new_Sub_QID_DataRow); //新增資料到QuestionLinkQID new_Sub_QID_DataRow = this.QuestionLinkQID.NewRow(); new_Sub_QID_DataRow["cParentQID"] = QID; new_Sub_QID_DataRow["cSubQID"] = new_Sub_QID; new_Sub_QID_DataRow["sSeq"] = CommonQuestionUtility.GetMaxSequence(QID, qsAccessor.QuestionSelectionIndex, QuestionLinkQID); QuestionLinkQID.Rows.Add(new_Sub_QID_DataRow); //新增資料到SubQuestionMap try { string strSQL = "INSERT INTO SubQuestionMap VALUES('" + case_id + "','" + QID + "','" + new_Sub_QID + "')"; sqldb.ExecuteNonQuery(strSQL); } catch { } }
/// <summary> /// 初始化要呈現給使用者設定特徵值的操作的介面 /// </summary> private void InititateLayoutTableForFeature() { LayoutTableForFeature.ID = "LayoutTableForFeature"; //第一列 LayoutTableForFeature.Width = Unit.Parse("100%"); //LayoutTable.BorderWidth = Unit.Parse("3px"); //LayoutTable.BorderColor = Color.Green; LayoutTableForFeature.ID = "LayoutTableForFeature_1"; LayoutTableForFeature.Rows.Add(new TableRow()); LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells.Add(new TableCell()); Label FeatureTitle = new Label(); FeatureTitle.Text = "SetFeature"; LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells[0].Controls.Add(FeatureTitle); LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells[0].CssClass = "title"; //第二列 LayoutTableForFeature.Rows.Add(new TableRow()); LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells.Add(new TableCell()); Table containerForFeature = CommonQuestionUtility.get_HTMLTable(1, 2); LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells[0].Controls.Add(containerForFeature); }
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(); }
/// <summary> /// 初始化要呈現給使用者操作的介面,因為使用者要操作的介面排版住要是利用LayoutTable來安排位置 /// </summary> private void InititateLayoutTable() { //LayoutTable的設定 //第一列 LayoutTable.Width = Unit.Parse("100%"); //LayoutTable.BorderWidth = Unit.Parse("3px"); //LayoutTable.BorderColor = Color.Green; LayoutTable.ID = "LayoutTable_1"; LayoutTable.Rows.Add(new TableRow()); LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells.Add(new TableCell()); Label Title = new Label(); if (ViewState["TitleText"] == null) { if (this.Question_Edit_Type == "Choice_Question") { ViewState["TitleText"] = usi.Section; } else { ViewState["TitleText"] = "Question Editor"; } } Title.Text = ViewState["TitleText"].ToString(); //Title.Font.Size = FontUnit.Parse("25"); //Title.ForeColor = Color.DarkRed; // removed by dolphin @ 2006-07-28 LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells[0].Controls.Add(Title); LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells[0].CssClass = "title"; //第二列 LayoutTable.Rows.Add(new TableRow()); LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells.Add(new TableCell()); Table container = CommonQuestionUtility.get_HTMLTable(1, 2); Label questionTypeLabel = new Label(); questionTypeLabel.Text = "<b>Question Type: </b>"; questionTypeLabel.Visible = false; ////選擇編輯模式的下拉式選單 //Question_Edit_Type_DDL = getQuestion_Edit_Type_DDL(); //新增問題的Button Button btnNew = new Button(); btnNew.BackColor = Color.FromName("#FF9933"); btnNew.Width = Unit.Pixel(140); btnNew.Text = "Add New Question"; btnNew.ID = "NewItemButton_1"; btnNew.Click += new EventHandler(btnNew_Click); //container.Rows[container.Rows.Count-1].Cells[0].Controls.Add(questionTypeLabel); //container.Rows[container.Rows.Count-1].Cells[0].Controls.Add(Question_Edit_Type_DDL); container.Rows[container.Rows.Count - 1].Cells[1].Controls.Add(btnNew); container.Rows[container.Rows.Count - 1].Cells[1].Width = Unit.Parse("10%"); LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells[0].Controls.Add(container); }
/// <summary> /// 開始至資料庫讀取問題以及問題的選項,並將問題按照父子關係呈現至HTML的Table中,以呈現至前端 /// </summary> private void ProcessData() { recordDisplayItemID.Value = this.Request.Form["recordDisplayItemID"]; DataRow[] drs = qAccessor.QuestionIndex.Select("sLevel=1"); //取得第一階層的起始問題 string QID = ""; if (this.Question_Edit_Type == "Group_Question" && !Convert.ToBoolean(Session["bModify"]) && !this.IsPostBack || (this.Question_Edit_Type == "Choice_Question" && !this.IsPostBack && drs.Length == 0)) { QID = CommonQuestionUtility.GetNewID(this.UserID, "Question"); //下面回圈所處理問題ID this.qAccessor.add_New_Question(QID); string[] new_SelectionID = CommonQuestionUtility.GetNewID(this.UserID, "Selection", 4); //新增的選項ID for (int i = 0; i < 4; i++) { this.qsAccessor.add_new_selection(QID, new_SelectionID[i]); } } drs = qAccessor.QuestionIndex.Select("sLevel=1"); //取得第一階層的起始問題 QuestionItemControlTable qItemControlTable = null; //QuestionItemControlTable // string LevelAndRank = ""; //下面回圈所處理問題ID string QuestionText = ""; string KeyWordsText = ""; if (this.Question_Edit_Type == "Group_Question" || this.Question_Edit_Type == "Choice_Question") { if (Session["totalQuestionNum"] == null) { Session.Add("totalQuestionNum", drs.Length); } else { Session["totalQuestionNum"] = drs.Length; } if (!Convert.ToBoolean(Session["bModify"])) { if (this.Page.IsPostBack == false) { Session["CurrentEditQuestionNum"] = Convert.ToInt32(Session["totalQuestionNum"]) - 1; } } else { if ((Request.QueryString["QID"] + "").Length > 0) { strQID = Request.QueryString["QID"].ToString(); Session["CurrentEditQuestionNum"] = getCurrentEditQuestionNumByQID(drs, Request.QueryString["QID"] + "");//在修改模式下,取得是哪個問題要修改 } else { Session["CurrentEditQuestionNum"] = Convert.ToInt32(Session["totalQuestionNum"]) - 1; } } } for (int i = 0; i < drs.Length; i++) //開始針對每個問題作處理 { QID = drs[i]["cQID"].ToString(); //問題ID set_recordDisplayItemID(QID); QuestionText = drs[i]["cQuestion"].ToString(); //問題內容 KeyWordsText = drs[i]["cKeyWords"].ToString(); //關鍵字內容 qItemControlTable = new QuestionItemControlTable(this.Question_Edit_Type, this.UserID, QID, QuestionText, this, 1, this.recordDisplayItemID, CaseID, KeyWordsText); this.LayoutTable.Rows.Add(new TableRow()); this.LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells.Add(new TableCell()); this.LayoutTable.Rows[LayoutTable.Rows.Count - 1].Cells[0].Controls.Add(qItemControlTable); if (this.Question_Edit_Type == "Group_Question" || this.Question_Edit_Type == "Choice_Question") { this.LayoutTable.Rows[LayoutTable.Rows.Count - 1].Style.Add("display", "none"); } } //朱君 加入特徵值TABLE if (strQID == "") { strQID = QID; //朱君 避免新創題目時strQID為空 } FeatureItemControl qFeatureItemControlTable = new FeatureItemControl(this, 1, strGroupID, strQID); //FeatureItemControlTable qFeatureItemControlTable.ID = "FeatureItemControlTable"; this.LayoutTableForFeature.Rows.Add(new TableRow()); this.LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells.Add(new TableCell()); this.LayoutTableForFeature.Rows[LayoutTableForFeature.Rows.Count - 1].Cells[0].Controls.Add(qFeatureItemControlTable); //新增題目時的QID 蕭凱2014/3/25 strAddNewQID = QID; }