/// <summary>
 /// 获取场次的平均分
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 protected double GetAvg(string id)
 {
     try
     {
         int mid = Convert.ToInt32(id);
         Song.Entities.Examination curr = null;
         if (exams != null)
         {
             foreach (Song.Entities.Examination em in exams)
             {
                 if (mid == em.Exam_ID)
                 {
                     curr = em;
                     break;
                 }
             }
         }
         if (curr == null)
         {
             return(0);
         }
         double res = Business.Do <IExamination>().Avg4Exam(curr.Exam_ID);
         return(Math.Round(res * 10000) / 10000);
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
         return(0);
     }
 }
 void fill()
 {
     try
     {
         //考试主题的平均成绩
         Song.Entities.Examination theme = Business.Do <IExamination>().ExamSingle(id);
         if (theme == null)
         {
             return;
         }
         //当前考试的所有成绩
         DataTable dt = null;
         if (theme.Exam_GroupType == 3)
         {
             //dt = Business.Do<IExamination>().Analysis4Team(id);
         }
         else
         {
             //dt = Business.Do<IExamination>().Analysis4Depart(id);
         }
         gvList.DataSource = dt;
         gvList.DataBind();
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }
Exemplo n.º 3
0
        private void fill()
        {
            //当前考试
            exam = Business.Do <IExamination>().ExamSingle(id);
            Song.Entities.ExamResults er = Business.Do <IExamination>().ResultSingle(id, 0, stid);
            if (er == null)
            {
                return;
            }
            stid = er.Ac_ID;
            //当前学生
            ListItem li = ddlStudent.Items.FindByValue(stid.ToString());

            if (li != null)
            {
                li.Selected = true;
            }
            //
            //学生名称
            lbStudent.Text = er.Ac_Name;
            //考试主题
            lbExamTheme.Text = exam.Exam_Title;
            //场次
            lbExamName.Text = exam.Exam_Name;
            //应试时间
            lbExamTime.Text = ((DateTime)er.Exr_CrtTime).ToString("yyyy月MM月dd日 hh:mm");
            //最终得分
            lbScoreFinal.Text = er.Exr_ScoreFinal.ToString();
            //展示简答题
            plJianda.Visible = bindShortQues(er);
        }
Exemplo n.º 4
0
        protected void Sts_ID_SelectedIndexChanged(object sender, EventArgs e)
        {
            //考试主题的平均成绩
            Song.Entities.Examination theme = Business.Do <IExamination>().ExamSingle(examid);
            if (theme == null)
            {
                return;
            }
            //各专业的平均成绩
            exams = Business.Do <IExamination>().ExamItem(theme.Exam_UID);
            rptExamItem.DataSource = exams;
            rptExamItem.DataBind();

            //考试主题下的所有参考人员成绩
            int       stsid = Convert.ToInt32(Sts_ID.SelectedValue);
            DataTable dt    = null;

            if (stsid == -1)
            {
                dt = dtResults;
            }
            if (dt == null)
            {
                dt = Business.Do <IExamination>().Result4Theme(examid, stsid);
            }
            gvList.DataSource = dt;
            gvList.DataBind();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 判断当前考试是否要显示“批阅试卷”按钮
        /// </summary>
        /// <param name="examid"></param>
        /// <returns></returns>
        protected bool getIsCorrect(object examid)
        {
            int id = Convert.ToInt32(examid);
            //考生数,如果没有人考试,则不需要批阅
            int students = Business.Do <IExamination>().Number4Exam(id);

            if (students < 1)
            {
                return(false);
            }
            Song.Entities.Examination exas  = Business.Do <IExamination>().ExamSingle(id);
            Song.Entities.TestPaper   pager = Business.Do <ITestPaper>().PagerSingle(exas.Tp_Id);
            if (pager == null)
            {
                return(false);
            }
            Song.Entities.TestPaperItem[] items = Business.Do <ITestPaper>().GetItemForAny(pager);
            foreach (Song.Entities.TestPaperItem ti in items)
            {
                if (ti.TPI_Type == 4)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 导出应该参加参加考试的所有学员,含缺考学员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOutput2_Click(object sender, EventArgs e)
        {
            //获取所有学员(含缺考)的成绩
            Song.Entities.Examination theme = Business.Do <IExamination>().ExamSingle(examid);
            HSSFWorkbook hssfworkbook       = new HSSFWorkbook();

            hssfworkbook = buildExcelSql_2(theme, hssfworkbook);

            //创建文件
            string     name     = WeiSha.Common.Server.LegalName(theme.Exam_Title) + "-所有学员" + ".xls";
            string     filePath = Upload.Get["Temp"].Physics + name;
            FileStream file     = new FileStream(filePath, FileMode.Create);

            hssfworkbook.Write(file);
            file.Close();
            if (System.IO.File.Exists(filePath))
            {
                FileInfo fileInfo = new FileInfo(filePath);
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name));
                Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType     = "application/-excel";
                Response.ContentEncoding = System.Text.Encoding.Default;
                Response.WriteFile(fileInfo.FullName);
                Response.Flush();
                Response.End();
                File.Delete(filePath);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 随机出题
        /// </summary>
        /// <returns></returns>
        private string randomJson()
        {
            //取果是第一次打开,则随机生成试题,此为获取试卷
            Song.Entities.TestPaper pager = Business.Do <ITestPaper>().PagerSingle(tpid);
            Dictionary <TestPaperItem, Questions[]> dics = Business.Do <ITestPaper>().Putout(pager); //生成试卷
            //
            List <Questions> list = new List <Questions>();                                          //缓存
            string           json = "[";

            foreach (var di in dics)
            {
                //++++++++按题型输出
                Song.Entities.TestPaperItem pi   = (Song.Entities.TestPaperItem)di.Key; //试题类型
                Song.Entities.Questions[]   ques = (Song.Entities.Questions[])di.Value; //当前类型的试题
                int   type  = (int)pi.TPI_Type;                                         //试题类型
                int   count = ques.Length;                                              //试题数目
                float num   = (float)pi.TPI_Number;                                     //占用多少分
                if (count < 1)
                {
                    continue;
                }
                string tpiJosn = "{'type':'" + type + "','count':'" + count + "','number':'" + num + "',";
                tpiJosn += "'ques':[";
                tpiJosn  = tpiJosn.Replace("'", "\"");
                //++++++++试题输出
                string quesJson = string.Empty;
                for (int n = 0; n < ques.Length; n++)
                {
                    quesJson += getQuesJson(ques[n]) + ",";
                    list.Add(ques[n]);      //存入列表,用于缓存存储
                }
                if (quesJson.EndsWith(","))
                {
                    quesJson = quesJson.Substring(0, quesJson.Length - 1);
                }
                //--------试题输出结束
                tpiJosn += quesJson + "]}";
                json    += tpiJosn + ",";
                //--------按题型输出结束
            }
            if (json.EndsWith(","))
            {
                json = json.Substring(0, json.Length - 1);
            }
            json += "]";
            //缓存
            if (list.Count > 0)
            {
                string uid = string.Format("ExamResults:{0}-{1}-{2}", examid, tpid, stid);    //缓存的uid
                Song.Entities.Examination exam = Business.Do <IExamination>().ExamSingle(examid);
                if (exam != null)
                {
                    Random rn = new Random(stid);
                    Business.Do <IQuestions>().CacheAdd(list.ToArray <Song.Entities.Questions>(), exam.Exam_Span + rn.Next(10), uid);
                }
            }
            return(json);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 绑定场次中的学科信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GvItem_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //当为数据行时
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
                //学科/专业
                DropDownTree ddl = (DropDownTree)e.Row.FindControl("ddlSubject");
                if (this.sbjs == null)
                {
                    sbjs = Business.Do <ISubject>().SubjectCount(org.Org_ID, null, true, -1, 0);
                    foreach (Song.Entities.Subject s in this.sbjs)
                    {
                        int count = Business.Do <ITestPaper>().PagerOfCount(org.Org_ID, s.Sbj_ID, -1, -1, true);
                        s.Sbj_Name = s.Sbj_Name + "  (" + count + ")";
                    }
                }
                ddl.DataSource     = sbjs;
                ddl.DataTextField  = "Sbj_Name";
                ddl.DataValueField = "Sbj_ID";
                ddl.Root           = 0;
                ddl.DataBind();
                ddl.Items.Insert(0, new ListItem(ddl.Items.Count < 1 ? "--(没有专业)--" : "", "-1"));

                //当前选中状态
                Song.Entities.Examination exam = (Song.Entities.Examination)e.Row.DataItem;
                ListItem liSubj = ddl.Items.FindByValue(exam.Sbj_ID.ToString());
                if (liSubj != null)
                {
                    liSubj.Selected = true;
                }

                //当前试卷
                if (exam.Sbj_ID > 0)
                {
                    Song.Entities.TestPaper[] tps = Business.Do <ITestPaper>().PagerCount(org.Org_ID, (int)exam.Sbj_ID, -1, -1, true, 0);
                    DropDownList tpDdl            = (DropDownList)e.Row.FindControl("ddlTestPager");
                    tpDdl.DataSource     = tps;
                    tpDdl.DataTextField  = "Tp_Name";
                    tpDdl.DataValueField = "Tp_Id";
                    tpDdl.DataBind();
                    for (int i = 0; i < tps.Length; i++)
                    {
                        tpDdl.Items[i].Attributes.Add("span", tps[i].Tp_Span.ToString());
                        tpDdl.Items[i].Attributes.Add("total", tps[i].Tp_Total.ToString());
                        tpDdl.Items[i].Attributes.Add("passScore", tps[i].Tp_PassScore.ToString());
                    }
                    ListItem liTp = tpDdl.Items.FindByValue(exam.Tp_Id.ToString());
                    if (liTp != null)
                    {
                        liTp.Selected = true;
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 绑定场次中的学科信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GvItem_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //当为数据行时
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //学科/专业
                DropDownList ddl = (DropDownList)e.Row.FindControl("ddlSubject");
                ddl.DataSource     = ddlSubject.DataSource;
                ddl.DataTextField  = "Sbj_Name";
                ddl.DataValueField = "Sbj_ID";
                ddl.DataBind();
                if (ddl.Items.Count < 1)
                {
                    ddl.Items.Insert(0, new ListItem("--(没有专业)--", "-1"));
                }
                if (ddl.Items.Count > 0)
                {
                    ddl.Items.Insert(0, new ListItem("", "-1"));
                }

                //当前选中状态
                Song.Entities.Examination exam = (Song.Entities.Examination)e.Row.DataItem;
                ListItem liSubj = ddl.Items.FindByValue(exam.Sbj_ID.ToString());
                if (liSubj != null)
                {
                    liSubj.Selected = true;
                }

                //当前试卷
                if (exam.Sbj_ID > 0)
                {
                    Song.Entities.TestPaper[] tps = Business.Do <ITestPaper>().PagerCount(org.Org_ID, (int)exam.Sbj_ID, -1, -1, true, 0);
                    DropDownList tpDdl            = (DropDownList)e.Row.FindControl("ddlTestPager");
                    tpDdl.DataSource     = tps;
                    tpDdl.DataTextField  = "Tp_Name";
                    tpDdl.DataValueField = "Tp_Id";
                    tpDdl.DataBind();
                    for (int i = 0; i < tps.Length; i++)
                    {
                        tpDdl.Items[i].Attributes.Add("span", tps[i].Tp_Span.ToString());
                        tpDdl.Items[i].Attributes.Add("total", tps[i].Tp_Total.ToString());
                        tpDdl.Items[i].Attributes.Add("passScore", tps[i].Tp_PassScore.ToString());
                    }
                    ListItem liTp = tpDdl.Items.FindByValue(exam.Tp_Id.ToString());
                    if (liTp != null)
                    {
                        liTp.Selected = true;
                    }
                }
            }
        }
Exemplo n.º 10
0
        protected void Sts_ID_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable dt = null;    //数据源

            //考试主题的平均成绩
            Song.Entities.Examination theme = Business.Do <IExamination>().ExamSingle(examid);
            if (theme == null)
            {
                return;
            }
            //各专业的平均成绩
            exams = Business.Do <IExamination>().ExamItem(theme.Exam_UID);
            rptExamItem.DataSource = exams;
            rptExamItem.DataBind();

            string stsid = "";

            //考试主题下的所有参考人员成绩
            stsid = Sts_ID.SelectedValue;  //选中的组ID
            switch (Sts_ID.SelectedValue)
            {
            //所有学员
            case "0":
                //当前考试限定的学生分组
                Song.Entities.StudentSort[] sts = Business.Do <IExamination>().GroupForStudentSort(theme.Exam_UID);
                //如果没有设定分组,则取当前参加考试的学员的分组
                if (sts == null || sts.Length < 1)
                {
                    sts = Business.Do <IExamination>().StudentSort4Theme(examid);
                }
                foreach (Song.Entities.StudentSort ss in sts)
                {
                    stsid += ss.Sts_ID + ",";
                }
                stsid += "-1";
                dt     = Business.Do <IExamination>().Result4Theme(examid, stsid);
                break;

            //未分组学员
            case "-1":
                dt = Business.Do <IExamination>().Result4Theme(examid, -1);
                break;

            //当前分组学员
            default:
                dt = Business.Do <IExamination>().Result4Theme(examid, Convert.ToInt32(Sts_ID.SelectedValue));
                break;
            }
            gvList.DataSource = dt;
            gvList.DataBind();
        }
Exemplo n.º 11
0
 void fill()
 {
     //当前考试限定的学生分组
     Song.Entities.Examination   theme = Business.Do <IExamination>().ExamSingle(examid);
     Song.Entities.StudentSort[] sts   = Business.Do <IExamination>().GroupForStudentSort(theme.Exam_UID);
     //如果没有设定分组,则取当前参加考试的学员的分组
     if (sts == null || sts.Length < 1)
     {
         sts = Business.Do <IExamination>().StudentSort4Theme(examid);
     }
     Sts_ID.DataSource = sts;
     Sts_ID.DataBind();
     Sts_ID.Items.Insert(0, new ListItem("-- 所有学员 --", "0"));
     Sts_ID.Items.Add(new ListItem("-- 未分组学员 --", "-1"));
 }
Exemplo n.º 12
0
        /// <summary>
        /// 导出成绩
        /// </summary>
        /// <param name="hssfworkbook"></param>
        private HSSFWorkbook buildExcelSql_2(Song.Entities.Examination theme, HSSFWorkbook hssfworkbook)
        {
            //当前考试限定的学生分组
            string stsid = "";

            Song.Entities.StudentSort[] sts = Business.Do <IExamination>().GroupForStudentSort(theme.Exam_UID);
            //如果没有设定分组,则取当前参加考试的学员的分组
            if (sts == null || sts.Length < 1)
            {
                sts = Business.Do <IExamination>().StudentSort4Theme(examid);
            }
            foreach (Song.Entities.StudentSort ss in sts)
            {
                stsid += ss.Sts_ID + ",";
            }
            DataTable dt = Business.Do <IExamination>().Result4Theme(examid, stsid);

            dt.TableName = "--所有学员--";
            buildExcelSql_2_fromData(dt, hssfworkbook);

            //每个分组单独创建工作表
            foreach (string s in stsid.Split(','))
            {
                if (string.IsNullOrWhiteSpace(s))
                {
                    continue;
                }
                int sid = 0;
                int.TryParse(s, out sid);
                if (sid <= 0)
                {
                    continue;
                }
                //取每个组的学员的考试成绩
                DataTable dtTm = Business.Do <IExamination>().Result4Theme(examid, sid);
                if (dtTm == null)
                {
                    continue;
                }
                Song.Entities.StudentSort sort = Business.Do <IStudent>().SortSingle(sid);
                dtTm.TableName = sort.Sts_Name;
                buildExcelSql_2_fromData(dtTm, hssfworkbook);
            }
            return(hssfworkbook);
        }
Exemplo n.º 13
0
 /// <summary>
 /// 修改是否显示的状态
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void sbUse_Click(object sender, EventArgs e)
 {
     try
     {
         StateButton ub    = (StateButton)sender;
         int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
         int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());
         //
         Song.Entities.Examination entity = Business.Do <IExamination>().ExamSingle(id);
         entity.Exam_IsUse = !entity.Exam_IsUse;
         Business.Do <IExamination>().ExamSave(entity);
         BindData(null, null);
     }
     catch (Exception ex)
     {
         this.Alert(ex.Message);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// 绑定选择题子项的列表
        /// </summary>
        private void setExamItem()
        {
            //最多几项
            int maxItem = Convert.ToInt16(lbMaxnum.Text);

            Song.Entities.Examination[]      ans  = Business.Do <IExamination>().ExamItem(getUID());
            List <Song.Entities.Examination> list = new List <Song.Entities.Examination>();

            for (int i = 0; i < maxItem; i++)
            {
                if (i < ans.Length)
                {
                    list.Add(ans[i]);
                }
                else
                {
                    Song.Entities.Examination t = new Song.Entities.Examination();
                    t.Exam_ID  = -1;
                    t.Exam_UID = getUID();
                    list.Add(t);
                }
                DateTime examDate = list[i].Exam_Date;
                list[i].Exam_Date = examDate.AddYears(100) < DateTime.Now ? DateTime.Now : examDate;
            }
            GvItem.DataSource   = list;
            GvItem.DataKeyNames = new string[] { "Exam_ID" };
            GvItem.DataBind();
            for (int i = 0; i < GvItem.Rows.Count; i++)
            {
                GridViewRow gvr = GvItem.Rows[i];
                //考试时间
                TextBox tbDate = (TextBox)gvr.FindControl("tbDate");
                if (list[i].Exam_ID < 1)
                {
                    tbDate.Text = "";
                    ((TextBox)gvr.FindControl("tbSpan")).Text = "";
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取场次的平均分
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected double GetAvg(string id)
        {
            int mid = Convert.ToInt32(id);

            Song.Entities.Examination curr = null;
            if (exams != null)
            {
                foreach (Song.Entities.Examination em in exams)
                {
                    if (mid == em.Exam_ID)
                    {
                        curr = em;
                        break;
                    }
                }
            }
            if (curr == null)
            {
                return(0);
            }
            double res = Business.Do <IExamination>().Avg4Exam(curr.Exam_ID);

            return(Math.Round(Math.Round(res * 10000) / 10000, 2, MidpointRounding.AwayFromZero));
        }
Exemplo n.º 16
0
        void fill()
        {
            try
            {
                //考试主题的平均成绩
                Song.Entities.Examination theme = Business.Do <IExamination>().ExamSingle(id);
                if (theme == null)
                {
                    return;
                }
                //各专业的平均成绩
                exams = Business.Do <IExamination>().ExamItem(theme.Exam_UID);
                rptExamItem.DataSource = exams;
                rptExamItem.DataBind();

                DataTable dt = Business.Do <IExamination>().Result4Theme(id);
                gvList.DataSource = dt;
                gvList.DataBind();
            }
            catch (Exception ex)
            {
                Message.ExceptionShow(ex);
            }
        }
Exemplo n.º 17
0
 void fill()
 {
     Song.Entities.Examination mm;
     if (id != 0)
     {
         mm = Business.Do <IExamination>().ExamSingle(id);
         //是否使用
         cbIsUse.Checked = mm.Exam_IsUse;
         //唯一标识
         ViewState["UID"] = mm.Exam_UID;
         //所属参考人员分类
         ListItem ligroup = this.rblGroup.Items.FindByValue(mm.Exam_GroupType.ToString());
         if (ligroup != null)
         {
             rblGroup.SelectedIndex = -1;
             ligroup.Selected       = true;
         }
         //按学员分类
         if (mm.Exam_GroupType == 2)
         {
             Song.Entities.StudentSort[] sts = Business.Do <IExamination>().GroupForStudentSort(getUID());
             lbSelected.DataSource     = sts;
             lbSelected.DataTextField  = "Sts_Name";
             lbSelected.DataValueField = "Sts_ID";
             lbSelected.DataBind();
             string stsStr = "";
             foreach (Song.Entities.StudentSort d in sts)
             {
                 stsStr += "," + d.Sts_ID + "|" + d.Sts_Name;
             }
             tbSortSelected.Text = stsStr;
         }
         //时间类型
         ListItem liDateType = this.rblExamTimeType.Items.FindByValue(mm.Exam_DateType.ToString());
         if (liDateType != null)
         {
             rblExamTimeType.SelectedIndex = -1;
             liDateType.Selected           = true;
             tbStartTime.Text = mm.Exam_Date.ToString("yyyy-MM-dd HH:mm");
             tbStartOver.Text = mm.Exam_DateOver.ToString("yyyy-MM-dd HH:mm");
             rblExamTimeType_SelectedIndexChanged(rblExamTimeType, null);
         }
         //一些参数
         cbExam_IsToggle.Checked     = mm.Exam_IsToggle;     //是否允许切换窗口
         cbExam_IsShowBtn.Checked    = mm.Exam_IsShowBtn;    //是否显示确认按钮
         cbExam_IsRightClick.Checked = mm.Exam_IsRightClick; //是否禁用右键
     }
     else
     {
         //如果是新增
         mm = new Song.Entities.Examination();
         ViewState["UID"] = WeiSha.Common.Request.UniqueID();
         tbStartTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
         tbStartOver.Text = DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd HH:mm");
     }
     //考试名称
     tbName.Text = mm.Exam_Title;
     //简介
     tbIntro.Text = mm.Exam_Intro;
     //考试场次的数据填充
     setExamItem();
 }
Exemplo n.º 18
0
        /// <summary>
        /// 获取考试场次
        /// </summary>
        /// <returns></returns>
        private List <Song.Entities.Examination> getExamItem()
        {
            List <Song.Entities.Examination> items = new List <Song.Entities.Examination>();

            for (int i = 0; i < GvItem.Rows.Count; i++)
            {
                GridViewRow gvr = GvItem.Rows[i];
                if (gvr.RowType != DataControlRowType.DataRow)
                {
                    continue;
                }
                //id
                Label lbID   = (Label)gvr.FindControl("lbID");
                int   itemID = Convert.ToInt32(lbID.Text == string.Empty ? "-1" : lbID.Text);

                //考试名称
                string name = ((TextBox)gvr.FindControl("tbName")).Text;
                //总分与及格分
                TextBox tbTotal     = (TextBox)gvr.FindControl("tbTotal");
                int     total       = tbTotal.Text.Trim() == "" ? 60 : Convert.ToInt32(tbTotal.Text);
                TextBox tbPassscore = (TextBox)gvr.FindControl("tbPassScore");
                int     passcore    = tbPassscore.Text.Trim() == "" ? 60 : Convert.ToInt32(tbPassscore.Text);
                //考试时间
                TextBox  tbDate = (TextBox)gvr.FindControl("tbDate");
                DateTime date   = Convert.ToDateTime(tbDate.Text == string.Empty ? DateTime.Now.AddYears(-100).ToString() : tbDate.Text);
                //考试时长
                TextBox tbSpan = (TextBox)gvr.FindControl("tbSpan");
                int     span   = Convert.ToInt32(tbSpan.Text == string.Empty ? "-1" : tbSpan.Text);
                //采用的试卷
                TextBox tbTestPager        = (TextBox)gvr.FindControl("tbTestPager");
                int     tpID               = Convert.ToInt32(tbTestPager.Text == string.Empty ? "-1" : tbTestPager.Text);
                Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle(tpID);
                //专业
                DropDownList sbjddl  = (DropDownList)gvr.FindControl("ddlSubject");
                int          sbjID   = 0;
                string       sbjName = "";
                if (sbjddl != null && sbjddl.Items.Count > 0)
                {
                    sbjID   = Convert.ToInt32(sbjddl.SelectedValue);
                    sbjName = sbjddl.SelectedItem.Text;
                }
                Song.Entities.Subject sbj = Business.Do <ISubject>().SubjectSingle(sbjID);
                if (sbj != null)
                {
                    sbjName = sbj.Sbj_Name;
                }


                //创建场次对象
                Song.Entities.Examination exam = itemID < 1 ? new Song.Entities.Examination() : Business.Do <IExamination>().ExamSingle(itemID);
                exam = exam == null ? new Song.Entities.Examination() : exam;
                //赋值
                exam.Exam_UID       = getUID();
                exam.Sbj_ID         = sbjID;
                exam.Sbj_Name       = sbjName;
                exam.Exam_Name      = name;
                exam.Exam_Total     = total;
                exam.Exam_PassScore = passcore;
                exam.Exam_Date      = date;
                exam.Exam_Span      = span;
                exam.Tp_Id          = tpID;
                exam.Exam_Tax       = i + 1;
                items.Add(exam);
            }
            //校验,各场次考试主题不可以相同
            bool isExists = false;

            foreach (Song.Entities.Examination e in items)
            {
                if (string.IsNullOrWhiteSpace(e.Exam_Name))
                {
                    continue;
                }
                foreach (Song.Entities.Examination j in items)
                {
                    if (e.Exam_Tax == j.Exam_Tax)
                    {
                        continue;
                    }
                    if (e.Exam_Name == j.Exam_Name)
                    {
                        isExists = true;
                        break;
                    }
                }
                if (isExists)
                {
                    break;
                }
            }
            if (isExists)
            {
                throw new Exception("各场次考试主题不可以相同");
            }
            return(items);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 初始化常用数据
        /// </summary>
        /// <returns>如果有错误,返回-1,如果考试结束或不存在,则返回0;正常返回1</returns>
        private int initData()
        {
            //如果为空,则返回-1,表示错误
            if (result == "")
            {
                return(-1);
            }
            resXml.LoadXml(result, false);
            XmlNode xn = resXml.SelectSingleNode("results");
            //试卷id,考试id
            int tpid;

            int.TryParse(xn.Attributes["tpid"].Value, out tpid);
            int examid;

            int.TryParse(xn.Attributes["examid"].Value, out examid);
            //考试结束时间
            long lover;

            long.TryParse(xn.Attributes["overtime"].Value, out lover);
            lover = lover * 10000;
            DateTime dtStart  = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            TimeSpan toNow    = new TimeSpan(lover);
            DateTime overTime = dtStart.Add(toNow); //得到转换后的时间
            //学生Id,学生名称
            int stid;

            int.TryParse(xn.Attributes["stid"].Value, out stid);
            string stname = xn.Attributes["stname"].Value.ToString();
            //学生性别,分组,身份证号
            int stsex;

            int.TryParse(xn.Attributes["stsex"].Value, out stsex);
            int stsid;

            int.TryParse(xn.Attributes["stsid"].Value, out stsid);
            string stcardid = xn.Attributes["stcardid"].Value.ToString();
            //学科Id,学科名称
            int sbjid;

            int.TryParse(xn.Attributes["sbjid"].Value, out sbjid);
            string sbjname = xn.Attributes["sbjname"].Value.ToString();
            //UID与考试主题
            string uid   = xn.Attributes["uid"].Value.ToString();
            string theme = xn.Attributes["theme"].Value.ToString();
            //提交方式,1为自动提交,2为交卷
            int patter = Convert.ToInt32(xn.Attributes["patter"].Value);

            //
            Song.Entities.Examination exam = Business.Do <IExamination>().ExamSingle(examid);
            //如果考试不存在
            if (exam == null)
            {
                return(0);
            }
            //如果考试已经结束
            int span = (int)exam.Exam_Span;

            //if (DateTime.Now > ((DateTime)exam.Exam_Date).AddMinutes(span + 5)) return 0;
            try
            {
                Song.Entities.ExamResults exr = new ExamResults();
                exr.Exr_IsSubmit    = patter == 2;
                exr.Exam_ID         = examid;
                exr.Exam_Name       = exam.Exam_Name;
                exr.Tp_Id           = tpid;
                exr.Ac_ID           = stid;
                exr.Ac_Name         = stname;
                exr.Sts_ID          = stsid;
                exr.Ac_Sex          = stsex;
                exr.Ac_IDCardNumber = stcardid;
                exr.Sbj_ID          = sbjid;
                exr.Sbj_Name        = sbjname;
                exr.Exr_IP          = WeiSha.Common.Browser.IP;
                exr.Exr_Mac         = WeiSha.Common.Request.UniqueID(); //原本是网卡的mac地址,此处不再记录
                exr.Exr_Results     = result;
                exr.Exam_UID        = uid;
                exr.Exam_Title      = theme;
                exr.Exr_IsSubmit    = patter == 2;
                if (exr.Exr_IsSubmit)
                {
                    exr.Exr_SubmitTime = DateTime.Now;
                }
                exr.Exr_OverTime = overTime;
                exr.Exr_CrtTime  = DateTime.Now;
                exr.Exr_LastTime = DateTime.Now;
                //Business.Do<IExamination>().ResultSubmit(exr);
                string cacheUid = string.Format("ExamResults:{0}-{1}-{2}", examid, tpid, stid);    //缓存的uid
                Business.Do <IQuestions>().CacheUpdate(exr, -1, cacheUid);
                return(1);
            }
            catch
            {
                return(0);
            }
        }
Exemplo n.º 20
0
        protected override void InitPageTemplate(HttpContext context)
        {
            accid = Extend.LoginState.Accounts.UserID;
            Song.Entities.ExamResults result = null;
            if (exrid != 0)
            {
                result = Business.Do <IExamination>().ResultSingle(exrid);
            }
            else
            {
                result = Business.Do <IExamination>().ResultSingle(accid, examid);
                if (result != null)
                {
                    exrid = result.Exr_ID;
                }
            }

            if (result == null)
            {
                return;
            }
            Song.Entities.Examination exam = Business.Do <IExamination>().ExamSingle(result.Exam_ID);
            if (exam == null)
            {
                return;
            }
            //加载答题信息
            resXml.LoadXml(result.Exr_Results, false);
            //判断开始时间与结束时间,是否考试结束等
            bool isOver;

            //判断是否已经开始、是否已经结束
            if (exam.Exam_DateType == 1)
            {
                //固定时间开始
                isOver = DateTime.Now > exam.Exam_Date.AddMinutes(exam.Exam_Span);   //是否结束
            }
            else
            {
                isOver = DateTime.Now > exam.Exam_DateOver;   //是否结束
                if (result != null && !string.IsNullOrWhiteSpace(result.Exr_Results))
                {
                    XmlNode xn = resXml.LastChild;
                    //考试的开始与结束时间,防止学员刷新考试界面,导致时间重置
                    long lover;
                    long.TryParse(xn.Attributes["overtime"] != null ? xn.Attributes["overtime"].Value : "0", out lover);
                    lover = lover * 10000;
                    DateTime dtStart  = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                    DateTime overTime = dtStart.Add(new TimeSpan(lover));    //得到转换后的结束时间
                    isOver = DateTime.Now > overTime;
                }
            }
            this.Document.Variables.SetValue("isOver", isOver);
            //
            result.Exam_Name = exam.Exam_Name;
            this.Document.Variables.SetValue("result", result);
            //试卷
            Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle((int)result.Tp_Id);
            this.Document.Variables.SetValue("pager", tp);
            //考生
            Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle((int)result.Ac_ID);
            this.Document.Variables.SetValue("st", st);

            //获取试题项
            Song.Entities.TestPaperItem[] tpi = getTpi(tp);
            this.Document.Variables.SetValue("tpi", tpi);
            //计算得分
            this.Document.RegisterGlobalFunction(this.getTypeName);
            this.Document.RegisterGlobalFunction(this.getTypeNumber);
            this.Document.RegisterGlobalFunction(this.getAnswerCount);
            this.Document.RegisterGlobalFunction(this.getSucessCount);
            this.Document.RegisterGlobalFunction(this.getErrorCount);
            //展示答题状态
            this.Document.RegisterGlobalFunction(this.getQues);
            this.Document.RegisterGlobalFunction(this.getItems);
            this.Document.RegisterGlobalFunction(this.getSucessAnswer);
            //计算答题状态等
            this.Document.RegisterGlobalFunction(this.getAnswerState);
            //获取学生答题内容与正确答案
            this.Document.RegisterGlobalFunction(this.getResult);
            this.Document.RegisterGlobalFunction(this.getQuesScore);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            //考试主题
            Song.Entities.Examination theme = id < 1 ? new Song.Entities.Examination() : Business.Do <IExamination>().ExamSingle(id);

            //基本信息:考试名称
            theme.Exam_Title = tbName.Text.Trim();
            //UID,是否为考试主题(后面还分场次)
            theme.Exam_UID     = getUID();
            theme.Exam_IsTheme = true;
            //是否使用与推荐
            theme.Exam_IsUse = cbIsUse.Checked;
            //简介
            theme.Exam_Intro = tbIntro.Text;
            //一些参数
            theme.Exam_IsToggle     = cbExam_IsToggle.Checked;     //是否允许切换窗口
            theme.Exam_IsShowBtn    = cbExam_IsShowBtn.Checked;    //是否显示确认按钮
            theme.Exam_IsRightClick = cbExam_IsRightClick.Checked; //是否禁用右键
            //参考人员
            //相关关联对象
            List <Song.Entities.ExamGroup> groups = null;

            //分类
            theme.Exam_GroupType = Convert.ToInt16(rblGroup.SelectedValue);
            //如果是按学员分类
            if (theme.Exam_GroupType == 2)
            {
                groups = this.getGroupForSts();
            }
            //时间设定
            theme.Exam_DateType = Convert.ToInt32(rblExamTimeType.SelectedValue);
            DateTime dtStart = DateTime.Now, dtOver = DateTime.Now.AddMonths(1);

            DateTime.TryParse(tbStartTime.Text, out dtStart);
            DateTime.TryParse(tbStartOver.Text, out dtOver);
            theme.Exam_Date     = dtStart;
            theme.Exam_DateOver = dtOver;
            try
            {
                if (theme.Exam_DateType == 2)
                {
                    if (theme.Exam_DateOver <= theme.Exam_Date)
                    {
                        throw new Exception("设定时间区间时,结束时间不能小于等于开始时间。");
                    }
                }
                //获取场次
                List <Song.Entities.Examination> items = getExamItem();
                if (id < 1)
                {
                    Business.Do <IExamination>().ExamAdd(theme, items, groups);
                }
                else
                {
                    Business.Do <IExamination>().ExamSave(theme, items, groups);
                }
                Master.AlertCloseAndRefresh("操作完成!");
            }
            catch (Exception ex)
            {
                Master.Alert(ex.Message);
            }
        }