Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Labelbanji.Text = BanjiInfo.GetBanjiName(int.Parse(Request.QueryString["banjiid"]));
     }
 }
Ejemplo n.º 2
0
    protected void BindBanjiStudent()
    {
        string    banjiid = ListBoxbj.SelectedValue;
        DataTable dt      = BanjiInfo.GetStudentNameAndUsername(int.Parse(banjiid));

        ListBox1.DataSource = dt;
        ListBox1.DataBind();
    }
    protected void BindBanji()
    {
        int    kechengid = int.Parse(Session["kechengid"].ToString());
        string tu        = ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name;

        DropDownListbj.DataSource = BanjiInfo.GetTeacherRenkeBanji(tu, kechengid);
        DropDownListbj.DataBind();
    }
    protected void BindStu()
    {
        string banjiid = ListBoxbanji.SelectedValue;
        //绑定学生信息
        DataTable studt = BanjiInfo.GetStudentNameAndUsername(int.Parse(banjiid));

        ListBoxstu.DataSource = studt;
        ListBoxstu.DataBind();
    }
    protected void BindBanji()
    {
        string  tun       = ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name;
        string  kechengid = Session["kechengid"].ToString();
        DataSet banjidt   = BanjiInfo.GetTeacherRenkeBanji(tun, int.Parse(kechengid));

        ListBoxbanji.DataSource = banjidt;
        ListBoxbanji.DataBind();
    }
    protected void BindBanji()
    {
        string  kechengid = Session["kechengid"].ToString();
        string  username  = ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name;
        DataSet ds        = BanjiInfo.GetTeacherRenkeBanji(username, int.Parse(kechengid));

        DropDownList_banji.DataSource = ds;
        DropDownList_banji.DataBind();
    }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string banjiid = Request.QueryString["banjiid"];
         Labelbanji.Text = BanjiInfo.GetBanjiName(int.Parse(banjiid));
         BindCeshiChengjiHuizong();
     }
 }
Ejemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Labelstuusername.Text = Request.QueryString["studentusername"];
         Labelbanji.Text       = BanjiInfo.GetBanjiName(int.Parse(Request.QueryString["banjiid"]));
         Labelxingming.Text    = StudentInfo.GetStuXingming(Request.QueryString["studentusername"]);
         BindZyoye();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Labelbanji.Text     = BanjiInfo.GetBanjiName(int.Parse(Request.QueryString["banjiid"]));
         Labelzuoyename.Text = ZuoyeInfo.getZuoyeName(int.Parse(Request.QueryString["zuoyeid"]));
         DataTable studt = BanjiInfo.GetStudentNameAndUsername(int.Parse(Request.QueryString["banjiid"]));
         ListBox1.DataSource = studt;
         ListBox1.DataBind();
     }
 }
Ejemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string banjiid = Request.QueryString["banjiid"];
         string stuun   = Request.QueryString["studentusername"];
         Labelbj.Text    = BanjiInfo.GetBanjiName(int.Parse(banjiid));
         Labelxm.Text    = StudentInfo.GetStuXingming(stuun);
         Labelstuun.Text = stuun;
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        string kechengid = Session["kechengid"].ToString();
        string banjiid   = Request.QueryString["banjiid"];
        string stuun     = Request.QueryString["studentusername"];

        Labelkc.Text = KechengInfo.getKechengname(kechengid);
        Labelbj.Text = BanjiInfo.GetBanjiName(int.Parse(banjiid));
        Labelxm.Text = StudentInfo.GetStuXingming(stuun);
        Labelun.Text = stuun;
        BindDianMingStu();
    }
Ejemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string banjiid   = Request.QueryString["banjiid"];
         string kechengid = Session["kechengid"].ToString();
         Labelbj.Text = BanjiInfo.GetBanjiName(int.Parse(banjiid));
         string stuusername = Request.QueryString["studentusername"];
         Labelxm.Text    = StudentInfo.GetStuXingming(stuusername);
         Labelstuun.Text = stuusername;
         BindStuCeshiInfo();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["zuoyeid"] != null && Request.QueryString["banjiid"] != null)
         {
             Labelbanji.Text     = BanjiInfo.GetBanjiName(int.Parse(Request.QueryString["banjiid"]));
             Labelzuoyename.Text = ZuoyeInfo.getZuoyeName(int.Parse(Request.QueryString["zuoyeid"]));
             DataTable dt = ZuoyeInfo.GetQuantiStuZuoyeXinxi(int.Parse(Request.QueryString["banjiid"]), int.Parse(Request.QueryString["zuoyeid"]));
             GridView1.DataSource = dt;
             GridView1.DataBind();
         }
         else
         {
             Response.Redirect("default.aspx");
         }
     }
 }
Ejemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["zuoyeid"] != null && Request.QueryString["banjiid"] != null)
         {
             Labelbanji.Text     = BanjiInfo.GetBanjiName(int.Parse(Request.QueryString["banjiid"]));
             Labelzuoyename.Text = ZuoyeInfo.getZuoyeName(int.Parse(Request.QueryString["zuoyeid"]));
             BindFenxi();
             BindTimu();
             Labelsjrs.Text = ZuoyeInfo.GetZuoyeShangjiaoRenShu(int.Parse(Request.QueryString["zuoyeid"]), int.Parse(Request.QueryString["banjiid"])).ToString();
         }
         else
         {
             Response.Redirect("default.aspx");
         }
     }
 }
    protected void BindBanji()//绑定任课班级
    {
        int           kechengid;
        string        zuoyeid = Request.QueryString["zuoyeid"];
        SqlConnection conn    = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();

        comm.CommandText = "select kechengid from teacherzuoye where zuoyeid=" + zuoyeid;
        conn.Open();
        kechengid = (int)(comm.ExecuteScalar());
        conn.Close();
        DataSet ds = BanjiInfo.GetTeacherRenkeBanji(((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name, kechengid);

        DropDownList1.DataSource     = ds;
        DropDownList1.DataTextField  = "banjiname";
        DropDownList1.DataValueField = "banjiid";
        DropDownList1.DataBind();
    }
    protected void StartNextButton_Click(object sender, EventArgs e)//验证是否有班级、题目,如果有,则跳转到下一步
    {
        //查询相关知识点、课程有无任课班级、题目
        bool   banjicunzai = false;
        bool   timucunzai  = false;
        string kechengid   = Session["kechengid"].ToString();
        string username    = ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name;
        string kechengname = KechengInfo.getKechengname(kechengid);
        //查询是否有班级
        DataSet ds = BanjiInfo.GetTeacherRenkeBanji(username, int.Parse(kechengid));

        if (ds.Tables[0].Rows.Count > 0)
        {
            banjicunzai = true;
        }
        if (!banjicunzai)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(String), "", "<script language='javascript'>alert('没有找到您任教课程" + kechengname + "的班级,请选择其他班级!');</script>", false);
            return;
        }
        //查询是否有题目
        //显示每种题型的数量,选择数量,分值
        //获取选择的知识点及其下位知识点
        List <string> nodeandchilren    = TreeView1.CheckedNodesAndChildrenIds;// 选择的知识点及其子孙知识点id
        StringBuilder nodeandchildrenSB = new StringBuilder();
        //从题库中查询符合条件的题目
        SqlConnection conn = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();
        //建立临时表,记录选择的知识点id号
        string temptablename = "#temptable" + username + DateTime.Now.Ticks.ToString();

        comm.CommandText = "create table " + temptablename + "(id int)";
        conn.Open();
        comm.ExecuteNonQuery();
        foreach (string nodeid in nodeandchilren)
        {
            nodeandchildrenSB.Append(nodeid + ",");
            comm.CommandText = "insert into " + temptablename + "(id) values(" + int.Parse(nodeid) + ")";
            comm.ExecuteNonQuery();
        }
        //查询符合条件的第一题
        comm.CommandText = "select top 1 questionid from tb_tiku where questionid in( select questionid from tb_timuzhishidian where questionid not in ( select questionid from tb_timuzhishidian where kechengjiegouid not in (select id from " + temptablename + ")))";
        SqlDataReader sdr = comm.ExecuteReader();

        if (sdr.HasRows)
        {
            timucunzai = true;
        }
        sdr.Close();
        conn.Close();
        HiddenFieldnodeandchildren.Value = nodeandchildrenSB.ToString();//把选择的知识点及其下位知识点保存在hiddenfield中,以便以后使用
        if (!timucunzai)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(String), "", "<script language='javascript'>alert('没有找到您选择的知识点的题目,请选择其他知识点!');</script>", false);
        }
        if (banjicunzai && timucunzai)
        {
            Wizard1.ActiveStepIndex = 1;
        }
    }
