实例介绍
【实例简介】基于asp.net sql server开发的在线答题系统
本人学习时开发的一个简单的在线答题系统,采用Asp.Net开发,现在个大家分享交流希望给些宝贵意见!
开发工具:vs2005 或更高版本
数据库:SqlSevrer2005 或者更高版本
测试帐号:
管理员:admin 密码:123
学生: huangyang 密码:123
【实例截图】
【核心代码】
protected void Button1_Click(object sender, EventArgs e)
{
if (rbA.Checked == true || rbB.Checked == true || rbC.Checked == true || rbD.Checked == true || rbE.Checked == true)
{
int a = dvCQ.PageCount;
int b = dvCQ.PageIndex;
dvCQ.PageIndex = b 1;
string answer = "";
if (rbA.Checked == true)
{
answer = "A";
}
else if (rbB.Checked == true)
{
answer = "B";
}
else if (rbC.Checked == true)
{
answer = "C";
}
else if (rbD.Checked == true)
{
answer = "D";
}
else if (rbE.Checked == true)
{
answer = "E";
}
User user = Session["user"] as User;
UserAnswer ua = new UserAnswer();
ua.UAnswer = answer;
ua.U = user;
Subject sb = new Subject();
sb.SId = Convert.ToInt32(Request.QueryString["subId"]);
ua.S = sb;
Label lblRightAnswer = dvCQ.FindControl("lblRightAnswer") as Label;
ua.RightAnswer = lblRightAnswer.Text;
ChoiceQuestion cq = new ChoiceQuestion();
Label lblQid = dvCQ.FindControl("lblCQid") as Label;
cq.Qid = Convert.ToInt32(lblQid.Text);
ua.C = cq;
UserAnswerBLL uab = new UserAnswerBLL();
uab.addUserAnswer(ua);
rbA.Checked = false;
rbB.Checked = false;
rbC.Checked = false;
rbD.Checked = false;
rbE.Checked = false;
if (b==a-1)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('已经答完所有题目,请提交!')", true);
btnNext.Visible = false;
btnOk.Visible = true;
}
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请选择一个答案!')",true);
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
int times = Convert.ToInt32(ViewState["times"]);
times --;
ViewState.Add("times",times);
int a = times;
int b = a / 60;
int c = a % 60;
if (c.ToString().Length < 2)
{
lblTimes.Text = b ":" "0" c.ToString();
}
else
{
lblTimes.Text = b ":" c.ToString();
}
if (b == 0 && c == 0)
{
Timer1.Enabled = false;
ScoreBLL scb = new ScoreBLL();
User user = Session["user"] as User;
int uid = user.UId;
int sid = Convert.ToInt32(Request.QueryString["subId"]);
double score = scb.SelScore(sid, uid);
btnNext.Enabled = false;
Score scores = new Score();
scores.U = user;
Subject sub = new Subject();
sub.SId = Convert.ToInt32(Request.QueryString["subId"]);
scores.Sub = sub;
scores.Core = score.ToString();
scb.AddUserScore(scores);
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('你的答题时间已到!你的本次成绩为:" score "分')", true);
}
}
protected void btnOk_Click(object sender, EventArgs e)
{
ScoreBLL scb = new ScoreBLL();
User user = Session["user"] as User;
int uid = user.UId;
int sid = Convert.ToInt32(Request.QueryString["subId"]);
double score = scb.SelScore(sid,uid);
Timer1.Enabled = false;
Score scores = new Score();
scores.U = user;
Subject sub = new Subject();
sub.SId = Convert.ToInt32(Request.QueryString["subId"]);
scores.Sub = sub;
scores.Core = score.ToString();
scb.AddUserScore(scores);
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('你的本次成绩为:" score "分')", true);
}
}
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论