首页上一页 1 下一页尾页 1 条记录 1/1页
ASP.NET项目开发案例全程实录(第二版)第七章在线考试系统
发表在ASP.NET图书答疑
2012-04-24
是否精华
是
否
版块置顶:
是
否
case 2:
SqlDataAdapter myadapter2 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='多选题'and que_lessonid='"
+ dd1 + "'and que_taotiid='" + dd2 + "'order by id desc", con);
DataSet myds2 = new DataSet();
myadapter2.Fill(myds2);
DataList2.DataSource = myds2;
DataList2.DataBind();
//生成多选题题号
for (int tID2 = 1; tID2 <= DataList2.Items.Count; tID2++)
{
Label lblDSelect = (Label)DataList2.Items[tID2 - 1].FindControl("Label24");
lblDSelect.Text = tID2.ToString() + "、";
}
break;
//核对单选题答案
case 3:
SqlDataAdapter myadapter3 = new SqlDataAdapter("select id,que_answer"
+ " from tb_Questions where que_type='单选题'and que_lessonid="
+ dd1 + " and que_taotiid=" + dd2 + " order by id desc", con);
DataSet myds3 = new DataSet();
myadapter3.Fill(myds3);
DataRow[] row1 = myds3.Tables[0].Select();
//计算单选题成绩
foreach (DataRow answer1 in row1)
{
int_row1 += 1;
if (int_row1<= 3)
{
RadioButtonList rbl = (RadioButtonList)(DataList1.Items[int_row1 - 1].FindControl("RadioButtonList1"));
if (rbl.SelectedValue == "")
{
this.lblSel.Text = "0";
}
else
{
if (answer1["que_answer"].ToString().Trim() == rbl.SelectedValue.ToString().Trim())
{
int_row1Point += 40 / DataList1.Items.Count;
this.lblSel.Text = int_row1Point.ToString();
}
}
}
}
break;
//核对多选题答案
case 4:
SqlDataAdapter myadapter4 = new SqlDataAdapter("select id,que_answer"
+ " from tb_Questions where que_type='多选题'and que_lessonid="
+ dd1 + " and que_taotiid=" + dd2 + " order by id desc", con);
DataSet myds4 = new DataSet();
myadapter4.Fill(myds4);
DataRow[] row2 = myds4.Tables[0].Select();
//计算多选题成绩
foreach (DataRow answer2 in row2)
{
int_row2 += 1;
if (int_row2 <= 3)
{
CheckBoxList cbl = (CheckBoxList)(DataList2.Items[int_row2 - 1].FindControl("CheckBoxList1"));
if (cbl.SelectedValue == "")
{
lblDSel.Text = "0";
}
else
{
this.TextBox1.Text = "";
for (int q = 0; q < cbl.Items.Count; q++)
{
if (cbl.Items[q].Selected == true)
{
this.TextBox1.Text = TextBox1.Text.Trim() + cbl.Items[q].Value + ", ";
}
}
if (answer2["que_answer"].ToString().Trim() + "," == this.TextBox1.Text.Trim())
{
int_row2Point += 60 / DataList2.Items.Count;
this.lblDSel.Text = int_row2Point.ToString();
}
}
}
}
break;
这段考试的代码什么意思,我要最具体详细的解释啊,int_row1<= 3为什么要小于3,4、5、6不行吗?这个是不是就是单选最多的题目数。要很详细的注释包括每一行什么意思。
考生只能考一次这个问题。应该能考很多门课程,这个怎么改string sqlstr1 = "select count(*) from tb_StuResult where stu_id ='" + Session["StuName"] + "' and which_lesson='" + this.ddlSelLess.SelectedItem.Text + "'";(选择套题那页面)我改成这样,还是错,说没有引用实例什么的。我要具体代码和页面,知道这么改,我就是不知道代码。
哪个高手会,发我邮箱也行,谢谢了
SqlDataAdapter myadapter2 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='多选题'and que_lessonid='"
+ dd1 + "'and que_taotiid='" + dd2 + "'order by id desc", con);
DataSet myds2 = new DataSet();
myadapter2.Fill(myds2);
DataList2.DataSource = myds2;
DataList2.DataBind();
//生成多选题题号
for (int tID2 = 1; tID2 <= DataList2.Items.Count; tID2++)
{
Label lblDSelect = (Label)DataList2.Items[tID2 - 1].FindControl("Label24");
lblDSelect.Text = tID2.ToString() + "、";
}
break;
//核对单选题答案
case 3:
SqlDataAdapter myadapter3 = new SqlDataAdapter("select id,que_answer"
+ " from tb_Questions where que_type='单选题'and que_lessonid="
+ dd1 + " and que_taotiid=" + dd2 + " order by id desc", con);
DataSet myds3 = new DataSet();
myadapter3.Fill(myds3);
DataRow[] row1 = myds3.Tables[0].Select();
//计算单选题成绩
foreach (DataRow answer1 in row1)
{
int_row1 += 1;
if (int_row1<= 3)
{
RadioButtonList rbl = (RadioButtonList)(DataList1.Items[int_row1 - 1].FindControl("RadioButtonList1"));
if (rbl.SelectedValue == "")
{
this.lblSel.Text = "0";
}
else
{
if (answer1["que_answer"].ToString().Trim() == rbl.SelectedValue.ToString().Trim())
{
int_row1Point += 40 / DataList1.Items.Count;
this.lblSel.Text = int_row1Point.ToString();
}
}
}
}
break;
//核对多选题答案
case 4:
SqlDataAdapter myadapter4 = new SqlDataAdapter("select id,que_answer"
+ " from tb_Questions where que_type='多选题'and que_lessonid="
+ dd1 + " and que_taotiid=" + dd2 + " order by id desc", con);
DataSet myds4 = new DataSet();
myadapter4.Fill(myds4);
DataRow[] row2 = myds4.Tables[0].Select();
//计算多选题成绩
foreach (DataRow answer2 in row2)
{
int_row2 += 1;
if (int_row2 <= 3)
{
CheckBoxList cbl = (CheckBoxList)(DataList2.Items[int_row2 - 1].FindControl("CheckBoxList1"));
if (cbl.SelectedValue == "")
{
lblDSel.Text = "0";
}
else
{
this.TextBox1.Text = "";
for (int q = 0; q < cbl.Items.Count; q++)
{
if (cbl.Items[q].Selected == true)
{
this.TextBox1.Text = TextBox1.Text.Trim() + cbl.Items[q].Value + ", ";
}
}
if (answer2["que_answer"].ToString().Trim() + "," == this.TextBox1.Text.Trim())
{
int_row2Point += 60 / DataList2.Items.Count;
this.lblDSel.Text = int_row2Point.ToString();
}
}
}
}
break;
这段考试的代码什么意思,我要最具体详细的解释啊,int_row1<= 3为什么要小于3,4、5、6不行吗?这个是不是就是单选最多的题目数。要很详细的注释包括每一行什么意思。
考生只能考一次这个问题。应该能考很多门课程,这个怎么改string sqlstr1 = "select count(*) from tb_StuResult where stu_id ='" + Session["StuName"] + "' and which_lesson='" + this.ddlSelLess.SelectedItem.Text + "'";(选择套题那页面)我改成这样,还是错,说没有引用实例什么的。我要具体代码和页面,知道这么改,我就是不知道代码。
哪个高手会,发我邮箱也行,谢谢了