Ejemplo n.º 17
0
    protected void Button2_Click(object sender, EventArgs e)//生成试卷
    {
        //检查测试名称是否可用
        //bool chenggong = true;
        int i, j;
        int shijuanid = 0;//新试卷id
        //string sqltxt="";
        string kechengid       = Session["kechengid"].ToString();
        string username        = ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name;
        string ceshiname       = tbx_ceshiname.Text.Trim();   //测试名称
        string xianzhiip       = Rbl_xianzhiip.SelectedValue; //是否限制IP
        string ceshizhishidian = lbl_zhishidian.Text;

        if (CheckCeshiName(int.Parse(kechengid), ceshiname, username))//检查测试名称是否可用
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('您的该课程的该试卷名称已使用,请选择其它名称。');</script>", false);
            return;
        }
        //创建新测试
        string zujuanfangshi = lbl_mingtifangshi.Text.Trim();
        string ceshibanji    = ddl_banji.SelectedItem.Text;           //班级名称
        string banjiid       = ddl_banji.SelectedValue;               //班级ID
        string xuantifangshi = lbl_mingtifangshi.Text.Trim();         //选题方式,两种+1zhong
        int    ceshishichang = int.Parse(Ddl_fenzhong.SelectedValue); //测试时长,分钟
        string shifouyunxu   = Rbl_yunxuceshi.SelectedValue;          //是否允许做题
        string yunxuchakan   = Rbl_yunxuchakan.SelectedValue;         //是否允许查看测试结果
        string oldshijuanid  = Request.QueryString["shijuanid"];      //原试卷id
        //DataTable dt = CeshiInfo.GetCeshiTimu(int.Parse(Request.QueryString["shijuanid"]));//原试卷中的题目
        DataTable stu             = BanjiInfo.GetStudent(int.Parse(banjiid));
        DataTable tixingshuliang  = new DataTable();              //题型及数量
        DataTable timu_fenzhi     = new DataTable();              //题目及分值
        DataTable Bxtimu          = GetBeixuanTimu(oldshijuanid); //备选题目
        int       bxtimuzongshu   = Bxtimu.Rows.Count;            //备选题目总数
        int       yixuantimushu   = 0;                            //已选题目数
        int       kexuantimushu   = 0;                            //可选题目数
        int       yingxuantimushu = 0;                            //应选题目数
        //DataTable tixing=
        SqlConnection conn = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm            = conn.CreateCommand();
        List <int> tihaolist       = new List <int>(); //可选题目在备选题目中的索引
        List <int> xuanzetihaolist = new List <int>(); //选择的题号列表
        int        xuanzetihao;                        //选择题号

        Random rand;

        //统计各题型题目数量\分值和出现过的题目,为随机组卷做准备
        if (zujuanfangshi == "全体学生不同")
        {
            tixingshuliang = GetShijuanTixing(oldshijuanid, stu.Rows[0]["username"].ToString());//题型及数量
        }
        conn.Open();
        SqlTransaction st = conn.BeginTransaction();

        comm.Transaction = st;
        try
        {
            //第一步,写入教师试卷表,得到试卷id
            comm.CommandText = "insert into tb_teachershijuan(teacherusername,ceshiname,kechengid,ceshizhishidian,timelength,manfen,mingtifangshi,yunxuzuoti,ceshibanji,banjiid,yunxuchakan,xianzhiip) values('" + username + "','" + ceshiname + "'," + kechengid + ",'" + lbl_zhishidian.Text + "'," + ceshishichang + ",100,'" + zujuanfangshi + "','" + shifouyunxu + "','" + ceshibanji + "'," + banjiid + ",'" + Rbl_yunxuchakan.SelectedValue + "','" + xianzhiip + "') select @@identity as shijuanid";
            shijuanid        = Convert.ToInt32(comm.ExecuteScalar());  //
            //第二步,写入教师题目表
            if (zujuanfangshi == "全体学生相同" || zujuanfangshi == "对学生保密") //根据组卷方式选题,全体学生相同和只组一套卷类似,都是只选一套题
            {
                comm.CommandText = "insert into tb_teachershijuantimu(questionid,fenzhi,tihao,shijuanid) select questionid,fenzhi,tihao," + shijuanid + " from tb_teachershijuantimu where shijuanid=" + oldshijuanid;
                comm.ExecuteNonQuery();
                //为学生创建试卷:将试卷信息写入学生试卷表,将题目信息写入学生试卷题目表
                foreach (DataRow dr in stu.Rows)
                {
                    //将试卷信息写入学生试卷表
                    //zujuanxinxiSB.Append("序号:" + stuxuhaoList[i] + ",姓名:" + stuxingmingList[i] + ",学号:" + stuusernameList[i] + ";<br/>");
                    comm.CommandText = "insert into tb_studentkaoshi(shijuanid,studentusername,zongfen,yunxu,kechengid,banjiid) values(" + shijuanid + ",'" + dr["username"].ToString() + "',0,'" + shifouyunxu + "'," + kechengid + "," + banjiid + ")";
                    comm.ExecuteNonQuery();
                    //将题目信息写入学生试卷题目表
                    comm.CommandText = "insert into tb_studentkaoshiti(questionid,fenzhi,timuhao,shijuanid,studentusername) select questionid,fenzhi,tihao," + shijuanid + ",'" + dr["username"].ToString() + "' from tb_teachershijuantimu where shijuanid=" + oldshijuanid;
                    comm.ExecuteNonQuery();
                }
            }
            else//全体学生题目不同,不写入教师试卷题目表,只写学生试卷表和学生题目表
            {
                //写学生试卷表
                foreach (DataRow dr in stu.Rows)
                {
                    int tihao = 1;
                    //将试卷信息写入学生试卷表
                    //zujuanxinxiSB.Append("序号:" + stuxuhaoList[i] + ",姓名:" + stuxingmingList[i] + ",学号:" + stuusernameList[i] + ";<br/>");
                    comm.CommandText = "insert into tb_studentkaoshi(shijuanid,studentusername,zongfen,yunxu,kechengid,banjiid) values(" + shijuanid + ",'" + dr["username"].ToString() + "',0,'" + shifouyunxu + "'," + kechengid + "," + banjiid + ")";
                    comm.ExecuteNonQuery();
                    //为学生随机组卷,根据每种题型的题目数量,随机生成题目,写入学生考试题目表
                    foreach (DataRow dr1 in tixingshuliang.Rows)
                    {
                        tihaolist.Clear();;
                        for (i = 0; i < bxtimuzongshu; i++)
                        {
                            if (Bxtimu.Rows[i]["type"].ToString() == dr1["type"].ToString())
                            {
                                tihaolist.Add(i);
                            }
                        }
                        //随机选题
                        kexuantimushu = tihaolist.Count;
                        xuanzetihaolist.Clear();
                        yixuantimushu   = 0;
                        yingxuantimushu = Convert.ToInt32(dr1[1]);
                        rand            = new Random();
                        while (yixuantimushu < yingxuantimushu)
                        {
                            xuanzetihao = rand.Next(kexuantimushu);
                            if (!xuanzetihaolist.Contains(xuanzetihao))
                            {
                                xuanzetihaolist.Add(xuanzetihao);
                                yixuantimushu++;
                            }
                        }
                    }
                    for (i = 0; i < yingxuantimushu; i++)
                    {
                        comm.CommandText = "insert into tb_studentkaoshiti(studentusername,shijuanid,questionid,fenzhi,timuhao) values('" + dr["username"].ToString() + "'," + shijuanid + "," + Bxtimu.Rows[tihaolist[xuanzetihaolist[i]]]["questionid"].ToString() + "," + Bxtimu.Rows[tihaolist[xuanzetihaolist[i]]]["fenzhi"].ToString() + "," + tihao.ToString() + ")";
                        comm.ExecuteNonQuery();
                        tihao++;
                    }
                }
                //统计各题型题目数量
                //搜索各题型出现过的题目
                //为学生随机组卷
            }

            st.Commit();
            lbl_fankui.Text = "试卷迁移成功!";
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('试卷迁移成功!');</script>", false);
        }
        catch (Exception ex)
        {
            st.Rollback();
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('试卷迁移失败!');</script>", false);
            lbl_fankui.Text = ex.Message;
        }
        finally
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
        //将测试分发给新班级的所有学生
        //如果是随机命题,即题目是全体学生不同,则搜集所有学生的题目,再随机组卷,包括统计各题型题目数量
        //如果所有学生题目相同,则直接分发即可
    }
    protected void btn_buzhizuoye_Click(object sender, EventArgs e)//将作业布置给某个班
    {
        lbl_fankui.Text = "";
        string zuoyeid = Request.QueryString["zuoyeid"];

        if (ZuoyeInfo.GetTimuCount(zuoyeid) <= 0)//判断作业中有无题目
        {
            lbl_fankui.Text = "该作业中没有题目,无法布置该作业。";
            return;
        }
        string banjiid = DropDownList1.SelectedValue.Trim();

        if (BanjiInfo.GetStudentCount(int.Parse(banjiid)) <= 0)
        {
            lbl_fankui.Text = DropDownList1.SelectedItem.Text + "班没有学生,无法布置作业。";
            return;
        }
        string        shangjiaoqixian = TextBox1.Text;
        string        yunxu           = RadioButtonList1.SelectedValue;
        string        yunxuchakan     = RadioButtonList2.SelectedValue;
        string        kechengid       = ZuoyeInfo.getZuoye_Kechengid(int.Parse(zuoyeid));
        DataTable     studt           = BanjiInfo.GetStudentUserName(int.Parse(banjiid));
        DataTable     ZuoyeTimuTb     = ZuoyeInfo.GetZuoyeTimuIdAndFenzhi(int.Parse(zuoyeid));
        SqlConnection conn            = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString;
        SqlCommand comm = conn.CreateCommand();

        conn.Open();
        SqlTransaction st = conn.BeginTransaction();

        comm.Transaction = st;
        comm.CommandText = "insert into tb_zuoyebuzhi(zuoyeid,banjiid,yunxuzuoti,yunxuchakan,buzhishijian,shangjiaoqixian,teacherusername,shuoming,kechengid) values(@zuoyeid,@banjiid,@yunxuzuoti,@yunxuchakan,@buzhishijian,@shangjiaoqixian,@teacherusername,@shuoming,@kechengid)";
        comm.Parameters.AddWithValue("@zuoyeid", zuoyeid);
        comm.Parameters.AddWithValue("@banjiid", banjiid);
        comm.Parameters.AddWithValue("@yunxuzuoti", yunxu);
        comm.Parameters.AddWithValue("@yunxuchakan", yunxuchakan);
        comm.Parameters.AddWithValue("@buzhishijian", DateTime.Now);
        comm.Parameters.AddWithValue("@shangjiaoqixian", TextBox1.Text);
        comm.Parameters.AddWithValue("@teacherusername", ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name);
        comm.Parameters.AddWithValue("@shuoming", TextBox2.Text);
        comm.Parameters.AddWithValue("@kechengid", kechengid);
        try
        {
            comm.ExecuteNonQuery();
            //将作业分发给学生,写入学生作业表
            //删除以前布置给学生的该作业
            //comm.CommandText = "delete from tb_studentzuoye where zuoyeid=@zuoyeid and studentusername in(select studentusername from tb_banjistudent where banjiid=@banjiid)";
            //comm.ExecuteNonQuery();
            //删除题目
            //comm.CommandText = "delete from tb_stuzuoyetimu where zuoyeid=@zuoyeid and studentusername in(select studentusername  from tb_banjistudent where banjiid=@banjiid)";
            //comm.ExecuteNonQuery();
            //写入学生作业表
            comm.CommandText = "insert into tb_studentzuoye(zuoyeid,kechengid,studentusername,wancheng,zongfen,buzhishijian,shangjiaoqixian,shuoming,yunxuzuoti,yunxuchakan,teacherusername) values(@zuoyeid,@kechengid,@studentusername,'未完成',0,@buzhishijian,@shangjiaoqixian,@shuoming,@yunxuzuoti,@yunxuchakan,@teacherusername)";
            comm.Parameters.Add("@studentusername", SqlDbType.VarChar);
            foreach (DataRow sdr in studt.Rows)
            {
                comm.Parameters[9].Value = sdr[0].ToString();
                comm.ExecuteNonQuery();
            }
            //将题目写入学生作业题目表
            comm.Parameters.Clear();
            comm.CommandText = "insert into tb_stuzuoyetimu(zuoyeid,studentusername,questionid,defen,fenzhi) values(@zuoyeid,@studentusername,@questionid,0,@fenzhi)";
            comm.Parameters.AddWithValue("@zuoyeid", zuoyeid);
            comm.Parameters.Add("@studentusername", SqlDbType.VarChar);
            comm.Parameters.Add("@questionid", SqlDbType.Int);
            comm.Parameters.Add("@fenzhi", SqlDbType.Int);
            foreach (DataRow sdr in studt.Rows)
            {
                comm.Parameters[1].Value = sdr[0].ToString();
                foreach (DataRow dr in ZuoyeTimuTb.Rows)
                {
                    comm.Parameters[2].Value = Convert.ToInt32(dr[0]);
                    comm.Parameters[3].Value = Convert.ToInt32(dr[1]);
                    comm.ExecuteNonQuery();
                }
            }
            st.Commit();
            lbl_fankui.Text = "将作业布置给" + DropDownList1.SelectedItem.Text + ", 成功!";
        }
        catch
        {
            st.Rollback();
            lbl_fankui.Text = "布置失败!您是否已经给该班布置过该作业?";
        }
        finally
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
    }