Exemplo n.º 1
0
        protected void btnEnter_Click(object sender, ImageClickEventArgs e)
        {
            if (id < 1)
            {
                return;
            }
            Song.Entities.ExamResults mm = Business.Do <IExamination>().ResultSingle(id);
            //画图得分
            float draw = (float)Convert.ToDouble(tbDraw.Text.Trim() == "" ? "0" : tbDraw.Text);

            mm.Exr_Draw = draw;
            //综合分
            float coli = (float)Convert.ToDouble(tbColligate.Text.Trim() == "" ? "0" : tbColligate.Text);

            mm.Exr_Colligate = coli;
            //简答题得分
            double sQusNum = calcShort(mm);

            //最终得分
            try
            {
                mm = Business.Do <IExamination>().ResultClacScore(mm);
                Business.Do <IExamination>().ResultSave(mm);
                Master.AlertCloseAndRefresh("操作成功!");
            }
            catch (Exception ex)
            {
                Message.ExceptionShow(ex);
            }
        }
Exemplo n.º 2
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);
        }
        /// <summary>
        /// 如果已经提交过答案,通过提交的答题返回试题
        /// </summary>
        /// <param name="exr"></param>
        /// <returns></returns>
        private string resultJson(Song.Entities.ExamResults exr)
        {
            XmlDocument resXml = new XmlDocument();

            resXml.LoadXml(exr.Exr_Results, false);
            string      json = "[";
            XmlNodeList ques = resXml.GetElementsByTagName("ques");

            for (int i = 0; i < ques.Count; i++)
            {
                XmlNode node    = ques[i];
                string  type    = node.Attributes["type"].Value;
                string  count   = node.Attributes["count"].Value;
                string  num     = node.Attributes["number"].Value;
                string  quesObj = "{";
                quesObj += "'type':'" + type + "','count':'" + count + "','number':'" + num + "',";
                quesObj += "'ques':[";
                quesObj  = quesObj.Replace("'", "\"");
                for (int n = 0; n < node.ChildNodes.Count; n++)
                {
                    int id = Convert.ToInt32(node.ChildNodes[n].Attributes["id"].Value);
                    Song.Entities.Questions q = null;
                    q = Business.Do <IQuestions>().QuesSingle4Cache(id);
                    if (q == null)
                    {
                        q = Business.Do <IQuestions>().QuesSingle(id);
                    }
                    if (q == null)
                    {
                        continue;
                    }
                    q.Qus_Number  = (float)Convert.ToDouble(node.ChildNodes[n].Attributes["num"].Value);
                    q.Qus_Explain = "";
                    q.Qus_Answer  = "";
                    string js = getQuesJson(q);
                    //如果是单选题,或多选题,或填空题
                    if (q.Qus_Type == 1 || q.Qus_Type == 2 || q.Qus_Type == 5)
                    {
                        quesObj += getAnserJson(q, js);
                    }
                    else
                    {
                        quesObj += js;
                    }
                    if (n < node.ChildNodes.Count - 1)
                    {
                        quesObj += ",";
                    }
                }
                quesObj += "]";
                quesObj += "}";
                if (i < ques.Count - 1)
                {
                    quesObj += ",";
                }
                json += quesObj;
            }
            json += "]";
            return(json);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            //判断分值是否超出最大分值
            for (int i = 0; i < rptQues.Items.Count; i++)
            {
                //当前试题的分数
                HiddenField hfnumField = (HiddenField)rptQues.Items[i].FindControl("hfnum");
                double      hfnum      = 0;
                double.TryParse(hfnumField.Value, out hfnum);
                //实际得分
                TextBox tbNumber = (TextBox)rptQues.Items[i].FindControl("tbNumber");
                double  number   = 0;
                double.TryParse(tbNumber.Text, out number);
                if (string.IsNullOrEmpty(tbNumber.Text))
                {
                    Master.Alert("第" + (i + 1) + "题得分不能为空!");
                    return;
                }
                if (number > hfnum)
                {
                    Master.Alert("第" + (i + 1) + "题得分超出该题最高分值!");
                    return;
                }
                if (number < 0)
                {
                    Master.Alert("第" + (i + 1) + "题得分不得为负值!");
                    return;
                }
            }
            Song.Entities.ExamResults mm = Business.Do <IExamination>().ResultSingle(id, 0, stid);
            //简答题得分
            double sQusNum = calcShort(mm);

            mm.Exr_ScoreFinal = (float)mm.Exr_Score + (float)sQusNum;
            //最终得分
            try
            {
                Business.Do <IExamination>().ResultSave(mm);
                Song.Entities.ExamResults next = Business.Do <IExamination>().ResultSingleNext(id, stid, false);
                if (next != null)
                {
                    this.Response.Redirect(string.Format("Correct.aspx?id={0}&stid={1}", next.Exam_ID.ToString(), next.Ac_ID.ToString()));
                }
                else
                {
                    fill();
                    Master.Alert("操作成功!");
                }
            }
            catch (Exception ex)
            {
                Master.Alert(ex.Message);
            }
        }
