void btnHints_ServerClick(object sender, EventArgs e) { //Hints的問卷系統 //檢查此問卷是不是每個問題都有被回答 bool bEmptyCheck = true; //取出此問卷的選擇題內容 string strSQL = mySQLString.getPaperSelectionContent(strPaperID); DataSet dsQuestionCheck = sqldb.getDataSet(strSQL); if (dsQuestionCheck.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsQuestionCheck.Tables[0].Rows.Count; i++) { //取得QID string strQID = ""; try { strQID = dsQuestionCheck.Tables[0].Rows[i]["cQID"].ToString(); } catch { } try { if (Request.Form[strQID] == null) { int intEmptyIndex = i + 1; bEmptyCheck = false; //此問題沒有被選取,顯示警告視窗警告使用者。 string strScript = "<script language='javascript'>\n"; strScript += "AlertSelectionNull('" + intEmptyIndex + "');\n"; strScript += "</script>\n"; Page.RegisterStartupScript("AlertSelectionNull", strScript); } } catch { int intEmptyIndex = i + 1; bEmptyCheck = false; //此問題沒有被選取,顯示警告視窗警告使用者。 string strScript = "<script language='javascript'>\n"; strScript += "AlertSelectionNull('" + intEmptyIndex + "');\n"; strScript += "</script>\n"; Page.RegisterStartupScript("AlertSelectionNull", strScript); } } } dsQuestionCheck.Dispose(); //如果每一個問題都有被回答的話,則將每個問題的回答存入資料庫中 if (bEmptyCheck == true) { //建立FinishTime string strFinishTime = ""; try { strFinishTime = myReceiver.getNowTime(); } catch { } //辨識使用者是否有點選此問卷中的任何一個項目 bool bPaperCheck = false; //取出此問卷的選擇題內容 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 { } //StandardScore int intStandardScore = 0; try { intStandardScore = Convert.ToInt32(dsQuestionList.Tables[0].Rows[i]["sStandardScore"]); } catch { } //QuestionMode string strQuestionMode = ""; try { strQuestionMode = dsQuestionList.Tables[0].Rows[i]["cQuestionMode"].ToString(); } catch { } //Seq string strQuestionSeq = ""; try { strQuestionSeq = dsQuestionList.Tables[0].Rows[i]["sSeq"].ToString(); } catch { } //取得問題的SQL strSQL = mySQLString.getSingleQuestionInformation(strQID); DataSet dsQuestion = sqldb.getDataSet(strSQL); if (dsQuestion.Tables[0].Rows.Count > 0) { intQuestionIndex += 1; //問題的內容 string strQuestion = ""; try { strQuestion = dsQuestion.Tables[0].Rows[0]["cQuestion"].ToString(); } catch { } //Question Level string strQuestionLevel = ""; try { strQuestionLevel = dsQuestion.Tables[0].Rows[0]["sLevel"].ToString(); } catch { } //QuestionGroupID string strQuestionGroupID = ""; try { strQuestionGroupID = dsQuestion.Tables[0].Rows[0]["cQuestionGroupID"].ToString(); } catch { } //檢查此問題是不是有被點選 bool bQuestionSelect = false; 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++) { //SelectionID string strSelectionID = ""; try { strSelectionID = dsSelection.Tables[0].Rows[j]["cSelectionID"].ToString(); } catch { } //Seq string strSelectionSeq = ""; try { strSelectionSeq = 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 { } string strCaseSelect = "0"; if (bCaseSelect == false) { strCaseSelect = "0"; } else { strCaseSelect = "1"; } //SelectState string strSelectState = ""; bool bCheck = false; try { bCheck = ((RadioButton)(this.FindControl("Form1").FindControl("rb-" + strQID + "-" + strSelectionID))).Checked; } catch { } if (bCheck == true) { strSelectState = "1"; } else { strSelectState = "0"; } //如果使用者有點選則去比對是否有答對這一個題目 //判斷這一個選項使用者是否有答對 if (strCaseSelect == "0") { if (strCaseSelect == strSelectState) { //不是建議選項,但是使用者也沒有點選,所以不儲存至TempLog } else { //使用者有點選此項目 //將資料存入TempLog_PaperSelectionAnswer strSelectState = "1"; bQuestionSelect = true; bPaperCheck = true; //把資料存入TempLog_PaperSelectionAnswer mySQLString.SaveToTempLog_PaperSelectionAnswer(strPaperID, strStartTime, strUserID, strQID, strSelectionID, strSelectionSeq, strSelection, strCaseSelect); } } else { if (strCaseSelect != strSelectState) { //是建議選項,但是使用者沒有點選,所以SelectState = 2 //將資料存入TempLog_PaperSelectionAnswer strSelectState = "2"; } else { //是建議選項,使用者有點選,所以SelectState = 1 //將資料存入TempLog_PaperSelectionAnswer strSelectState = "1"; bQuestionSelect = true; bPaperCheck = true; //把資料存入TempLog_PaperSelectionAnswer mySQLString.SaveToTempLog_PaperSelectionAnswer(strPaperID, strStartTime, strUserID, strQID, strSelectionID, strSelectionSeq, strSelection, strCaseSelect); } } } } else { //此問題沒有選項 } dsSelection.Dispose(); if (bQuestionSelect == true) { //把資料存入TempLog_PaperSelectionQuestion mySQLString.SaveToTempLog_PaperSelectionQuestion(strPaperID, strStartTime, strUserID, strQID, strQuestionLevel, strQuestion); } } else { //此問題沒有選項 } dsQuestion.Dispose(); //如果使用者有點選此問卷鍾任何一個項目,則新增一筆資料至TempLog_PaperHeader if (bPaperCheck == true) { mySQLString.SaveToTempLog_PaperHeader(strPaperID, strStartTime, strUserID, hiddenOperationTime.Value, strFinishTime); } } } else { //此問卷沒有選擇題的情況 } dsQuestionList.Dispose(); //建立屬於此問卷的問答題 strSQL = mySQLString.getPaperTextContent(strPaperID); DataSet dsTextList = sqldb.getDataSet(strSQL); if (dsTextList.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsTextList.Tables[0].Rows.Count; i++) { //取得此問題的QID string strQID = ""; try { strQID = dsTextList.Tables[0].Rows[i]["cQID"].ToString(); } catch { } //Question number string strQuestionNum = "Q" + intQuestionIndex.ToString() + ": "; //Question string strQuestion = ""; try { strQuestion = dsTextList.Tables[0].Rows[i]["cQuestion"].ToString(); } catch { } //取得TextArea的內容 string strAnswer = ""; try { strAnswer = ((HtmlTextArea)(this.FindControl("Form1").FindControl("txt-" + strQID))).InnerText; } catch { } //StandardScore int intStandardScore = 0; try { intStandardScore = Convert.ToInt32(dsTextList.Tables[0].Rows[i]["sStandardScore"]); } catch { } //如果TextArea的內容不是空的話,則存入資料庫。 if (strAnswer.Length > 0) { bPaperCheck = true; //把資料存入TempLog_PaperText mySQLString.SaveToTempLog_PaperTextQuestion(strPaperID, strStartTime, strUserID, strQID, strQuestion, strAnswer); } } } else { //此問卷沒有問答題的情形 } dsTextList.Dispose(); //如果使用者有點選此問卷鍾任何一個項目,則新增一筆資料至TempLog_PaperHeader if (bPaperCheck == true) { mySQLString.SaveToTempLog_PaperHeader(strPaperID, strStartTime, strUserID, hiddenOperationTime.Value, strFinishTime); } //關閉網頁 string strScript = "<script language='javascript'>\n"; strScript += "closeWindow();\n"; strScript += "</script>\n"; Page.RegisterStartupScript("closeWindow", strScript); } else { //有問題沒有回答的情形 //phQuestion.Controls.Clear(); this.setupHintsQuestionTable(); } }