Пример #1
0
        protected void FillPaper()
        {
            // QueryString id stands for EXAM_RESULT_ID
            string strId = Request.QueryString.Get("id");
            string orgid = Request.QueryString.Get("orgid");

            // Not pass id
            if (string.IsNullOrEmpty(strId))
            {
                SessionSet.PageMessage = "参数错误!";

                return;
            }

            RandomExamResultBLL randomExamResultBLL = new RandomExamResultBLL();
            RandomExamResult    randomExamResult    = new RandomExamResult();

            if (ViewState["NowOrgID"].ToString() != orgid)
            {
                randomExamResult = randomExamResultBLL.GetRandomExamResultByOrgID(int.Parse(strId), int.Parse(orgid));
            }
            else
            {
                randomExamResult = randomExamResultBLL.GetRandomExamResultTemp(int.Parse(strId));
            }
            int RandomExamId       = randomExamResult.RandomExamId;
            int randomExamResultId = int.Parse(strId);

            OracleAccess  db     = new OracleAccess();
            RandomExamBLL objBll = new RandomExamBLL();
            int           year   = objBll.GetExam(RandomExamId).BeginTime.Year;

            RandomExamItemBLL              randomItemBLL             = new RandomExamItemBLL();
            RandomExamSubjectBLL           subjectBLL                = new RandomExamSubjectBLL();
            RandomExamResultAnswerBLL      randomExamResultAnswerBLL = new RandomExamResultAnswerBLL();
            IList <RandomExamSubject>      randomExamSubjects        = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId);
            IList <RandomExamResultAnswer> examResultAnswers         = new List <RandomExamResultAnswer>();

            if (ViewState["NowOrgID"].ToString() != orgid)
            {
                examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersByOrgID(int.Parse(strId), int.Parse(orgid));
            }
            else
            {
                examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswers(randomExamResultId);
            }

            int z = 1;

            if (randomExamSubjects != null)
            {
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject      paperSubject = randomExamSubjects[i];
                    IList <RandomExamItem> PaperItems   = new List <RandomExamItem>();
                    if (ViewState["NowOrgID"].ToString() != orgid)
                    {
                        PaperItems = randomItemBLL.GetItemsByOrgID(paperSubject.RandomExamSubjectId, randomExamResultId, int.Parse(orgid), year);
                    }
                    else
                    {
                        PaperItems = randomItemBLL.GetItems(paperSubject.RandomExamSubjectId, randomExamResultId, year);
                    }

                    Response.Write("<table width='100%'>");
                    Response.Write(" <tr > <td class='ExamBigTitle' >");
                    Response.Write(" " + GetNo(i) + "");
                    Response.Write(".&nbsp;" + paperSubject.SubjectName + "");
                    Response.Write("  (共" + paperSubject.ItemCount + "题,共" + System.String.Format("{0:0.##}", paperSubject.ItemCount * paperSubject.UnitScore) + "分)</td></tr >");

                    if (PaperItems != null)
                    {
                        for (int j = 0; j < PaperItems.Count; j++)
                        {
                            RandomExamItem paperItem = PaperItems[j];
                            int            k         = j + 1;

                            if (paperItem.TypeId != 5)
                            {
                                z = 1;
                                Response.Write("<tr > <td class='ExamResultItem'>&nbsp;&nbsp;&nbsp;"
                                               + k + ".&nbsp; " + paperItem.Content + "&nbsp;&nbsp;(" +
                                               System.String.Format("{0:0.##}", paperSubject.UnitScore) +
                                               "分)</td></tr >");
                            }
                            else
                            {
                                string strSql = "select * from Random_Exam_Item_" + year + " where Item_ID='" +
                                                paperItem.ItemId + "' and Random_Exam_ID=" + RandomExamId;
                                DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];

                                IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(Convert.ToInt32(dr["Parent_Item_ID"]), RandomExamId, year);

                                Response.Write("<tr > <td class='ExamResultItem'>&nbsp;&nbsp;&nbsp;("
                                               + z + ").&nbsp; " + paperItem.Content + "&nbsp;&nbsp;(" + System.String.Format("{0:0.##}", (decimal)paperSubject.UnitScore / (decimal)randomExamItems.Count) +
                                               "分)</td></tr >");
                                z++;
                            }

                            // 组织用户答案
                            RandomExamResultAnswer theExamResultAnswer = null;
                            string[] strUserAnswers = new string[0];
                            string   strUserAnswer  = string.Empty;

                            foreach (RandomExamResultAnswer resultAnswer in examResultAnswers)
                            {
                                if (resultAnswer.RandomExamItemId == paperItem.RandomExamItemId)
                                {
                                    theExamResultAnswer = resultAnswer;
                                    break;
                                }
                            }

                            // 若子表无记录,结束页面输出
                            if (theExamResultAnswer == null)
                            {
                                SessionSet.PageMessage = "数据错误!";
                            }

                            // 否则组织考生答案
                            if (theExamResultAnswer.Answer != null || theExamResultAnswer.Answer == string.Empty)
                            {
                                strUserAnswers = theExamResultAnswer.Answer.Split(new char[] { '|' });
                            }


                            for (int n = 0; n < strUserAnswers.Length; n++)
                            {
                                string strN = intToString(int.Parse(strUserAnswers[n]) + 1);
                                if (n == 0)
                                {
                                    strUserAnswer += strN;
                                }
                                else
                                {
                                    strUserAnswer += "," + strN;
                                }
                            }

                            //多选


                            if (paperSubject.ItemTypeId == 2)
                            {
                                string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' });
                                for (int n = 0; n < strAnswer.Length; n++)
                                {
                                    string strN = intToString(n + 1);
                                    Response.Write(" <tr ><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
                                                   + strN + "." + strAnswer[n] + "</td></tr >");
                                }
                            }
                            else if (paperSubject.ItemTypeId == 1 || paperSubject.ItemTypeId == 3 || paperItem.TypeId == 5)
                            {
                                //单选


                                string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' });
                                for (int n = 0; n < strAnswer.Length; n++)
                                {
                                    string strN = intToString(n + 1);

                                    Response.Write("<tr > <td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
                                                   + strN + "." + strAnswer[n] + "</td></tr >");
                                }
                            }

                            if (paperSubject.ItemTypeId == 1 || paperSubject.ItemTypeId == 2 || paperSubject.ItemTypeId == 3 || paperItem.TypeId == 5)
                            {
                                // 组织正确答案
                                string[] strRightAnswers = paperItem.StandardAnswer.Split(new char[] { '|' });
                                string   strRightAnswer  = "";
                                for (int n = 0; n < strRightAnswers.Length; n++)
                                {
                                    string strN = intToString(int.Parse(strRightAnswers[n]) + 1);
                                    if (n == 0)
                                    {
                                        strRightAnswer += strN;
                                    }
                                    else
                                    {
                                        strRightAnswer += "," + strN;
                                    }
                                }

                                string strScore = "0";

                                if (paperItem.TypeId == 5)
                                {
                                    if (strRightAnswer == strUserAnswer)
                                    {
                                        strScore = System.String.Format("{0:0.##}", paperItem.Score);
                                    }
                                }
                                else
                                {
                                    if (strRightAnswer == strUserAnswer)
                                    {
                                        strScore = System.String.Format("{0:0.##}", paperSubject.UnitScore);
                                    }
                                }


                                if (strScore == "0")
                                {
                                    Response.Write(" <tr><td class='ExamAnswerZero'>&nbsp;&nbsp;&nbsp;★标准答案:"
                                                   + "<span id='span-" + paperItem.RandomExamItemId + "-0' name='span-" +
                                                   paperItem.RandomExamItemId
                                                   + "'>" + strRightAnswer + "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考生答案:"
                                                   + "<span id='span-" + paperItem.RandomExamItemId + "-1' name='span-" +
                                                   paperItem.RandomExamItemId
                                                   + "'>" + strUserAnswer + "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;得分:" + strScore + "</td></tr>");
                                }
                                else
                                {
                                    Response.Write(" <tr><td class='ExamAnswer'>&nbsp;&nbsp;&nbsp;★标准答案:"
                                                   + "<span id='span-" + paperItem.RandomExamItemId + "-0' name='span-" +
                                                   paperItem.RandomExamItemId
                                                   + "'>" + strRightAnswer + "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考生答案:"
                                                   + "<span id='span-" + paperItem.RandomExamItemId + "-1' name='span-" +
                                                   paperItem.RandomExamItemId
                                                   + "'>" + strUserAnswer + "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;得分:" + strScore + "</td></tr>");
                                }
                            }
                        }
                    }
                    Response.Write(" </table> ");
                }
            }
            else
            {
                SessionSet.PageMessage = "数据错误!";

                return;
            }
        }