Exemplo n.º 5
0
 //获取当前学科下的所有试卷
 protected void Page_Load(object sender, EventArgs e)
 {
     //获取答题信息
     Song.Entities.ExamResults exr = Business.Do <IExamination>().ResultSingle(examid, tpid, accid);
     if (exr == null)
     {
         Response.Write("0");
     }
     else
     {
         Response.Write(exr.Exr_Results);
     }
     Response.End();
 }
Exemplo n.º 6
0
        /// <summary>
        /// 计算简答题得分
        /// </summary>
        /// <returns></returns>
        private double calcShort(Song.Entities.ExamResults exr)
        {
            if (string.IsNullOrEmpty(exr.Exr_Results))
            {
                return(0);
            }
            XmlDocument resXml = new XmlDocument();

            resXml.LoadXml(exr.Exr_Results, false);
            XmlNodeList nodeList = resXml.SelectSingleNode("results").ChildNodes;
            //得分记录
            double scoreSum = 0;

            foreach (RepeaterItem pi in rptQues.Items)
            {
                //id
                Label lbId = (Label)pi.FindControl("lbID");
                //得分
                TextBox tb    = (TextBox)pi.FindControl("tbNumber");
                double  score = tb.Text.Trim() == "" ? 0 : Convert.ToDouble(tb.Text);
                scoreSum += score;
                for (int i = 0; i < nodeList.Count; i++)
                {
                    XmlNode node = nodeList[i];
                    if (node.Attributes["id"].Value == lbId.Text)
                    {
                        XmlElement el = (XmlElement)node;
                        el.SetAttribute("score", score.ToString());
                    }
                }
            }
            StringWriter  sw = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(sw);

            resXml.WriteTo(xw);
            exr.Exr_Results = sw.ToString();
            return(scoreSum);
        }
Exemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "text/plain";
            context.Response.ContentEncoding = System.Text.Encoding.UTF8;
            context.Response.Charset         = "utf-8";
            Response = context.Response;
            //获取答题信息
            Song.Entities.ExamResults exr = Business.Do <IExamination>().ResultSingleForCache(examid, tpid, stid);
            string json = string.Empty;

            if (exr == null)
            {
                //第一次,随机出题
                json = randomJson();
            }
            else
            {
                //如果已经交过卷,输出2
                json = exr.Exr_IsSubmit ? "2" : resultJson(exr);
            }
            Response.Write(json);
            Response.End();
        }
Exemplo n.º 8
0
        //获取当前学科下的所有试卷
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取答题信息
            Song.Entities.ExamResults exr = Business.Do <IExamination>().ResultSingle(examid, tpid, stid);
            //取试题
            List <Song.Entities.Questions> quesList = new List <Questions>();

            if (exr == null)
            {
                //取果是第一次打开,则随机生成试题,此为获取试卷
                Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle(tpid);
                //难度区间
                int diff1 = tp.Tp_Diff > tp.Tp_Diff2 ? (int)tp.Tp_Diff2 : (int)tp.Tp_Diff;
                int diff2 = tp.Tp_Diff > tp.Tp_Diff2 ? (int)tp.Tp_Diff : (int)tp.Tp_Diff2;
                //获取试题项
                Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForAll(tp);
                foreach (Song.Entities.TestPaperItem pi in tpi)
                {
                    //类型,试题数目,该类型占多少分,
                    int   type  = (int)pi.TPI_Type;
                    int   count = (int)pi.TPI_Count;
                    float num   = (float)pi.TPI_Number;
                    int   per   = (int)pi.TPI_Percent;
                    if (count < 1)
                    {
                        continue;
                    }
                    Song.Entities.Questions[] ques = Business.Do <IQuestions>().QuesRandom(tp.Org_ID, (int)tp.Sbj_ID, -1, -1, type, diff1, diff2, true, count);
                    float surplus = num;
                    for (int i = 0; i < ques.Length; i++)
                    {
                        //当前试题的分数
                        float curr = ((float)pi.TPI_Number) / ques.Length;
                        curr = ((float)Math.Round(curr * 10)) / 10;
                        if (i < ques.Length - 1)
                        {
                            ques[i].Qus_Number = curr;
                            surplus            = surplus - curr;
                        }
                        else
                        {
                            ques[i].Qus_Number = surplus;
                        }
                    }
                    foreach (Song.Entities.Questions q in ques)
                    {
                        quesList.Add(replaceText(q));
                    }
                }
            }
            else
            {
                //如果已经做过试题
                if (exr.Exr_IsSubmit)
                {
                    //如果已经交过卷,则不允许再做题
                    Response.Write("2");
                    Response.End();
                }
                else
                {
                    quesList = Business.Do <IExamination>().QuesForResults(exr.Exr_Results);
                }
            }

            string tm = "[";

            for (int i = 0; i < quesList.Count; i++)
            {
                string json = quesList[i].ToJson();
                //如果是单选题,或多选题,或填空题
                if (quesList[i].Qus_Type == 1 || quesList[i].Qus_Type == 2 || quesList[i].Qus_Type == 5)
                {
                    tm += getAnserJson(quesList[i], json);
                }
                else
                {
                    tm += json;
                }
                if (i < quesList.Count - 1)
                {
                    tm += ",";
                }
            }
            tm += "]";
            Response.Write(tm);
            Response.End();
        }
