/// <summary> /// 傳回Paper_RandomNum的組別問題數目表格(不做動作) /// </summary> private Table setupQuestionNumTable(string strPaperID) { Table table = new Table(); table.Attributes.Add("Class", "TableName"); table.Style.Add("WIDTH", "100%"); table.CellSpacing = 0; table.CellPadding = 2; table.BorderWidth = Unit.Pixel(1); table.BorderStyle = BorderStyle.Solid; table.BorderColor = System.Drawing.Color.Black; SQLString mySQL = new SQLString(); DataReceiver myReceiver = new DataReceiver(); //從Paper_RandomQuestionNum取出此問卷的資料 SqlDB sqldb = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]); string strSQL = mySQL.getPaper_RandomQuestionNum(strPaperID); DataSet dsQuestionNum = sqldb.getDataSet(strSQL); if (dsQuestionNum.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsQuestionNum.Tables[0].Rows.Count; i++) { //設定Table的Style string strStyle = "header1_tr_odd_row"; if ((i % 2) != 0) { strStyle = "header1_tr_odd_row"; } else { strStyle = "header1_tr_even_row"; } TableRow tr = new TableRow(); tr.CssClass = strStyle; table.Rows.Add(tr); //get GroupID string strGroupID = ""; try { strGroupID = dsQuestionNum.Tables[0].Rows[i]["cQuestionGroupID"].ToString(); } catch { } //get Question number int intQuestionNum = 0; try { intQuestionNum = Convert.ToInt32(dsQuestionNum.Tables[0].Rows[i]["sQuestionNum"]); } catch { } //get 此組別全部的問題數目 int intQuestionCount = 0; if (strGroupID == "Specific") { strSQL = mySQL.getSpecificSelectionQuestion(strPaperID); } else { strSQL = mySQL.getGroupSelectionQuestion(strGroupID); } DataSet dsQuestionCount = sqldb.getDataSet(strSQL); try { intQuestionCount = dsQuestionCount.Tables[0].Rows.Count; } catch { } dsQuestionCount.Dispose(); //組別名稱 TableCell tcGroupName = new TableCell(); tr.Cells.Add(tcGroupName); string strGroupName = ""; if (strGroupID == "Specific") { strGroupName = "Specific questions"; } else { strGroupName = mySQL.getQuestionGroupName(strGroupID); } tcGroupName.Text = strGroupName; //問題個數 TableCell tcQuestionNum = new TableCell(); tr.Cells.Add(tcQuestionNum); TextBox txtQuestionNum = new TextBox(); tcQuestionNum.Controls.Add(txtQuestionNum); txtQuestionNum.ID = "txt" + strGroupID; txtQuestionNum.Text = intQuestionNum.ToString(); //此組別的問題總數 TableCell tcQuestionCount = new TableCell(); tr.Cells.Add(tcQuestionCount); tcQuestionCount.Text = intQuestionCount.ToString(); tcQuestionCount.Attributes.Add("Align", "Center"); //建立Title的TextArea TableRow trQuestionTitle = new TableRow(); table.Rows.Add(trQuestionTitle); TableCell tcTitle = new TableCell(); trQuestionTitle.Cells.Add(tcTitle); tcTitle.Attributes.Add("align", "right"); tcTitle.ColumnSpan = 3; //建立Question title的TextArea HtmlTextArea txtTitle = new HtmlTextArea(); tcTitle.Controls.Add(txtTitle); txtTitle.ID = "txtTitle" + strGroupID; txtTitle.Style.Add("WIDTH", "100%"); txtTitle.Rows = 5; txtTitle.Style.Add("DISPLAY", "none"); //取出此QuestionTitle的內容 txtTitle.InnerText = myReceiver.getQuestionTitle(strPaperID, strGroupID); //建立Question title button HtmlInputButton btnTitle = new HtmlInputButton("button"); tcTitle.Controls.Add(btnTitle); btnTitle.ID = "btnTitle" + strGroupID; btnTitle.Value = "Add a question title"; btnTitle.Attributes.Add("onclick", "showQuestionTitle('" + strGroupID + "')"); //建立間隔 Label lblCell0 = new Label(); lblCell0.Style.Add("WIDTH", "20px"); tcTitle.Controls.Add(lblCell0); //建立Empty row if (i < dsQuestionNum.Tables[0].Rows.Count - 1) { TableRow trEmpty = new TableRow(); table.Rows.Add(trEmpty); trEmpty.BackColor = System.Drawing.Color.White; TableCell tcEmpty1 = new TableCell(); trEmpty.Cells.Add(tcEmpty1); tcEmpty1.Style.Add("Height", "10px"); tcEmpty1.ColumnSpan = 3; } } //加入Table的Title TableRow trTitle = new TableRow(); table.Rows.AddAt(0, trTitle); trTitle.Attributes.Add("Class", "header1_table_first_row"); TableCell tcGroupTitle = new TableCell(); trTitle.Cells.Add(tcGroupTitle); tcGroupTitle.Text = "Question topic"; TableCell tcQuestionTitle = new TableCell(); trTitle.Cells.Add(tcQuestionTitle); tcQuestionTitle.Text = "Selected questions number"; TableCell tcQuestionCountTitle = new TableCell(); trTitle.Cells.Add(tcQuestionCountTitle); tcQuestionCountTitle.Text = "Maximum questions count"; } else { //沒有資料 } dsQuestionNum.Dispose(); return(table); }
/* * public string[] getRandomQIDArray(string strPaperID , int intQuestionNum) * { * ///亂數取得某一個問題組別中的問題 * * //傳回的陣列 * string[] arrayQID = new String[intQuestionNum]; * int intArrayIndex = 0;//代表arrayQID的指標 * * //取得Paper_Grouping的資料 * string strSQL = "SELECT * FROM Paper_GroupingQuestion WHERE cPaperID = '"+strPaperID+"' "; * DataSet dsGroup = sqldb.getDataSet(strSQL); * if(dsGroup.Tables[0].Rows.Count > 0) * { * for(int i=0 ; i<dsGroup.Tables[0].Rows.Count ; i++) * { * //針對每一個組別找出屬於此分組的題目 * * //QuestionGroupID * string strGroupID = ""; * try * { * strGroupID = dsGroup.Tables[0].Rows[i]["cGroupID"].ToString(); * } * catch * { * } * * //Question number * int intGroupQuestionNum = 0; * try * { * intGroupQuestionNum = Convert.ToInt32(dsGroup.Tables[0].Rows[i]["sQuestionNum"]); * } * catch * { * } * * //GroupDivision * string strDivisionID = ""; * try * { * strDivisionID = dsGroup.Tables[0].Rows[i]["cDivisionID"].ToString(); * } * catch * { * } * * //取得屬於該組別並且尚未被引用的問題集合 * strSQL = mySQL.getGroupQuestionLevel1NotSelect(strGroupID , strPaperID); * DataSet dsQuestionList = sqldb.getDataSet(strSQL); * * //亂數選取問題後存入Array中 * //檢查intQuestionNum是否大於QuestionList中的題目數量 * if(intGroupQuestionNum <= dsQuestionList.Tables[0].Rows.Count) * { * for(int j=0 ; j<intGroupQuestionNum ; j++) * { * //亂數取得一個介於0~RowCount之間的數字 * int intRandom = 0; * string strQID = ""; * do * { * intRandom = myRandom.Next(0,dsQuestionList.Tables[0].Rows.Count); * strQID = dsQuestionList.Tables[0].Rows[intRandom]["cQID"].ToString(); * } * while(checkArray(strQID , arrayQID)); * * //將此QID存入Array中 * arrayQID[intArrayIndex] = strQID; * intArrayIndex += 1; * } * } * else * { * //把所有的題目都挑選進Array來 * for(int j=0 ; j<dsQuestionList.Tables[0].Rows.Count ; j++) * { * arrayQID[j] = dsQuestionList.Tables[0].Rows[j]["cQID"].ToString(); * } * } * dsQuestionList.Dispose(); * } * } * dsGroup.Dispose(); * * return arrayQID; * } */ public string[] getRandomQIDArray(string strPaperID) { ///亂數取得某一個問題組別中的問題 //取得此問卷所有需要亂數取得的問題總數 int intQuestionSum = 0; intQuestionSum = myReceiver.getTotalQuestionNumFromRandomQuestion(strPaperID); //傳回的陣列 string[] arrayQID = new String[intQuestionSum]; int intArrayIndex = 0; //代表arrayQID的指標 //取得Paper_RandomQuestionNum的資料 string strSQL = mySQL.getPaper_RandomQuestionNum(strPaperID); DataSet dsGroupNum = sqldb.getDataSet(strSQL); if (dsGroupNum.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsGroupNum.Tables[0].Rows.Count; i++) { //get GroupID string strGroupID = ""; try { strGroupID = dsGroupNum.Tables[0].Rows[i]["cQuestionGroupID"].ToString(); } catch { } //get Question number int intQuestionNum = 0; try { intQuestionNum = Convert.ToInt32(dsGroupNum.Tables[0].Rows[i]["sQuestionNum"]); } catch { } //取得此問題組別的所有Level 1問題 if (strGroupID == "Specific") { strSQL = mySQL.getSpecificSelectionQuestion(strPaperID); } else { strSQL = mySQL.getGroupSelectionQuestion(strGroupID); } DataSet dsQuestionList = sqldb.getDataSet(strSQL); if (dsQuestionList.Tables[0].Rows.Count > 0) { //檢查intQuestionNum是否大於QuestionList中的題目數量 if (intQuestionNum <= dsQuestionList.Tables[0].Rows.Count) { //亂數選取問題後存入Array中 for (int j = 0; j < intQuestionNum; j++) { //亂數取得一個介於0~RowCount之間的數字 int intRandom = 0; string strQID = ""; do { intRandom = myRandom.Next(0, dsQuestionList.Tables[0].Rows.Count); strQID = dsQuestionList.Tables[0].Rows[intRandom]["cQID"].ToString(); }while(checkArray(strQID, arrayQID)); //將此QID存入Array中 arrayQID[intArrayIndex] = strQID; intArrayIndex += 1; } } else { //把所有的題目都挑選進Array來 for (int j = 0; j < dsQuestionList.Tables[0].Rows.Count; j++) { arrayQID[j] = dsQuestionList.Tables[0].Rows[j]["cQID"].ToString(); } } } else { //找不到此問題組別的資料 } dsQuestionList.Dispose(); } } else { //在Paper_RandomQuestion找不到資料 } dsGroupNum.Dispose(); return(arrayQID); }
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(); }