Пример #2
0
        protected void FillPaper()
        {
            // QueryString id stands for EXAM_RESULT_ID
            string strId = Request.QueryString.Get("id");
            string orgid = Request.QueryString.Get("orgid");

            // Not pass id
            if (string.IsNullOrEmpty(strId))
            {
                SessionSet.PageMessage = "参数错误!";
                return;
            }

            RandomExamResultBLL randomExamResultBLL = new RandomExamResultBLL();
            RandomExamResult    randomExamResult    = new RandomExamResult();

            randomExamResult = randomExamResultBLL.GetRandomExamResultStation(int.Parse(strId));
            int RandomExamId       = randomExamResult.RandomExamId;
            int randomExamResultId = int.Parse(strId);

            RandomExamBLL objBll = new RandomExamBLL();
            int           year   = objBll.GetExam(RandomExamId).BeginTime.Year;

            RandomExamItemBLL         randomItemBLL      = new RandomExamItemBLL();
            RandomExamSubjectBLL      subjectBLL         = new RandomExamSubjectBLL();
            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId);

            //RandomExamResultAnswerBLL randomExamResultAnswerBLL = new RandomExamResultAnswerBLL();
            //IList<RandomExamResultAnswer> examResultAnswers = new List<RandomExamResultAnswer>();
            //if (ViewState["NowOrgID"].ToString() != orgid)
            //{
            //    examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersStation(randomExamResultId);
            //}
            //else
            //{
            //    examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswers(randomExamResultId);
            //}

            IList <RandomExamItem> TotalItems = new List <RandomExamItem>();

            //按年取出每张试卷的Random_Exam_Item_Year 表中的记录
            if (ViewState["NowOrgID"].ToString() != orgid)
            {
                TotalItems = randomItemBLL.GetItemsStation(0, randomExamResultId, year);
            }
            else
            {
                TotalItems = randomItemBLL.GetItems(0, randomExamResultId, year);
            }

            OracleAccess db = new OracleAccess();

            //按考试取出每张试卷的完形填空子题
            string    strSql   = "select * from Random_Exam_Item_" + year + " where Type_ID=" + PrjPub.ITEMTYPE_FILLBLANKDETAIL + " and Random_Exam_ID=" + RandomExamId;
            DataTable dtDetail = db.RunSqlDataSet(strSql).Tables[0];

            //按考试取出每张试卷的完形填空主题
            //strSql = "select * from Random_Exam_Item_" + year + " where Type_ID="+ PrjPub.ITEMTYPE_FILLBLANK +" and Random_Exam_ID=" + RandomExamId;
            //DataTable dt= db.RunSqlDataSet(strSql).Tables[0];

            int z       = 1;
            int hasyear = 0;

            if (randomExamSubjects != null)
            {
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject      paperSubject = randomExamSubjects[i];
                    IList <RandomExamItem> PaperItems   = new List <RandomExamItem>();

                    PaperItems = GetSubjectItems(TotalItems, paperSubject.RandomExamSubjectId);

                    if (ViewState["NowOrgID"].ToString() != orgid)
                    {
                        //PaperItems = randomItemBLL.GetItemsStation(paperSubject.RandomExamSubjectId, randomExamResultId,  year);
                        hasyear = 1;
                    }
                    else
                    {
                        //PaperItems = randomItemBLL.GetItems(paperSubject.RandomExamSubjectId, randomExamResultId, year);
                        hasyear = 0;
                    }

                    Response.Write("<table width='100%'>");
                    Response.Write(" <tr > <td class='ExamBigTitle' >");
                    Response.Write(" " + GetNo(i) + "");
                    Response.Write(".&nbsp;" + paperSubject.SubjectName + "");
                    Response.Write("  (共" + paperSubject.ItemCount + "题,共" + System.String.Format("{0:0.##}", paperSubject.ItemCount * paperSubject.UnitScore) + "分)</td></tr >");

                    if (PaperItems != null)
                    {
                        int x = 1;
                        for (int j = 0; j < PaperItems.Count; j++)
                        {
                            RandomExamItem paperItem = PaperItems[j];
                            int            k         = j + 1;

                            if (paperItem.TypeId != 5)
                            {
                                if (paperItem.TypeId == 4)
                                {
                                    k = x;
                                    x++;
                                }

                                z = 1;
                                Response.Write("<tr > <td class='ExamResultItem'><a name='Test" + i + j + "' id='Test" + i + j + "'></a>&nbsp;&nbsp;&nbsp;"
                                               + k + ".&nbsp; " + paperItem.Content + "&nbsp;&nbsp;(" +
                                               System.String.Format("{0:0.##}", paperSubject.UnitScore) +
                                               "分)</td></tr >");
                            }
                            else
                            {
                                //string strSql = "select * from Random_Exam_Item_" + year + " where Item_ID='" +
                                //                paperItem.ItemId + "' and Random_Exam_ID=" + RandomExamId;
                                //DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];
                                //IList<RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(Convert.ToInt32(dr["Parent_Item_ID"]), RandomExamId, year);

                                //查找当前完型子题的主题ID
                                DataRow[] drsDetail = dtDetail.Select("Item_ID=" + paperItem.ItemId);

                                int detailCount = 0;
                                if (drsDetail.Length > 0)
                                {
                                    //通过完形填空的主题ID查找完形填空的子题个数,为计算每个子题分数做准备
                                    DataRow[] drs = dtDetail.Select("Parent_Item_ID=" + drsDetail[0]["Parent_Item_ID"]);
                                    detailCount = drs.Length;
                                }

                                Response.Write("<tr > <td class='ExamResultItem'><a name='Test" + i + j + "' id='Test" + i + j + "'></a>&nbsp;&nbsp;&nbsp;"//+ z + ").&nbsp; "
                                               + paperItem.Content + "&nbsp;&nbsp;(" + System.String.Format("{0:0.##}", (decimal)paperSubject.UnitScore / (decimal)detailCount) +
                                               "分)</td></tr >");
                                z++;
                            }

                            string[] strUserAnswers = new string[0];
                            string   strUserAnswer  = string.Empty;

                            // 组织用户答案
                            //RandomExamResultAnswer theExamResultAnswer = null;
                            //foreach (RandomExamResultAnswer resultAnswer in examResultAnswers)
                            //{
                            //    if (resultAnswer.RandomExamItemId == paperItem.RandomExamItemId)
                            //    {
                            //        theExamResultAnswer = resultAnswer;
                            //        break;
                            //    }
                            //}
                            //// 若子表无记录,结束页面输出
                            //if (theExamResultAnswer == null)
                            //{
                            //    SessionSet.PageMessage = "数据错误!";
                            //}
                            //// 否则组织考生答案
                            //if (theExamResultAnswer.Answer != null || theExamResultAnswer.Answer == string.Empty)
                            //{
                            //    strUserAnswers = theExamResultAnswer.Answer.Split(new char[] { '|' });
                            //}

                            if (paperItem.Answer == null)
                            {
                                SessionSet.PageMessage = "数据错误!";
                            }

                            if (!string.IsNullOrEmpty(paperItem.Answer))
                            {
                                strUserAnswers = paperItem.Answer.Split(new char[] { '|' });
                            }

                            for (int n = 0; n < strUserAnswers.Length; n++)
                            {
                                string strN = intToString(int.Parse(strUserAnswers[n]) + 1);
                                if (n == 0)
                                {
                                    strUserAnswer += strN;
                                }
                                else
                                {
                                    strUserAnswer += "," + strN;
                                }
                            }

                            //多选


                            if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_MULTICHOOSE)
                            {
                                string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' });
                                for (int n = 0; n < strAnswer.Length; n++)
                                {
                                    string strN  = intToString(n + 1);
                                    string strij = "-" + paperItem.RandomExamItemId + "-" + i.ToString() + "-"
                                                   + j.ToString() + "-" + n.ToString();
                                    string strName = i.ToString() + j.ToString();

                                    Response.Write(" <tr ><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
                                                   + strN + "." + strAnswer[n] + "</td></tr >");
                                }
                            }
                            else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_JUDGE || paperSubject.ItemTypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || paperItem.TypeId == 5)
                            {
                                //单选


                                string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' });
                                for (int n = 0; n < strAnswer.Length; n++)
                                {
                                    string strN = intToString(n + 1);
                                    Response.Write("<tr > <td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
                                                   + strN + "." + strAnswer[n] + "</td></tr >");
                                }
                            }

                            if (paperSubject.ItemTypeId == 1 || paperSubject.ItemTypeId == 2 || paperSubject.ItemTypeId == 3 || paperItem.TypeId == 5)
                            {
                                // 组织正确答案
                                string[] strRightAnswers = paperItem.StandardAnswer.Split(new char[] { '|' });
                                string   strRightAnswer  = "";
                                for (int n = 0; n < strRightAnswers.Length; n++)
                                {
                                    string strN = intToString(int.Parse(strRightAnswers[n]) + 1);
                                    if (n == 0)
                                    {
                                        strRightAnswer += strN;
                                    }
                                    else
                                    {
                                        strRightAnswer += "," + strN;
                                    }
                                }

                                string strScore   = "0";
                                string couldScore = "0";
                                if (paperItem.TypeId == 5)
                                {
                                    if (strRightAnswer == strUserAnswer)
                                    {
                                        strScore = System.String.Format("{0:0.##}", paperItem.Score);
                                    }

                                    couldScore = paperItem.Score.ToString();
                                }
                                else
                                {
                                    if (strRightAnswer == strUserAnswer)
                                    {
                                        strScore = System.String.Format("{0:0.##}", paperSubject.UnitScore);
                                    }

                                    couldScore = paperSubject.UnitScore.ToString();
                                }

                                if (strScore == "0")
                                {
                                    if (hfLoginEmployeeID.Value == "0")
                                    {
                                        string strFirst = @"""";
                                        Response.Write(" <tr><td id='span-" + paperItem.RandomExamItemId + "' class='ExamAnswerZero'>&nbsp;&nbsp;&nbsp;★标准答案:"
                                                       + "<span id='span-" + paperItem.RandomExamItemId + "-0' name='span-" +
                                                       paperItem.RandomExamItemId
                                                       + "'>" + strRightAnswer +
                                                       "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考生答案:"
                                                       + "<span id='span-" + paperItem.RandomExamItemId + "-1' name='span-" +
                                                       paperItem.RandomExamItemId
                                                       + "'>" + strUserAnswer +
                                                       "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;得分:" +
                                                       "<span id='span-" + paperItem.RandomExamItemId + "-2'>" + strScore +
                                                       "</span>"
                                                       + "&nbsp;&nbsp;&nbsp;<a id='a-" + paperItem.RandomExamItemId + "' onclick=" + strFirst + "updateScore(" + randomExamResultId + "," + paperItem.RandomExamItemId + "," + couldScore + ",'" + paperItem.StandardAnswer + "'," + hasyear + ")" + strFirst
                                                       + " href='#Test" + i + j + "' style='cursor: hand;'>更改考生答案</a></td></tr>");
                                    }
                                    else
                                    {
                                        Response.Write(" <tr><td class='ExamAnswerZero'>&nbsp;&nbsp;&nbsp;★标准答案:"
                                                       + "<span id='span-" + paperItem.RandomExamItemId + "-0' name='span-" +
                                                       paperItem.RandomExamItemId
                                                       + "'>" + strRightAnswer +
                                                       "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考生答案:"
                                                       + "<span id='span-" + paperItem.RandomExamItemId + "-1' name='span-" +
                                                       paperItem.RandomExamItemId
                                                       + "'>" + strUserAnswer +
                                                       "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;得分:" +
                                                       "<span id='span-" + paperItem.RandomExamItemId + "-2'>" + strScore +
                                                       "</span></td></tr>");
                                    }
                                }
                                else
                                {
                                    Response.Write(" <tr><td class='ExamAnswer'>&nbsp;&nbsp;&nbsp;★标准答案:"
                                                   + "<span id='span-" + paperItem.RandomExamItemId + "-0' name='span-" +
                                                   paperItem.RandomExamItemId
                                                   + "'>" + strRightAnswer +
                                                   "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考生答案:"
                                                   + "<span id='span-" + paperItem.RandomExamItemId + "-1' name='span-" +
                                                   paperItem.RandomExamItemId
                                                   + "'>" + strUserAnswer +
                                                   "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;得分:" + strScore +
                                                   "</td></tr>");
                                }
                            }
                        }
                    }
                    Response.Write(" </table> ");
                }
            }
            else
            {
                SessionSet.PageMessage = "数据错误!";

                return;
            }
        }