Exemplo n.º 9
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.º 10
0
 void fill()
 {
     try
     {
         if (id < 1)
         {
             return;
         }
         Song.Entities.ExamResults mm = Business.Do <IExamination>().ResultSingle(id);
         if (mm == null)
         {
             return;
         }
         //考生姓名,考试主题,学科
         lbAccName.Text   = mm.Ac_Name;
         lbExamTheme.Text = mm.Exam_Title;
         lbExamSbj.Text   = mm.Sbj_Name;
         //自动判卷得分
         lbScore.Text = mm.Exr_Score.ToString();
         //最终得分
         lbScoreFinal.Text = mm.Exr_ScoreFinal.ToString();
         //人工判卷
         tbDraw.Text      = mm.Exr_Draw.ToString();
         tbColligate.Text = mm.Exr_Colligate.ToString();
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
     try
     {
         if (id < 1)
         {
             return;
         }
         Song.Entities.ExamResults mm = Business.Do <IExamination>().ResultSingle(id);
         if (mm == null)
         {
             return;
         }
         //考生姓名,考试主题,学科
         lbAccName.Text   = mm.Ac_Name;
         lbExamTheme.Text = mm.Exam_Title;
         lbExamSbj.Text   = mm.Sbj_Name;
         //应试时间
         lbExamTime.Text = ((DateTime)mm.Exr_CrtTime).ToString("yyyy月MM月dd日 hh:mm");
         //采用试卷
         Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle((int)mm.Tp_Id);
         lbTestPager.Text = tp != null ? tp.Tp_Name : "";
         //自动判卷得分
         lbScore.Text = mm.Exr_Score.ToString();
         //最终得分
         lbScoreFinal.Text = mm.Exr_ScoreFinal.ToString();
         //人工判卷
         tbDraw.Text      = mm.Exr_Draw.ToString();
         tbColligate.Text = mm.Exr_Colligate.ToString();
         //展示简答题
         plJianda.Visible = bindShortQues(mm);
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 绑定简答题
        /// </summary>
        private bool bindShortQues(Song.Entities.ExamResults exr)
        {
            if (string.IsNullOrEmpty(exr.Exr_Results))
            {
                return(false);
            }
            DataTable dt = new DataTable("DataBase");

            //试题的id,题干,答案,类型
            dt.Columns.Add(new DataColumn("qid", Type.GetType("System.String")));
            dt.Columns.Add(new DataColumn("qtitle", Type.GetType("System.String")));
            dt.Columns.Add(new DataColumn("answer", Type.GetType("System.String")));
            dt.Columns.Add(new DataColumn("type", Type.GetType("System.String")));
            //试题分数,得分,考生回答内容
            dt.Columns.Add(new DataColumn("num", Type.GetType("System.String")));
            dt.Columns.Add(new DataColumn("score", Type.GetType("System.String")));
            dt.Columns.Add(new DataColumn("reply", Type.GetType("System.String")));
            //
            XmlDocument resXml = new XmlDocument();

            resXml.LoadXml(exr.Exr_Results, false);
            XmlNodeList nodeList = resXml.SelectSingleNode("results").ChildNodes;

            for (int i = 0; i < nodeList.Count; i++)
            {
                //试题的类型
                int type = Convert.ToInt32(nodeList[i].Attributes["type"].Value);
                //如果是不是简答题,跳过
                if (type != 4)
                {
                    continue;
                }
                //试题的Id
                int id = Convert.ToInt32(nodeList[i].Attributes["id"].Value);
                //试题的分数
                double num = Convert.ToDouble(nodeList[i].Attributes["num"].Value);
                //试题得分
                double score = 0;
                if (nodeList[i].Attributes["score"] != null)
                {
                    score = Convert.ToDouble(nodeList[i].Attributes["score"].Value);
                }
                //回答
                string reply = nodeList[i].InnerText;
                //生成Datatable
                DataRow dr = dt.NewRow();
                dr["qid"] = id.ToString();
                Song.Entities.Questions qus = Business.Do <IQuestions>().QuesSingle(id);
                if (qus != null)
                {
                    dr["qtitle"] = qus.Qus_Title;
                    dr["answer"] = qus.Qus_Answer;
                }
                dr["type"]  = type.ToString();
                dr["num"]   = num.ToString();
                dr["score"] = score < 1 ? "" : score.ToString();
                dr["reply"] = reply;
                dt.Rows.Add(dr);
            }
            rptQues.DataSource = dt;
            rptQues.DataBind();
            return(dt.Rows.Count > 0);
        }