急急急,希望高手尽快帮偶看看,在这里万分感谢!

leejelen 2009-03-11 09:02:18


发表于:2009-03-11 20:59:141楼 得分:0
C# code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class page_ExerciseOnline : System.Web.UI.Page
{

string[] Details = new string[10000];
string[] OptionA = new string[10000];
string[] OptionB = new string[10000];
string[] OptionC = new string[10000];
string[] OptionD = new string[10000];
string[] Answer = new string[10000];
string[] Result = new string[10000];
string[] CorrectResult = new string[100000];
string[] ChooseAnswer = new string[100000];
String StringB = null;

int Count = 0;
int k = 0;
int s = 0;
String title = null;

protected void Page_Load(object sender, EventArgs e)
{
//获取章节参数
if (Request.Params["Param"] != null)
{
Exercise exercise = new Exercise();
SqlDataReader dr = exercise.GetChapter(Request.Params["Param"].ToString());
Exercise exerciseRusultAdd = new Exercise();
int i = 0;
while (dr.Read())
{
Details[i] = dr["edetails"].ToString();
OptionA[i] = dr["optionA"].ToString();
OptionB[i] = dr["optionB"].ToString();
OptionC[i] = dr["optionC"].ToString();
OptionD[i] = dr["optionD"].ToString();
Answer[i] = dr["eanswer"].ToString();

i = i + 1;
Count++;
}

//判断页面是否是第一次生成
if (!IsPostBack)
{
if (Request.QueryString["id"] != null)
{
s = int.Parse(Request.QueryString["id"].ToString());
}
if (Request.QueryString["stringB"] != null)
{
ChooseAnswer[s - 1] = Request.QueryString["stringB"];
if (ChooseAnswer[s - 1].Equals(Answer[s - 1]))
{
exerciseRusultAdd.AddResult("正确", "");
}
else
{
exerciseRusultAdd.AddResult("错误", Answer[s - 1]);
}
}

}

if (s < Count)
{
Label_details.Text = Details[s];
RadioButtonList_option.Items[0].Text = OptionA[s];
RadioButtonList_option.Items[1].Text = OptionB[s];
RadioButtonList_option.Items[2].Text = OptionC[s];
RadioButtonList_option.Items[3].Text = OptionD[s];
}

else
{
Response.Write("<script>alert('" + "最后一题" + "');</script>");
Label_details.Text = Details[Count - 1];
RadioButtonList_option.Items[0].Text = OptionA[Count - 1];
RadioButtonList_option.Items[1].Text = OptionB[Count - 1];
RadioButtonList_option.Items[2].Text = OptionC[Count - 1];
RadioButtonList_option.Items[3].Text = OptionD[Count - 1];
}

}
title = Request.QueryString["Param"];
}

protected void ImageButton_next_Click(object sender, ImageClickEventArgs e)
{
if (Request.QueryString["id"] != null)
{
//int j = int.Parse(Request.QueryString["id"]);
StringB = RadioButtonList_option.SelectedValue.ToString();
}


if (Request.QueryString["id"] == null)
{
StringB = RadioButtonList_option.SelectedValue.ToString();
Response.Redirect("ExerciseOnline.aspx?Param=" + title + "&id=1" + "&stringB=" + StringB);
}

int id = int.Parse(Request.QueryString["id"]) + 1;

if (id >= Count)
{
id = Count;
}

Response.Redirect("ExerciseOnline.aspx?Param=" + title + "&id=" + id.ToString() + "&stringB=" + StringB);
}

protected void ImageButton_check_Click(object sender, ImageClickEventArgs e)
{
string[] Result = new string[100000];
int j = 0;

Exercise exerciseResult = new Exercise();
SqlDataReader dr = exerciseResult.GetRusult();
while (dr.Read())
{
Result[j] = dr["rorw"].ToString();
CorrectResult[j] = dr["acorrect"].ToString();
j++;
}

for (int k = 0; k < j; k++)
{
Label_result.Text += Result[k].ToString() + " " + CorrectResult[k].ToString();
}
}
}



...全文
85 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