/// <summary> /// ��������б� /// </summary> public List<LearnSite.Model.Result> DataTableToList(DataTable dt) { List<LearnSite.Model.Result> modelList = new List<LearnSite.Model.Result>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.Result model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.Result(); if(dt.Rows[n]["Rid"].ToString()!="") { model.Rid=int.Parse(dt.Rows[n]["Rid"].ToString()); } model.Rnum=dt.Rows[n]["Rnum"].ToString(); if(dt.Rows[n]["Rscore"].ToString()!="") { model.Rscore=int.Parse(dt.Rows[n]["Rscore"].ToString()); } if(dt.Rows[n]["Rdate"].ToString()!="") { model.Rdate=DateTime.Parse(dt.Rows[n]["Rdate"].ToString()); } modelList.Add(model); } } return modelList; }
private void ListQuiz() { string Rnum = cook.Snum; int Qgrade = cook.Sgrade; int Qclass = cook.Sclass; string myname = Server.UrlDecode(cook.Sname); LearnSite.BLL.QuizGrade qgbll = new LearnSite.BLL.QuizGrade(); isanswer = qgbll.GetQanswer(Qgrade, Qclass); if (Request.QueryString["Rid"] != null) { int Rid = Int32.Parse(Request.QueryString["Rid"].ToString()); LearnSite.BLL.Result rbll = new LearnSite.BLL.Result(); LearnSite.Model.Result rmodel = new LearnSite.Model.Result(); rmodel = rbll.GetModel(Rid); if (rmodel != null) { string mystr = rmodel.Rhistory; if (mystr != "") { WrongsStr = rmodel.Rwrong.Split(','); string[] qmystr = mystr.Split(','); LearnSite.BLL.Quiz bll = new LearnSite.BLL.Quiz(); GVQuiz.DataSource = bll.GetListByQidArray(qmystr); GVQuiz.DataBind(); Labeltitle.Text = " 〖" + myname + " 随机生成的" + rmodel.Rdate.Value.ToShortDateString() + "号历史记录试卷参考答案〗"; } } //显示本次测验试卷参考答案 } else { if (Session[Rnum + "quizQids"] != null) { WrongsStr = Session[Rnum + "quizWrong"].ToString().Split(',');//将错题号保存 string[] qstr = (string[])Session[Rnum + "quizQids"]; LearnSite.BLL.Quiz bll = new LearnSite.BLL.Quiz(); GVQuiz.DataSource = bll.GetListByQidArray(qstr); GVQuiz.DataBind(); // Labelmsg.Text = "所有题编号:" + Session[Rnum + "quizRightWrong"].ToString() + "<br/>正确题编号:" + Session[Rnum + "quizRight"].ToString() + "<br/>错误题编号:" + Session[Rnum + "quizWrong"].ToString(); } if (Session[Rnum + "quizrnd"] != null) { Labeltitle.Text = " 〖" + myname + " 随机生成的" + Session[Rnum + "quizrnd"].ToString() + "号试卷参考答案〗"; Session[Rnum + "quizrnd"] = null; } } }
protected void Btnquiz_Click(object sender, EventArgs e) { string strscore = Labelallscore.Text; if (strscore != "") { int Rscore = Int32.Parse(strscore); if (Rscore > 0) { string Rnum = Request.Cookies["StudentCookies"].Values["Snum"].ToString(); string odate = DateTime.Now.ToShortDateString(); DateTime Rdate = DateTime.Parse(odate); Labelmsg.Text = Rdate.ToString(); LearnSite.BLL.Result bll = new LearnSite.BLL.Result(); if (bll.ExistsBynumdate(Rnum, Rdate)) { Labelmsg.Text = "今天已经通过测验!"; } else { LearnSite.Model.Result model = new LearnSite.Model.Result(); model.Rdate = Rdate; model.Rnum = Rnum; model.Rscore = Rscore; bll.Add(model);//增加今天测验成绩记录 int Squiz = bll.GetAverage(Rnum);//计算获得该学号的测验成绩总平均值 LearnSite.BLL.Students stbll = new LearnSite.BLL.Students(); stbll.SetSquiz(Rnum, Squiz);//更新该学号的测验成绩 System.Threading.Thread.Sleep(1000); Labelmsg.Text = "测验成绩成功提交!"; PrintQids(); Btnquiz.Enabled = false; HLanswer.Enabled = true; HLanswer.Visible = true; } } else { Labelmsg.Text = "测验成绩为零!"; } } else { Labelmsg.Text = "请先进行测验!"; } }
/// <summary> /// 获得数据列表 /// </summary> public List <LearnSite.Model.Result> DataTableToList(DataTable dt) { List <LearnSite.Model.Result> modelList = new List <LearnSite.Model.Result>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.Result model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.Result(); if (dt.Rows[n]["Rid"].ToString() != "") { model.Rid = int.Parse(dt.Rows[n]["Rid"].ToString()); } model.Rnum = dt.Rows[n]["Rnum"].ToString(); if (dt.Rows[n]["Rscore"].ToString() != "") { model.Rscore = int.Parse(dt.Rows[n]["Rscore"].ToString()); } if (dt.Rows[n]["Rdate"].ToString() != "") { model.Rdate = DateTime.Parse(dt.Rows[n]["Rdate"].ToString()); } model.Rhistory = dt.Rows[n]["Rhistory"].ToString(); model.Rwrong = dt.Rows[n]["Rwrong"].ToString(); if (dt.Rows[n]["Rgrade"].ToString() != "") { model.Rgrade = int.Parse(dt.Rows[n]["Rgrade"].ToString()); } if (dt.Rows[n]["Rterm"].ToString() != "") { model.Rterm = int.Parse(dt.Rows[n]["Rterm"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LearnSite.Model.Result model) { dal.Update(model); }
/// <summary> /// 更新一条数据中的Rscore,Rhistory,Rwrong /// </summary> public bool UpdateToday(LearnSite.Model.Result model) { return(dal.UpdateToday(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LearnSite.Model.Result model) { return(dal.Add(model)); }
protected void Btnquiz_Click(object sender, EventArgs e) { finished(); string strscore = Labelallscore.Text; if (strscore != "") { int Rscore = Int32.Parse(strscore); if (Rscore > 0) { int Rsid = cook.Sid; string Rnum = cook.Snum; int Rgrade = cook.Sgrade; int Rterm = cook.ThisTerm; DateTime dt = DateTime.Now; string odate = dt.Year.ToString() + "-" + dt.Month.ToString() + "-" + dt.Day; DateTime Rdate = DateTime.Parse(odate); Labelmsg.Text = Rdate.ToString(); string Rwrong = ""; string Rhistory = ""; if (Session[Rnum + "quizRightWrong"] != null) { Rwrong = Session[Rnum + "quizWrong"].ToString(); Rhistory = Session[Rnum + "quizRightWrong"].ToString(); } LearnSite.Model.Result model = new LearnSite.Model.Result(); model.Rdate = Rdate; model.Rnum = Rnum; model.Rscore = Rscore; model.Rhistory = Rhistory; model.Rwrong = Rwrong; model.Rgrade = Rgrade; model.Rterm = Rterm; model.Rsid = Rsid; LearnSite.BLL.Students stbll = new LearnSite.BLL.Students(); LearnSite.BLL.Result bll = new LearnSite.BLL.Result(); if (bll.ExistsBynumdate(Rsid, Rdate)) { if (Session[Rnum + "quizrnd"] != null) { if (bll.UpdateToday(model)) { Labelmsg.Text = "你获得了更好的成绩,已经更新成功!"; PrintQids(); HLanswer.Enabled = true; HLanswer.Visible = true; } else { Labelmsg.Text = "你刚才的成绩比原来的差,不作更新,可以重新再测验!"; } } else { Response.Redirect("~/Student/myquiz.aspx", false);//查看过答案 } } else { bll.Add(model);//增加今天测验成绩记录 Labelmsg.Text = "测验成绩成功提交!"; PrintQids(); HLanswer.Enabled = true; HLanswer.Visible = true; } bll.GetAverage(Rsid, Rgrade, Rterm);//计算获得该学号的测验成绩总平均值,更新该学号的测验总成绩 Btnquiz.Enabled = false; } else { Labelmsg.Text = "测验成绩为零,提交无效!"; } } else { Labelmsg.Text = "请先进行测验!"; } }