//建立題組的表格 private void BuildQuestionGroupTable() { switch (strQuestionType) { #region 選擇題 case "1": tcQuestionGroupTable.Controls.Clear(); Table table = new Table(); tcQuestionGroupTable.Controls.Add(table); table.CellSpacing = 0; table.CellPadding = 2; table.BorderStyle = BorderStyle.Solid; table.BorderWidth = Unit.Pixel(1); table.BorderColor = System.Drawing.Color.Black; table.GridLines = GridLines.Both; table.Width = Unit.Percentage(100); //建立Table的CSS table.CssClass = "header1_table"; //建立問題的內容 TableRow trQuestion = new TableRow(); table.Rows.Add(trQuestion); //問題的內容 TableCell tcQuestion = new TableCell(); trQuestion.Cells.Add(tcQuestion); tcQuestion.Text = GetQuestionContext(); tcQuestion.ColumnSpan = 2; tcQuestion.Style.Add("text-align", "left"); //建立問題的CSS trQuestion.Attributes.Add("Class", "header1_table_first_row"); //建立選項的標題 TableRow trSelectionTitle = new TableRow(); table.Rows.Add(trSelectionTitle); TableCell tcSelectionTitle = new TableCell(); trSelectionTitle.Cells.Add(tcSelectionTitle); tcSelectionTitle.Text = "選項內容"; tcSelectionTitle.Width = Unit.Pixel(100); TableCell tcSelectionQuestionGroup = new TableCell(); trSelectionTitle.Cells.Add(tcSelectionQuestionGroup); tcSelectionQuestionGroup.Text = "編輯功能"; //建立選項 SQLString mySQLString = new SQLString(); string strSQL_QuestionSelectionIndex = mySQLString.getAllSelections(strQID); clsHintsDB HintsDB = new clsHintsDB(); DataSet dsSelection = HintsDB.getDataSet(strSQL_QuestionSelectionIndex); if (dsSelection.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsSelection.Tables[0].Rows.Count; j++) { //Seq string strSeq = ""; strSeq = dsSelection.Tables[0].Rows[j]["sSeq"].ToString(); //Selection string strSelection = ""; strSelection = dsSelection.Tables[0].Rows[j]["cSelection"].ToString(); //bCaseSelect bool bCaseSelect = false; bCaseSelect = Convert.ToBoolean(dsSelection.Tables[0].Rows[j]["bCaseSelect"]); //SelectionID string strSelectionID = ""; strSelectionID = dsSelection.Tables[0].Rows[j]["cSelectionID"].ToString(); TableRow trSelection = new TableRow(); table.Rows.Add(trSelection); //選項的相關內容 TableCell tcSelectionContext = new TableCell(); trSelection.Cells.Add(tcSelectionContext); tcSelectionContext.Width = Unit.Percentage(80); tcSelectionContext.Style.Add("text-align", "left"); //是否為建議選項 HtmlImage imgSuggest = new HtmlImage(); tcSelectionContext.Controls.Add(imgSuggest); if (bCaseSelect == true) { imgSuggest.Src = "/Hints/Summary/Images/smiley4.gif"; } else { imgSuggest.Src = "/Hints/Summary/Images/smiley11.gif"; } //選項內容 Label lbSelection = new Label(); lbSelection.Text = " " + strSelection; tcSelectionContext.Controls.Add(lbSelection); //選項的相關題目 TableCell tcSelectionRelatedQuestion = new TableCell(); trSelection.Cells.Add(tcSelectionRelatedQuestion); tcSelectionRelatedQuestion.Width = Unit.Percentage(20); tcSelectionRelatedQuestion.Style.Add("text-align", "center"); DataTable dt = new DataTable(); if (dt.Rows.Count > 0) { Button btEditQuestionGroup = new Button(); btEditQuestionGroup.Text = "編輯相關問題"; btEditQuestionGroup.CssClass = "button_continue"; btEditQuestionGroup.Click += new EventHandler(btEditQuestionGroup_Click); tcSelectionRelatedQuestion.Controls.Add(btEditQuestionGroup); btEditQuestionGroup.CommandArgument = strSelectionID; } else { Button btEditQuestionGroup = new Button(); btEditQuestionGroup.Text = "編輯相關問題"; btEditQuestionGroup.CssClass = "button_continue"; btEditQuestionGroup.Click += new EventHandler(btEditQuestionGroup_Click); tcSelectionRelatedQuestion.Controls.Add(btEditQuestionGroup); btEditQuestionGroup.CommandArgument = strSelectionID; Label lbNull = new Label(); lbNull.Text = " NULL"; //tcSelectionRelatedQuestion.Controls.Add(lbNull); } //建立選項的CSS if ((Convert.ToInt32(strSeq) % 2) != 0) { trSelection.Attributes.Add("Class", "header1_tr_even_row"); } else { trSelection.Attributes.Add("Class", "header1_tr_odd_row"); } } } else { //此問題沒有選項 } dsSelection.Dispose(); break; #endregion //問答題 case "2": break; #region 圖型題 case "3": tcQuestionGroupTable.Controls.Clear(); Table table_sim = new Table(); tcQuestionGroupTable.Controls.Add(table_sim); table_sim.CellSpacing = 0; table_sim.CellPadding = 2; table_sim.BorderStyle = BorderStyle.Solid; table_sim.BorderWidth = Unit.Pixel(1); table_sim.BorderColor = System.Drawing.Color.Black; table_sim.GridLines = GridLines.Both; table_sim.Width = Unit.Percentage(100); //建立Table的CSS table_sim.CssClass = "header1_table"; //建立問題的內容 TableRow trQuestion_sim = new TableRow(); table_sim.Rows.Add(trQuestion_sim); //問題的內容 TableCell tcQuestion_sim = new TableCell(); trQuestion_sim.Cells.Add(tcQuestion_sim); tcQuestion_sim.Text = GetQuestionContext(); tcQuestion_sim.ColumnSpan = 2; tcQuestion_sim.Style.Add("text-align", "left"); //建立問題的CSS trQuestion_sim.Attributes.Add("Class", "header1_table_first_row"); //建立選項的標題 TableRow trSelectionTitle_sim = new TableRow(); table_sim.Rows.Add(trSelectionTitle_sim); TableCell tcSelectionTitle_sim = new TableCell(); trSelectionTitle_sim.Cells.Add(tcSelectionTitle_sim); tcSelectionTitle_sim.Text = "選項內容"; trSelectionTitle_sim.Width = Unit.Pixel(100); TableCell tcSelectionQuestionGroup_sim = new TableCell(); trSelectionTitle_sim.Cells.Add(tcSelectionQuestionGroup_sim); tcSelectionQuestionGroup_sim.Text = "編輯功能"; //建立選項 SQLString mySQLString_sim = new SQLString(); string strSQL_QuestionSelectionIndex_sim = mySQLString_sim.getAllSimulation(strQID); clsHintsDB HintsDB_sim = new clsHintsDB(); DataSet dsSelection_sim = HintsDB_sim.getDataSet(strSQL_QuestionSelectionIndex_sim); if (dsSelection_sim.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsSelection_sim.Tables[0].Rows.Count; j++) { //Seq //string strSeq = ""; //strSeq = dsSelection_sim.Tables[0].Rows[j]["sSeq"].ToString(); //Selection string strSelection = ""; strSelection = dsSelection_sim.Tables[0].Rows[j]["cAnswer"].ToString(); strSelection = strSelection.Replace('|', ','); //把線換成逗號 strSelection = strSelection.Substring(0, strSelection.Length - 1); //刪掉最後一個逗號 ////bCaseSelect //bool bCaseSelect = false; //bCaseSelect = Convert.ToBoolean(dsSelection_sim.Tables[0].Rows[j]["bCaseSelect"]); //SelectionID string strSelectionID = ""; strSelectionID = dsSelection_sim.Tables[0].Rows[j]["cAnsID"].ToString(); TableRow trSelection = new TableRow(); table_sim.Rows.Add(trSelection); //選項的相關內容 TableCell tcSelectionContext = new TableCell(); trSelection.Cells.Add(tcSelectionContext); tcSelectionContext.Width = Unit.Percentage(80); tcSelectionContext.Style.Add("text-align", "left"); ////是否為建議選項 //HtmlImage imgSuggest = new HtmlImage(); //tcSelectionContext.Controls.Add(imgSuggest); //if (bCaseSelect == true) //{ // imgSuggest.Src = "/Hints/Summary/Images/smiley4.gif"; //} //else //{ // imgSuggest.Src = "/Hints/Summary/Images/smiley11.gif"; //} //選項內容 Label lbSelection = new Label(); lbSelection.Text = " " + strSelection; tcSelectionContext.Controls.Add(lbSelection); //選項的相關題目 TableCell tcSelectionRelatedQuestion = new TableCell(); trSelection.Cells.Add(tcSelectionRelatedQuestion); tcSelectionRelatedQuestion.Width = Unit.Percentage(20); tcSelectionRelatedQuestion.Style.Add("text-align", "center"); DataTable dt = new DataTable(); if (dt.Rows.Count > 0) { Button btEditQuestionGroup = new Button(); btEditQuestionGroup.Text = "編輯相關問題"; btEditQuestionGroup.CssClass = "button_continue"; btEditQuestionGroup.Click += new EventHandler(btEditQuestionGroup_Click); tcSelectionRelatedQuestion.Controls.Add(btEditQuestionGroup); btEditQuestionGroup.CommandArgument = strSelectionID; } else { Button btEditQuestionGroup = new Button(); btEditQuestionGroup.Text = "編輯相關問題"; btEditQuestionGroup.CssClass = "button_continue"; btEditQuestionGroup.Click += new EventHandler(btEditQuestionGroup_Click); tcSelectionRelatedQuestion.Controls.Add(btEditQuestionGroup); btEditQuestionGroup.CommandArgument = strSelectionID; Label lbNull = new Label(); lbNull.Text = " NULL"; //tcSelectionRelatedQuestion.Controls.Add(lbNull); } //建立選項的CSS //if ((Convert.ToInt32(strSeq) % 2) != 0) if ((j % 2) != 0) { trSelection.Attributes.Add("Class", "header1_tr_even_row"); } else { trSelection.Attributes.Add("Class", "header1_tr_odd_row"); } } } else { //此問題沒有選項 } dsSelection_sim.Dispose(); break; #endregion case "4": tcQuestionGroupTable.Controls.Clear(); Table Contable = new Table(); tcQuestionGroupTable.Controls.Add(Contable); Contable.CellSpacing = 0; Contable.CellPadding = 2; Contable.BorderStyle = BorderStyle.Solid; Contable.BorderWidth = Unit.Pixel(1); Contable.BorderColor = System.Drawing.Color.Black; Contable.GridLines = GridLines.Both; Contable.Width = Unit.Percentage(100); //建立Table的CSS Contable.CssClass = "header1_table"; //建立問題的內容 TableRow trConQuestion = new TableRow(); Contable.Rows.Add(trConQuestion); //問題的內容 TableCell tcConQuestion = new TableCell(); trConQuestion.Cells.Add(tcConQuestion); tcConQuestion.Text = "Student's Answer Options"; tcConQuestion.ColumnSpan = 2; tcConQuestion.Style.Add("text-align", "left"); //建立問題的CSS trConQuestion.Attributes.Add("Class", "header1_table_first_row"); //建立選項的標題 TableRow trConSelectionTitle = new TableRow(); Contable.Rows.Add(trConSelectionTitle); TableCell tcConSelectionTitle = new TableCell(); trConSelectionTitle.Cells.Add(tcConSelectionTitle); tcConSelectionTitle.Text = "選項內容"; tcConSelectionTitle.Width = Unit.Pixel(100); TableCell tcConSelectionQuestionGroup = new TableCell(); trConSelectionTitle.Cells.Add(tcConSelectionQuestionGroup); tcConSelectionQuestionGroup.Text = "編輯功能"; //建立選項 SQLString myConSQLString = new SQLString(); string strSQL_VPAns = "SELECT * FROM StudentAnsType WHERE cVPAID = '" + strQID + "'"; clsHintsDB HintsConDB = new clsHintsDB(); DataSet dsConSelection = HintsConDB.getDataSet(strSQL_VPAns); if (dsConSelection.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsConSelection.Tables[0].Rows.Count; j++) { //Selection string strSelection = ""; strSelection = dsConSelection.Tables[0].Rows[j]["cAnswerContent"].ToString(); //bCaseSelect bool bCaseSelect = false; bCaseSelect = Convert.ToBoolean(dsConSelection.Tables[0].Rows[j]["bIsCorrect"]); //SelectionID string strSelectionID = ""; strSelectionID = Convert.ToString(j); TableRow trConSelection = new TableRow(); Contable.Rows.Add(trConSelection); //選項的相關內容 TableCell tcConSelectionContext = new TableCell(); trConSelection.Cells.Add(tcConSelectionContext); tcConSelectionContext.Width = Unit.Percentage(80); tcConSelectionContext.Style.Add("text-align", "left"); //是否為建議選項 HtmlImage imgConSuggest = new HtmlImage(); tcConSelectionContext.Controls.Add(imgConSuggest); if (bCaseSelect == true) { imgConSuggest.Src = "/Hints/Summary/Images/smiley4.gif"; } else { imgConSuggest.Src = "/Hints/Summary/Images/smiley11.gif"; } //選項內容 Label lbConSelection = new Label(); lbConSelection.Text = " " + strSelection; tcConSelectionContext.Controls.Add(lbConSelection); //選項的相關題目 TableCell tcConSelectionRelatedQuestion = new TableCell(); trConSelection.Cells.Add(tcConSelectionRelatedQuestion); tcConSelectionRelatedQuestion.Width = Unit.Percentage(20); tcConSelectionRelatedQuestion.Style.Add("text-align", "center"); DataTable dt = new DataTable(); if (dt.Rows.Count > 0) { Button btEditQuestionGroup = new Button(); btEditQuestionGroup.Text = "編輯相關問題"; btEditQuestionGroup.CssClass = "button_continue"; btEditQuestionGroup.Style["cursor"] = "pointer"; btEditQuestionGroup.Click += new EventHandler(btEditQuestionGroup_Click); tcConSelectionRelatedQuestion.Controls.Add(btEditQuestionGroup); btEditQuestionGroup.CommandArgument = strSelectionID + "_" + strSelection; } else { Button btEditQuestionGroup = new Button(); btEditQuestionGroup.Text = "編輯相關問題"; btEditQuestionGroup.CssClass = "button_continue"; btEditQuestionGroup.Style["cursor"] = "pointer"; btEditQuestionGroup.Click += new EventHandler(btEditQuestionGroup_Click); tcConSelectionRelatedQuestion.Controls.Add(btEditQuestionGroup); btEditQuestionGroup.CommandArgument = strSelectionID + "_" + strSelection; Label lbNull = new Label(); lbNull.Text = " NULL"; //tcSelectionRelatedQuestion.Controls.Add(lbNull); } //建立選項的CSS if (((j + 1) % 2) != 0) { trConSelection.Attributes.Add("Class", "header1_tr_even_row"); } else { trConSelection.Attributes.Add("Class", "header1_tr_odd_row"); } } } else { //此問題沒有選項 } dsConSelection.Dispose(); break; default: break; } }
/// <summary> /// 儲存一個題目下所有選項的資料至Paper_NextStepBySelectionID /// </summary> /// <param name="WebPage"></param> /// <param name="strPaperID"></param> /// <param name="strQID"></param> /// <param name="strSelectionID"></param> /// <param name="intQuestionIndex"></param> public void saveNextStepBySelectionID(System.Web.UI.Page WebPage, string strPaperID, string strQID, int intQuestionIndex) { //DataReceiver myReceiver = new DataReceiver(); //選項 SQLString mySQL = new SQLString(); string strSQL = mySQL.getAllSelections(strQID); SqlDB myDB = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]); DataSet dsSelection = myDB.getDataSet(strSQL); if (dsSelection.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsSelection.Tables[0].Rows.Count; i++) { string strSelectionID = dsSelection.Tables[0].Rows[i]["cSelectionID"].ToString(); int intSelectionIndex = Convert.ToInt32(dsSelection.Tables[0].Rows[i]["sSeq"]); string strSelection = dsSelection.Tables[0].Rows[i]["cSelection"].ToString(); bool bSuggested = Convert.ToBoolean(dsSelection.Tables[0].Rows[i]["bCaseSelect"]); //取得題號下拉式選單被選取的內容 string strDlIndexID = "dlSelection-Index-" + strSelectionID; DropDownList dlIndex = ((DropDownList)(WebPage.FindControl("Form1").FindControl(strDlIndexID))); int intNextIndex = Convert.ToInt32(dlIndex.SelectedItem.Value); //取得Section下拉式選單被選取的內容 string strDlSectionID = "dlSelection-Section-" + strSelectionID; DropDownList dlSection = ((DropDownList)(WebPage.FindControl("Form1").FindControl(strDlSectionID))); string strNextSection = ""; if (dlSection.SelectedItem != null) { strNextSection = dlSection.SelectedItem.Value; } //此選項的NextStep是By Section還是題號 int intNextMethod = 2; //檢查此選項的NextStep是Section還是題號 string strRbIndexID = "rbIndex-" + strSelectionID; RadioButton rbIndex = ((RadioButton)(WebPage.FindControl("Form1").FindControl(strRbIndexID))); string strRbSectionID = "rbSection-" + strSelectionID; RadioButton rbSection = ((RadioButton)(WebPage.FindControl("Form1").FindControl(strRbSectionID))); string strRbDefaultID = "rbDefault-" + strSelectionID; RadioButton rbDefault = ((RadioButton)(WebPage.FindControl("Form1").FindControl(strRbDefaultID))); if (rbIndex.Checked == true) { if (intNextIndex == 0) { //結束Section intNextMethod = 0; } else { //題號 intNextMethod = 2; } } else if (rbSection.Checked == true) { //Section intNextMethod = 1; } else { //Default intNextMethod = 9999; intNextIndex = 9999; } //把資料存入Paper_NextStepBySelectionID SQLString.SaveToPaper_NextStepBySelectionID(strPaperID, strQID, intQuestionIndex, strSelectionID, intSelectionIndex, intNextMethod, strNextSection, intNextIndex); } } dsSelection.Dispose(); }
/// <summary> /// 建立一個可以顯示建議與非建議選項選擇題的表格 /// </summary> /// <returns></returns> public Table setupSingleSelectionQuestionTableByPlainView(string strPaperID, string strCaseID, int intClinicNum, string strSectionName, string strQID, int intQuestionIndex) { DataReceiver myReceiver = new DataReceiver(); Table table = new Table(); //題目 TableRow trQuestion = new TableRow(); table.Rows.Add(trQuestion); //題號 TableCell tcNum = new TableCell(); trQuestion.Cells.Add(tcNum); tcNum.Text = intQuestionIndex.ToString(); tcNum.Attributes.Add("align", "center"); tcNum.Style.Add("WIDTH", "10px"); //Question string strQuestion = myReceiver.getSelectionQuestionContent(strQID); TableCell tcQuestion = new TableCell(); trQuestion.Cells.Add(tcQuestion); tcQuestion.Text = strQuestion; //設定回饋機制 TableCell tcRetry = new TableCell(); trQuestion.Cells.Add(tcRetry); tcRetry.Attributes["align"] = "center"; tcRetry.Style["width"] = "220px"; HtmlInputButton btnRetry = new HtmlInputButton("button"); tcRetry.Controls.Add(btnRetry); btnRetry.Style["width"] = "150px"; btnRetry.Style["height"] = "30px"; btnRetry.Value = "設定回饋機制"; btnRetry.Attributes.Add("class", "button_continue"); btnRetry.Attributes["onclick"] = "callRetrySetting('" + strPaperID + "' , '" + strCaseID + "' , '" + intClinicNum + "' , '" + strSectionName + "' , '" + strQID + "')"; //選項 SQLString mySQL = new SQLString(); string strSQL = mySQL.getAllSelections(strQID); SqlDB myDB = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]); DataSet dsSelection = myDB.getDataSet(strSQL); if (dsSelection.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsSelection.Tables[0].Rows.Count; i++) { TableRow trSelection = new TableRow(); table.Rows.Add(trSelection); string strSelectionID = dsSelection.Tables[0].Rows[i]["cSelectionID"].ToString(); int intSeq = Convert.ToInt32(dsSelection.Tables[0].Rows[i]["sSeq"]); string strSelection = dsSelection.Tables[0].Rows[i]["cSelection"].ToString(); bool bSuggested = Convert.ToBoolean(dsSelection.Tables[0].Rows[i]["bCaseSelect"]); //顯示建議或是非建議選項的圖片 TableCell tcControl = new TableCell(); trSelection.Cells.Add(tcControl); tcControl.Attributes.Add("align", "center"); tcControl.Style.Add("WIDTH", "10px"); //img HtmlImage img = new HtmlImage(); tcControl.Controls.Add(img); if (bSuggested == true) { //Suggested img.Src = "/Hints/Summary/Images/smiley4.gif"; } else { //Un-Suggested img.Src = "/Hints/Summary/Images/smiley11.gif"; } //Selection TableCell tcSelection = new TableCell(); trSelection.Cells.Add(tcSelection); tcSelection.Text = strSelection; //NextStep TableCell tcNextStep = new TableCell(); trSelection.Cells.Add(tcNextStep); tcNextStep.Style["width"] = "220px"; tcNextStep.Controls.Add(this.getNextStepTable(strPaperID, strCaseID, intClinicNum, strSectionName, strQID, strSelectionID, bSuggested, intQuestionIndex)); } } dsSelection.Dispose(); //設定外觀 TableAttribute.setupTopHeaderTableStyle(table, "TableName", 1, "100%", 5, 0, GridLines.Both, true); return(table); }
private void setupHintsQuestionTable() { Table table = new Table(); table.CellSpacing = 0; table.CellPadding = 2; table.BorderStyle = BorderStyle.Solid; table.BorderWidth = Unit.Pixel(1); table.BorderColor = System.Drawing.Color.Black; table.GridLines = GridLines.None; table.Width = Unit.Percentage(100); intQuestionIndex = 0; //取出此問卷的選擇題內容 string strSQL = mySQLString.getPaperSelectionContent(strPaperID); DataSet dsQuestionList = sqldb.getDataSet(strSQL); if (dsQuestionList.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsQuestionList.Tables[0].Rows.Count; i++) { //取得QuestionType string strQuestionType = "1"; try { strQuestionType = dsQuestionList.Tables[0].Rows[i]["cQuestionType"].ToString(); } catch { } //取得QID string strQID = ""; try { strQID = dsQuestionList.Tables[0].Rows[i]["cQID"].ToString(); } catch { } //設定Selection row的CSS所設定的變數 int intQuestionCount = 0; //取得問題的SQL strSQL = mySQLString.getSingleQuestionInformation(strQID); DataSet dsQuestion = sqldb.getDataSet(strSQL); if (dsQuestion.Tables[0].Rows.Count > 0) { //建立問題的內容 TableRow trQuestion = new TableRow(); table.Rows.Add(trQuestion); intQuestionIndex += 1; //問題的題號 string strQuestionNum = "Q" + intQuestionIndex.ToString() + ": "; //問題的內容 string strQuestion = ""; try { strQuestion = dsQuestion.Tables[0].Rows[0]["cQuestion"].ToString(); } catch { } TableCell tcQuestion = new TableCell(); trQuestion.Cells.Add(tcQuestion); tcQuestion.Text = strQuestionNum + strQuestion; double dQuestionWidth = tcQuestion.Width.Value; //建立問題的CSS trQuestion.Attributes.Add("Class", "TableTitle"); trQuestion.ForeColor = System.Drawing.Color.DarkRed; trQuestion.Font.Bold = true; //建立選項 TableRow trSelection = new TableRow(); table.Rows.Add(trSelection); int intColSpan = 0; strSQL = mySQLString.getAllSelections(strQID); DataSet dsSelection = sqldb.getDataSet(strSQL); if (dsSelection.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsSelection.Tables[0].Rows.Count; j++) { intQuestionCount += 1; //SelectionID string strSelectionID = ""; try { strSelectionID = dsSelection.Tables[0].Rows[j]["cSelectionID"].ToString(); } catch { } //Seq string strSeq = ""; try { strSeq = dsSelection.Tables[0].Rows[j]["sSeq"].ToString(); } catch { } //Selection string strSelection = ""; try { strSelection = dsSelection.Tables[0].Rows[j]["cSelection"].ToString(); } catch { } //bCaseSelect bool bCaseSelect = false; try { bCaseSelect = Convert.ToBoolean(dsSelection.Tables[0].Rows[j]["bCaseSelect"]); } catch { } //選項內容與RadioButton TableCell tcSelection = new TableCell(); trSelection.Cells.Add(tcSelection); RadioButton rbSelection = new RadioButton(); tcSelection.Controls.Add(rbSelection); rbSelection.Text = strSelection; rbSelection.GroupName = strQID; string strID = "rb-" + strQID + "-" + strSelectionID; rbSelection.ID = strID; try { if (Request.Form[strQID] != null) { if (Request.Form[strQID].ToString() == strID) { rbSelection.Checked = true; } } } catch { } intColSpan += 1; } tcQuestion.ColumnSpan = intColSpan; } else { //此問題沒有選項 } dsSelection.Dispose(); } else { //此問題沒有選項 } dsQuestion.Dispose(); } } else { //此問卷沒有選擇題的情況 } dsQuestionList.Dispose(); int intMaxColSpan = 0; //調整table的TableCell寬度 int intSelectionIndex = 0; for (int i = 0; i < table.Rows.Count; i++) { if (i % 2 != 0) { for (int j = 0; j < table.Rows[i].Cells.Count; j++) { double dPercentage = Convert.ToDouble(100) / Convert.ToDouble(table.Rows[i].Cells.Count); //將每個SelectionCell的寬度設成QuestionCell的寬度/tcSelection的個數 table.Rows[i].Cells[j].Width = Unit.Percentage(dPercentage); if (table.Rows[i].Cells.Count > intMaxColSpan) { intMaxColSpan = table.Rows[i].Cells.Count; } } //建立選項的CSS if ((Convert.ToInt32(intSelectionIndex) % 2) != 0) { table.Rows[i].Attributes.Add("Class", "TableOddRow"); } else { table.Rows[i].Attributes.Add("Class", "TableEvenRow"); } intSelectionIndex += 1; } } //建立屬於此問卷的問答題 strSQL = mySQLString.getPaperTextContent(strPaperID); DataSet dsTextList = sqldb.getDataSet(strSQL); int intTextCount = 0; if (dsTextList.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsTextList.Tables[0].Rows.Count; i++) { intQuestionIndex += 1; //取得此問題的QID string strQID = ""; try { strQID = dsTextList.Tables[0].Rows[i]["cQID"].ToString(); } catch { } TableRow trQuestion = new TableRow(); table.Rows.Add(trQuestion); //Question number string strQuestionNum = "Q" + intQuestionIndex.ToString() + ": "; //Question TableCell tcQuestion = new TableCell(); trQuestion.Cells.Add(tcQuestion); tcQuestion.ColumnSpan = intMaxColSpan; string strQuestion = ""; try { strQuestion = dsTextList.Tables[0].Rows[i]["cQuestion"].ToString(); } catch { } tcQuestion.Text = strQuestionNum + strQuestion; //加入CSS intTextCount += 1; trQuestion.Attributes.Add("Class", "TableTitle"); trQuestion.ForeColor = System.Drawing.Color.DarkRed; trQuestion.Font.Bold = true; //加入答案TableRow TableRow trAnswer = new TableRow(); table.Rows.Add(trAnswer); TableCell tcAnswer = new TableCell(); trAnswer.Cells.Add(tcAnswer); tcAnswer.ColumnSpan = intMaxColSpan; //加入TextArea HtmlTextArea txtAnswer = new HtmlTextArea(); tcAnswer.Controls.Add(txtAnswer); string strTxtID = "txt-" + strQID; txtAnswer.ID = strTxtID; txtAnswer.Cols = 80; txtAnswer.Rows = 5; txtAnswer.Style.Add("WIDTH", "100%"); try { if (Request.Form[strTxtID] != null) { txtAnswer.Value = Request.Form[strTxtID].ToString(); } } catch { } hiddenTextID.Value += strTxtID + ";"; hiddenTextCount.Value = Convert.ToString(Convert.ToInt32(hiddenTextCount.Value) + 1); //套用CSS if ((intTextCount % 2) != 0) { trAnswer.Attributes.Add("Class", "TableOddRow"); } else { trAnswer.Attributes.Add("Class", "TableEvenRow"); } } } else { //此問卷沒有問答題的情形 } dsTextList.Dispose(); //加入Empty TableRow int a = 0; for (int i = table.Rows.Count - 1; i >= 1; i--) { if (a == 1) { TableRow tr1 = new TableRow(); table.Rows.AddAt(i, tr1); TableCell tc1 = new TableCell(); tr1.Cells.Add(tc1); tc1.ForeColor = System.Drawing.Color.Transparent; tc1.Font.Size = FontUnit.Parse("0"); tc1.Text = "1"; TableRow tr2 = new TableRow(); table.Rows.AddAt(i, tr2); TableCell tc2 = new TableCell(); tr2.Cells.Add(tc2); tc2.ForeColor = System.Drawing.Color.Transparent; tc2.Font.Size = FontUnit.Parse("0"); tc2.Text = "1"; a = 0; } else { a += 1; } } phQuestion.Controls.Clear(); phQuestion.Controls.Add(table); }
private void setupQuestionTable() { tcQuestionTable.Controls.Clear(); Table table = new Table(); tcQuestionTable.Controls.Add(table); table.CellSpacing = 0; table.CellPadding = 2; table.BorderStyle = BorderStyle.Solid; table.BorderWidth = Unit.Pixel(1); table.BorderColor = System.Drawing.Color.Black; table.GridLines = GridLines.Both; table.Width = Unit.Percentage(100); //建立Table的CSS table.CssClass = "header1_table"; //依照QuestionMode決定取出此組別的選擇題 string strSQL = mySQL.getGroupSelectionQuestion(Session["GroupID"].ToString()); DataSet dsQuestionList = sqldb.getDataSet(strSQL); if (dsQuestionList.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsQuestionList.Tables[0].Rows.Count; i++) { //取得QuestionType string strQuestionType = "1"; strQuestionType = dsQuestionList.Tables[0].Rows[i]["cQuestionType"].ToString(); //取得QID string strQID = ""; strQID = dsQuestionList.Tables[0].Rows[i]["cQID"].ToString(); //取得問題的SQL DataSet dsQuestion = null; if (hfSymptoms.Value == "All") { strSQL = mySQL.getQuestion(strQID); } else { strSQL = mySQL.getQuestionBySymptoms(strQID, hfSymptoms.Value); } dsQuestion = sqldb.getDataSet(strSQL); if (dsQuestion.Tables[0].Rows.Count > 0) { //建立問題的內容 TableRow trQuestion = new TableRow(); table.Rows.Add(trQuestion); intQuestionIndex += 1; //問題的CheckBox // TableCell tcCheckBox = new TableCell(); // trQuestion.Cells.Add(tcCheckBox); // tcCheckBox.Width = Unit.Pixel(25); // // CheckBox chQuestion = new CheckBox(); // tcCheckBox.Controls.Add(chQuestion); // tcCheckBox.Attributes.Add("onclick","ShowbtnDelete();"); // string strID = ""; // strID = "ch-" + dsQuestion.Tables[0].Rows[0]["cQID"].ToString(); // // chQuestion.ID = strID; //問題的題號 TableCell tcQuestionNum = new TableCell(); trQuestion.Cells.Add(tcQuestionNum); tcQuestionNum.Width = Unit.Pixel(25); tcQuestionNum.Text = "Q" + intQuestionIndex.ToString() + ": "; //問題的內容 string strQuestion = ""; strQuestion = dsQuestion.Tables[0].Rows[0]["cQuestion"].ToString(); TableCell tcQuestion = new TableCell(); trQuestion.Cells.Add(tcQuestion); tcQuestion.Text = strQuestion; //建立問題的CSS trQuestion.Attributes.Add("Class", "header1_table_first_row"); //建立選項 strSQL = mySQL.getAllSelections(strQID); DataSet dsSelection = sqldb.getDataSet(strSQL); if (dsSelection.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsSelection.Tables[0].Rows.Count; j++) { //Seq string strSeq = ""; strSeq = dsSelection.Tables[0].Rows[j]["sSeq"].ToString(); //Selection string strSelection = ""; strSelection = dsSelection.Tables[0].Rows[j]["cSelection"].ToString(); //bCaseSelect bool bCaseSelect = false; bCaseSelect = Convert.ToBoolean(dsSelection.Tables[0].Rows[j]["bCaseSelect"]); TableRow trSelection = new TableRow(); table.Rows.Add(trSelection); //是否為建議選項 TableCell tcSuggest = new TableCell(); trSelection.Cells.Add(tcSuggest); HtmlImage imgSuggest = new HtmlImage(); tcSuggest.Controls.Add(imgSuggest); if (bCaseSelect == true) { imgSuggest.Src = "/Hints/Summary/Images/smiley4.gif"; } else { imgSuggest.Src = "/Hints/Summary/Images/smiley11.gif"; } //選項編號 // TableCell tcSelectionNum = new TableCell(); // trSelection.Cells.Add(tcSelectionNum); // tcSelectionNum.Text = Convert.ToString((j+1)) + "."; //選項內容 TableCell tcSelection = new TableCell(); trSelection.Cells.Add(tcSelection); tcSelection.Text = strSelection; //Empty TableCell // TableCell tcEmpty = new TableCell(); // trSelection.Cells.Add(tcEmpty); //建立選項的CSS if ((Convert.ToInt32(strSeq) % 2) != 0) { trSelection.Attributes.Add("Class", "header1_tr_odd_row"); } else { trSelection.Attributes.Add("Class", "header1_tr_even_row"); } } } else { //此問題沒有選項 } dsSelection.Dispose(); //Modify and Delete 按鈕的TableRow TableRow trModify = new TableRow(); table.Rows.Add(trModify); //建立修改問題的Button TableCell tcModify = new TableCell(); trModify.Cells.Add(tcModify); tcModify.Attributes["align"] = "right"; tcModify.ColumnSpan = 2; //問題的分數 Label lbQuestionGrade = new Label(); tcModify.Controls.Add(lbQuestionGrade); string strQuestionGrade = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_SELECT_Grade(strQID); if (strQuestionGrade != "-1") { lbQuestionGrade.Text = "Question Grade:" + strQuestionGrade + " "; } //問題的難易度 Label lbQuestionLevel = new Label(); tcModify.Controls.Add(lbQuestionLevel); int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelValue(strQID); if (iQuestionLevel != -1) { lbQuestionLevel.Text = "Question Level:" + AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_LevelName(iQuestionLevel) + " "; } Button btnModifySelection = new Button(); tcModify.Controls.Add(btnModifySelection); btnModifySelection.ID = "btnModifySelection-" + strQID; btnModifySelection.Text = "Modify"; btnModifySelection.Click += new EventHandler(btnModifySelection_Click); btnModifySelection.Style["width"] = "150px"; //建立間隔 Label lblCell = new Label(); tcModify.Controls.Add(lblCell); lblCell.Text = " "; Button btnDeleteSelection = new Button(); tcModify.Controls.Add(btnDeleteSelection); btnDeleteSelection.ID = "btnDeleteSelection-" + strQID; btnDeleteSelection.Text = "Delete"; btnDeleteSelection.Click += new EventHandler(btnDeleteSelection_Click); btnDeleteSelection.Style["width"] = "150px"; //建立Space TableRow trSpace = new TableRow(); trSpace.Style.Add("background-color", "#EBECED"); table.Rows.Add(trSpace); TableCell tcSpace = new TableCell(); tcSpace.ColumnSpan = 2; tcSpace.Style.Add("height", "7px"); trSpace.Cells.Add(tcSpace); } else { //此問題沒有選項 } dsQuestion.Dispose(); } } else { //此問卷沒有任何選擇題的情況 trQuestionTable.Style["display"] = "none"; } dsQuestionList.Dispose(); }