📄 autoexercise.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
public partial class Students_autoexercise : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager1.RegisterAsyncPostBackControl(lbCourse);
if (!Page.IsPostBack)
{
//------------------------------------------------------------
//string strCheck = "exercise";
//if (Session["checkUser"].ToString() != strCheck.ToString())
//{
// Response.Redirect("login.aspx");
//}
//------------------------------------------------------------
(new ExamOnline.Exam()).bindListBox(lbCourse, "0");
}
}
protected void lbCourse_SelectedIndexChanged(object sender, EventArgs e)
{
string strStyleMess = "";
string cid = lbCourse.SelectedValue.ToString();
string strcmd = "select distinct s.sname,q.sid from styles s,questions q ";
strcmd += " where q.cid = '" + cid + "' and audit=1 and s.sid=q.sid order by q.sid asc";
(new ExamOnline.AutoExercise()).bindGV(gvSytles, strcmd);
//----------------------------------------------
//绑定后对gvSytles进行初始化
if (gvSytles.Rows.Count > 0)
{
for (int i = 0; i < gvSytles.Rows.Count; i++)
{
//----------------------------------------------------------------
//CheckBox cb = (CheckBox)gvSytles.Rows[i].FindControl("cbStyle");
DropDownList ddl = (DropDownList)gvSytles.Rows[i].FindControl("dblLevel");
TextBox tb = (TextBox)gvSytles.Rows[i].FindControl("tbNum");
//----------------------------------------------------
//初始化难度系数
string strCid = lbCourse.SelectedValue.ToString();
int intSid = Convert.ToInt32(gvSytles.Rows[i].Cells[2].Text);
int intQlevel = (new ExamOnline.AutoExercise()).getQlevel(strCid, intSid);
for (int jloop = 1; jloop <= intQlevel; jloop++)
{
ListItem li = new ListItem(jloop.ToString(), jloop.ToString());
ddl.Items.Add(li);
}
//------------------------------------------
//显示题量信息
int intQNum = (new ExamOnline.AutoExercise()).getQNum(strCid, intSid);
string strSName = (new ExamOnline.AutoExercise()).getStyleName(intSid);
strStyleMess += strSName + ":" + intQNum.ToString() + ";";
//----------------------------------------
//初始化时设置题型难度和题量的enable为false
ddl.Enabled = false;
ddl.BackColor = Color.LightGray;
tb.Enabled = false;
tb.BackColor = Color.LightGray;
}
lblStyleMess.Text = strStyleMess;
lblMessage.Text = String.Empty;
}
else
{
lblStyleMess.Text = "题量为空!";
lblMessage.Text = "该课程还未配置题型!";
}
//更新
UpdatePanel1.Update();
}
protected void cbStyle_CheckedChanged(object sender, EventArgs e)
{
int styleNum = 0;
for (int i = 0; i < gvSytles.Rows.Count; i++)
{
CheckBox cb = (CheckBox)gvSytles.Rows[i].FindControl("cbStyle");
DropDownList ddl = (DropDownList)gvSytles.Rows[i].FindControl("dblLevel");
TextBox tb = (TextBox)gvSytles.Rows[i].FindControl("tbNum");
if (cb.Checked == true)
{
ddl.Enabled = true;
ddl.BackColor = Color.White;
tb.Enabled = true;
tb.BackColor = Color.White;
styleNum += 1;
}
else
{
ddl.Enabled = false;
ddl.BackColor = Color.LightGray;
tb.Enabled = false;
tb.BackColor = Color.LightGray;
}
}
ViewState["styleNum"] = styleNum; //保存题型个数
}
protected void btnExercise_Click(object sender, EventArgs e)
{
string strPassMessage = "";
int styleNum = Convert.ToInt32(ViewState["styleNum"]);
if (lblMessage.Text == String.Empty)
{
if (styleNum != 0)
{
for (int i = 0; i < gvSytles.Rows.Count; i++)
{
CheckBox cb = (CheckBox)gvSytles.Rows[i].FindControl("cbStyle");
if (cb.Checked == true)
{
DropDownList ddl = (DropDownList)gvSytles.Rows[i].FindControl("dblLevel");
TextBox tb = (TextBox)gvSytles.Rows[i].FindControl("tbNum");
if (!ExamOnline.Common.regMatchNum(tb.Text.ToString()))
{
ExamOnline.Common.ShowMess("题型代号为【" + Convert.ToInt32(gvSytles.Rows[i].Cells[2].Text) + "】的题量范围请输入数字【0~999】");
return;
}
else //输入格式为正确的数字
{
string strCid = lbCourse.SelectedValue.ToString();
int intSid = Convert.ToInt32(gvSytles.Rows[i].Cells[2].Text);
int intQNum = (new ExamOnline.AutoExercise()).getQNum(strCid, intSid);
if (Convert.ToInt32(tb.Text) > intQNum)
{
ExamOnline.Common.ShowMess("题型代号为【"+intSid+"】的自定义题量超出题库题量!");
return;
}
else //所输入的题量也在题库的范围内
{
//TODO
if(strPassMessage == String.Empty)
strPassMessage = intSid.ToString() + "/" + Convert.ToInt32(ddl.SelectedValue) + "/" + tb.Text.ToString();
else
strPassMessage += "^" + intSid.ToString() + "/" + Convert.ToInt32(ddl.SelectedValue) + "/" + tb.Text.ToString();
}
}
}
}
Response.Redirect("autopage.aspx?PassMessage=" + strPassMessage + "&cid=" + lbCourse.SelectedValue.ToString());
}
else
{
ExamOnline.Common.ShowMess("你未配置组卷参数!");
return;
}
}
else
{
ExamOnline.Common.ShowMess("该课程还未配置题型!");
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -