/// <summary> /// 获取问题总分和平均分 /// </summary> /// <param name="qid">问题ID</param> /// <param name="qtypeid">问题类型ID</param> /// <returns></returns> public string GetScore(int qid, int qtypeid) { double score = 0; M_Question QMod = new M_Question(); QMod = B_Survey.GetQuestion(Convert.ToInt32(qid)); string[] qConte = QMod.QuestionContent.Split('|'); string str = "select * from ZL_Answer where qid=" + qid; DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, str); for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < qConte.Length; j++) { if (!string.IsNullOrEmpty(qConte[j].Split(':').ToString()) && dt.Rows[i]["AnswerContent"].ToString() == qConte[j].Split(':')[0]) { score += Convert.ToDouble(qConte[j].Split(':')[1]); } } } return("总分:" + score.ToString() + " 平均分:" + score / dt.Rows.Count); }
public string CreateIframe(int qid) { M_Question QMod = new M_Question(); QMod = B_Survey.GetQuestion(Convert.ToInt32(qid)); string[] qConte = QMod.QuestionContent.Split('|'); string str = "select * from ZL_Answer where qid=" + qid; DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, str); string num = ""; string text = ""; for (int i = 0; i < qConte.Length; i++) { DataTable dt1; dt.DefaultView.RowFilter = "AnswerContent='" + qConte[i].Split(':')[0] + "'"; dt1 = dt.DefaultView.ToTable(); num += dt1.Rows.Count.ToString() + ","; text += qConte[i].Split(':')[0] + ","; } num = num.Trim(','); text = text.Trim(','); return(num + "|" + text); }