Exemplo n.º 1
0
        public RandomExamSubject GetRandomExamSubject(int RandomExamSubjectId)
        {
            RandomExamSubject Paper;

            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_Random_Exam_Subject_G";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "p_Random_Exam_Subject_id", DbType.Int32, RandomExamSubjectId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    Paper = SubjectNamelObject(dataReader);
                }
                else
                {
                    Paper = new RandomExamSubject();
                }
            }

            return(Paper);
        }
Exemplo n.º 2
0
        private void DeleteData(int nBookID)
        {
            RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
            RandomExamSubject    paperStrategySubject    = paperStrategySubjectBLL.GetRandomExamSubject(int.Parse(Request.QueryString.Get("id")));

            if (paperStrategySubject != null)
            {
                RandomExamResultBLL reBll = new RandomExamResultBLL();
                IList <RailExam.Model.RandomExamResult> examResults = reBll.GetRandomExamResultByExamID(paperStrategySubject.RandomExamId);

                if (Pub.HasPaper(Convert.ToInt32(paperStrategySubject.RandomExamId)))
                {
                    SessionSet.PageMessage = "该考试已生成试卷,取题范围不能被删除!";
                    return;
                }

                if (examResults.Count > 0)
                {
                    SessionSet.PageMessage = "已有考生参加考试,取题范围不能被删除!";
                    return;
                }
            }

            RandomExamStrategyBLL paperStrategyBookChapterBLL = new RandomExamStrategyBLL();

            paperStrategyBookChapterBLL.DeleteRandomExamStrategy(nBookID);

            OracleAccess db     = new OracleAccess();
            string       strSql = "delete from Random_Exam_Strategy where Is_Mother_Item=1 and Mother_ID=" + nBookID;

            db.ExecuteNonQuery(strSql);

            strSql = "delete from Random_Exam_Item_Select where  RANDOM_EXAM_STRATEGY_ID=" + nBookID;
            db.ExecuteNonQuery(strSql);
        }
Exemplo n.º 3
0
        public IList <RandomExamSubject> GetRandomExamSubjectByRandomExamId(int RandomExamId)
        {
            IList <RandomExamSubject> Papers = new List <RandomExamSubject>();

            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_Random_Exam_SUBJECT_Q";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "p_Random_Exam_Id", DbType.Int32, RandomExamId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    RandomExamSubject Paper = SubjectNamelObject(dataReader);
                    Papers.Add(Paper);
                }
            }
            return(Papers);
        }
Exemplo n.º 4
0
        public int AddRandomExamSubject(RandomExamSubject Paper)
        {
            int      i  = 0;
            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_random_exam_subject_I";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "p_random_exam_ID", DbType.Int32, Paper.RandomExamId);
            db.AddOutParameter(dbCommand, "p_random_exam_Subject_Id", DbType.Int32, Paper.RandomExamSubjectId);
            db.AddInParameter(dbCommand, "p_Order_Index", DbType.String, Paper.OrderIndex);
            db.AddInParameter(dbCommand, "p_Item_Count", DbType.Int32, Paper.ItemCount);
            db.AddInParameter(dbCommand, "p_Item_Type_Id", DbType.Int32, Paper.ItemTypeId);
            db.AddInParameter(dbCommand, "p_Remark", DbType.String, Paper.Remark);
            db.AddInParameter(dbCommand, "p_Subject_Name", DbType.String, Paper.SubjectName);
            db.AddInParameter(dbCommand, "p_Total_Score", DbType.Decimal, Paper.TotalScore);
            db.AddInParameter(dbCommand, "p_Unit_Score", DbType.Decimal, Paper.UnitScore);
            db.AddInParameter(dbCommand, "p_memo", DbType.String, Paper.Memo);

            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                db.ExecuteNonQuery(dbCommand, transaction);

                i = (int)db.GetParameterValue(dbCommand, "p_random_exam_subject_Id");
                transaction.Commit();
            }
            catch (System.SystemException ex)
            {
                transaction.Rollback();
                throw ex;
            }
            connection.Close();
            return(i);
        }
Exemplo n.º 5
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;
            }
        }
        protected void FillPaper()
        {
            string strId = Request.QueryString.Get("id");

            if (string.IsNullOrEmpty(strId))
            {
                SessionSet.PageMessage = "缺少参数!";

                return;
            }

            RandomExamItemBLL     randomItemBLL = new RandomExamItemBLL();
            RandomExamSubjectBLL  subjectBLL    = new RandomExamSubjectBLL();
            RandomExamStrategyBLL strategyBLL   = new RandomExamStrategyBLL();

            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

            if (randomExamSubjects != null)
            {
                Hashtable hashTableItemIds = new Hashtable();
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject paperSubject = randomExamSubjects[i];
                    int nSubjectId = paperSubject.RandomExamSubjectId;
                    //  int nItemCount = paperSubject.ItemCount;

                    Hashtable htSubjectItemIds           = new Hashtable();
                    IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                    for (int j = 0; j < strategys.Count; j++)
                    {
                        int nStrategyId = strategys[j].RandomExamStrategyId;
                        int nItemCount  = strategys[j].ItemCount;
                        IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, Convert.ToInt32(ViewState["Year"].ToString()));

                        // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId);

                        Random    ObjRandom      = new Random();
                        Hashtable hashTable      = new Hashtable();
                        Hashtable hashTableCount = new Hashtable();
                        while (hashTable.Count < nItemCount)
                        {
                            int k = ObjRandom.Next(itemList.Count);
                            hashTableCount[k] = k;
                            int itemID     = itemList[k].ItemId;
                            int examItemID = itemList[k].RandomExamItemId;
                            if (!hashTableItemIds.ContainsKey(itemID))
                            {
                                hashTable[examItemID]        = examItemID;
                                hashTableItemIds[itemID]     = itemID;
                                htSubjectItemIds[examItemID] = examItemID;
                            }
                            if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                            {
                                SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                                return;
                            }
                        }
                    }

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

                    foreach (int key in htSubjectItemIds.Keys)
                    {
                        string         strItemId = htSubjectItemIds[key].ToString();
                        RandomExamItem item      = randomItemBLL.GetRandomExamItem(int.Parse(strItemId), Convert.ToInt32(ViewState["Year"].ToString()));
                        paperItems.Add(item);
                    }


                    Response.Write("<table width='95%' class='ExamContent'>");
                    Response.Write(" <tr> <td class='ExamBigTitle' >");
                    Response.Write(" " + GetNo(i) + "");
                    Response.Write("、" + paperSubject.SubjectName + "");
                    Response.Write("  (共" + paperItems.Count + "题,共" + paperItems.Count * paperSubject.UnitScore + "分)</td></tr >");

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

                            if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                k = y;
                                y++;
                            }
                            else if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANKDETAIL)
                            {
                                continue;
                            }

                            Response.Write("<tr><td class='ExamItem'>&nbsp;&nbsp;&nbsp;" + k + ".&nbsp; " + paperItem.Content +
                                           "&nbsp;&nbsp; (" + paperSubject.UnitScore + "分)</td></tr >");

                            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; <input type='checkbox' id='Answer" +
                                        strij + "' name='Answer" + strName + "'> " + strN + "." + strAnswer[n] +
                                        "</td></tr>");
                                }
                            }
                            else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || paperSubject.ItemTypeId == PrjPub.ITEMTYPE_JUDGE)    //单选
                            {
                                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; <input type='Radio' id='RAnswer" +
                                        strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] +
                                        "</td></tr>");
                                }
                            }
                            else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                IList <RandomExamItem> randomExamItems =
                                    randomItemBLL.GetItemsByParentItemID(paperItem.ItemId, Convert.ToInt32(strId),
                                                                         Convert.ToInt32(ViewState["Year"].ToString()));

                                int z = 1;
                                foreach (RandomExamItem randomExamItem in randomExamItems)
                                {
                                    Response.Write("<tr><td class='ExamItem'>&nbsp;&nbsp;&nbsp;(" + z + ").&nbsp; " + randomExamItem.Content +
                                                   "&nbsp;&nbsp; (" + System.String.Format("{0:0.##}", (decimal)paperSubject.UnitScore / (decimal)randomExamItems.Count) + "分)</td></tr >");

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

                                        Response.Write(
                                            "<tr><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='Radio' id='RAnswer" +
                                            strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] +
                                            "</td></tr>");
                                    }
                                    z++;
                                }
                            }
                            else
                            {
                                Response.Write(
                                    "<tr><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <textarea id='" + paperItem.RandomExamItemId + "' rows='5' cols='120' ></textarea></td></tr>");
                            }
                        }
                    }
                    Response.Write("</table>");
                }

                Response.Write(" <div class='ExamButton'><input id='btnClose' class='button' name='btnClose' type='button' value='关闭' onclick='Save()' /></div>");
            }
            else
            {
                SessionSet.PageMessage = "未找到记录!";
            }
        }
        private void GetPaper()
        {
            // 根据 ProgressBar.htm 显示进度条界面
            string       templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");
            StreamReader reader           = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312"));
            string       html             = reader.ReadToEnd();

            reader.Close();
            Response.Write(html);
            Response.Flush();
            System.Threading.Thread.Sleep(200);

            string jsBlock;

            ViewState["BeginTime"] = DateTime.Now.ToString();
            string strId = Request.QueryString.Get("RandomExamID");

            //获取当前考试的生成试卷的状态和次数
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId));

            int year      = obj.BeginTime.Year;
            int ExamCount = obj.MaxExamTimes;

            RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL();
            IList <RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId));
            string       strChooseID = "";
            OracleAccess db          = new OracleAccess();
            OracleAccess dbCenter    = new OracleAccess(System.Configuration.ConfigurationManager.ConnectionStrings["OracleCenter"].ConnectionString);

            string strSql;

            if (ExamArranges.Count > 0)
            {
                strSql = "select a.* from Random_Exam_Arrange_Detail a "
                         + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID"
                         + " inner join Computer_Server c on c.Computer_server_ID=b.Computer_Server_ID"
                         + " where c.Computer_Server_No='" + PrjPub.ServerNo + "' "
                         + " and Random_Exam_ID=" + strId;

                DataSet ds = db.RunSqlDataSet(strSql);

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (string.IsNullOrEmpty(strChooseID))
                    {
                        strChooseID += dr["User_Ids"].ToString();
                    }
                    else
                    {
                        strChooseID += "," + dr["User_Ids"];
                    }
                }
            }
            else
            {
                strChooseID = "";
            }

            if (strChooseID == "")
            {
                Response.Write("<script>top.returnValue='本场考试未在本单位安排考生!';window.close();</script>");
                return;
            }

            if (db.GetCount("RANDOM_EXAM_ITEM_TEMP_" + year, "TABLE") == 0)
            {
                strSql = "create table RANDOM_EXAM_ITEM_TEMP_" + year + "  as select * from RANDOM_EXAM_ITEM_" + year + " where 1=2 ";
                db.ExecuteNonQuery(strSql);
            }
            strSql = "insert into RANDOM_EXAM_ITEM_TEMP_" + year + " select * from RANDOM_EXAM_ITEM_" + year + " where Random_Exam_ID=" + strId;
            db.ExecuteNonQuery(strSql);

            if (!PrjPub.IsServerCenter)
            {
                if (dbCenter.GetCount("RANDOM_EXAM_ITEM_TEMP_" + year, "TABLE") == 0)
                {
                    strSql = "create table RANDOM_EXAM_ITEM_TEMP_" + year + "  as select * from RANDOM_EXAM_ITEM_" + year + " where 1=2 ";
                    dbCenter.ExecuteNonQuery(strSql);
                }
                strSql = "insert into RANDOM_EXAM_ITEM_TEMP_" + year + " select * from RANDOM_EXAM_ITEM_" + year + " where Random_Exam_ID=" + strId;
                dbCenter.ExecuteNonQuery(strSql);
            }

            System.Threading.Thread.Sleep(10);
            jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)2) + "'); </script>");
            Response.Write(jsBlock);
            Response.Flush();


            //每次生成试卷之前删除已生成的考试试卷
            RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();

            randomExamResultBLL.DelRandomExamResultCurrent(Convert.ToInt32(strId));
            System.Threading.Thread.Sleep(10);
            jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>");
            Response.Write(jsBlock);
            Response.Flush();

            System.Threading.Thread.Sleep(200);
            jsBlock = string.Empty;

            string[] str = strChooseID.Split(',');

            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            //定义全局答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>();
            //定义一个考生一次答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null;

            int progressNum = 1;

            for (int n = 1; n <= ExamCount; n++)
            {
                for (int m = 0; m < str.Length; m++)
                {
                    RandomExamResultCurrent randomExamResult = new RandomExamResultCurrent();

                    randomExamResult.RandomExamId    = int.Parse(strId);
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.BeginDateTime   = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.ExamTime        = 0;
                    randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.Score           = 0;
                    randomExamResult.OrganizationId  = int.Parse(ConfigurationManager.AppSettings["StationID"]);
                    randomExamResult.Memo            = "";
                    randomExamResult.StatusId        = 0;
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.CorrectRate     = 0;
                    randomExamResult.ExamineeId      = int.Parse(str[m]);
                    randomExamResult.ExamSeqNo       = n;

                    int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult);
                    ViewState["RandomExamResultPK"] = nRandomExamResultPK;

                    strSql = "select a.* from Random_Exam_Arrange_Detail a "
                             + " where ','||User_Ids||',' like '%," + str[m] + ",%' "
                             + " and Random_Exam_ID=" + strId;
                    DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];

                    //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID,"
                    //         + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) "
                    //         + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                    //         + nRandomExamResultPK + ","
                    //         + randomExamResult.RandomExamId + ","
                    //         + randomExamResult.ExamineeId + ","
                    //         + "0," + dr["Computer_Room_ID"] + ") ";
                    //db.ExecuteNonQuery(strSql);

                    strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID,"
                             + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) "
                             + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                             + nRandomExamResultPK + ","
                             + randomExamResult.RandomExamId + ","
                             + randomExamResult.ExamineeId + ","
                             + "0," + dr["Computer_Room_ID"] + ",0) ";
                    db.ExecuteNonQuery(strSql);

                    RandomExamItemBLL     randomItemBLL = new RandomExamItemBLL();
                    RandomExamSubjectBLL  subjectBLL    = new RandomExamSubjectBLL();
                    RandomExamStrategyBLL strategyBLL   = new RandomExamStrategyBLL();

                    IList <RandomExamSubject> randomExamSubjects =
                        subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

                    if (randomExamSubjects != null)
                    {
                        Hashtable hashTableItemIds = new Hashtable();
                        Hashtable htSubjectItemIds = new Hashtable();
                        for (int i = 0; i < randomExamSubjects.Count; i++)
                        {
                            RandomExamSubject paperSubject = randomExamSubjects[i];
                            int nSubjectId = paperSubject.RandomExamSubjectId;
                            //  int nItemCount = paperSubject.ItemCount;

                            IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                            for (int j = 0; j < strategys.Count; j++)
                            {
                                int nStrategyId = strategys[j].RandomExamStrategyId;
                                int nItemCount  = strategys[j].ItemCount;
                                IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year);

                                // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId);

                                Random    ObjRandom      = new Random();
                                Hashtable hashTable      = new Hashtable();
                                Hashtable hashTableCount = new Hashtable();
                                int       index          = 0;
                                while (hashTable.Count < nItemCount)
                                {
                                    int k = ObjRandom.Next(itemList.Count);
                                    hashTableCount[index] = k;
                                    index = index + 1;
                                    int itemID     = itemList[k].ItemId;
                                    int examItemID = itemList[k].RandomExamItemId;
                                    if (!hashTableItemIds.ContainsKey(itemID))
                                    {
                                        hashTable[examItemID]        = examItemID;
                                        hashTableItemIds[itemID]     = itemID;
                                        htSubjectItemIds[examItemID] = examItemID;
                                    }
                                    //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                                    //{
                                    //    SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                                    //    return;
                                    //}
                                }
                            }
                        }


                        foreach (int key in htSubjectItemIds.Keys)
                        {
                            string         strItemId = htSubjectItemIds[key].ToString();
                            RandomExamItem item      = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year);

                            string nowSelectAnswer   = string.Empty;
                            string nowStandardAnswer = string.Empty;
                            if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer);
                            }

                            RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                            randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                            randomExamResultAnswer.RandomExamItemId   = int.Parse(strItemId);
                            randomExamResultAnswer.JudgeStatusId      = 0;
                            randomExamResultAnswer.JudgeRemark        = string.Empty;
                            randomExamResultAnswer.ExamTime           = 0;
                            randomExamResultAnswer.Answer             = string.Empty;
                            randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                            randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                            randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);

                            //完型填空子题
                            IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year);
                            foreach (RandomExamItem randomExamItem in randomExamItems)
                            {
                                Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer);

                                randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                                randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                                randomExamResultAnswer.RandomExamItemId   = randomExamItem.RandomExamItemId;
                                randomExamResultAnswer.JudgeStatusId      = 0;
                                randomExamResultAnswer.JudgeRemark        = string.Empty;
                                randomExamResultAnswer.ExamTime           = 0;
                                randomExamResultAnswer.Answer             = string.Empty;
                                randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                                randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                                randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);
                            }

                            System.Threading.Thread.Sleep(10);
                            jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>";
                            Response.Write(jsBlock);
                            Response.Flush();

                            progressNum++;
                        }
                    }
                    else
                    {
                        SessionSet.PageMessage = "未找到记录!";
                    }
                }
            }

            bool isRefresh = true;

            try
            {
                objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true);
            }
            catch
            {
                strSql =
                    @"  update Random_Exam_Computer_Server set  has_paper=1
                      where random_exam_id=" + strId + @" and Computer_server_no='" + PrjPub.ServerNo + @"'";
                dbCenter.ExecuteNonQuery(strSql);
                strSql = @"select count(*)  from Random_Exam_Computer_Server where has_paper=1 and  random_exam_id=" + strId;
                int count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                if (count > 0)
                {
                    strSql = @"update Random_Exam set has_paper=1 where random_exam_id=" + strId;
                    dbCenter.ExecuteNonQuery(strSql);
                }
                else
                {
                    strSql = @"update Random_Exam set has_paper=0 where random_exam_id=" + strId;
                    dbCenter.ExecuteNonQuery(strSql);
                }
            }


            //如果考试是随到随考,考试状态自动变为正在进行
            if (obj.StartMode == 1)
            {
                try
                {
                    objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1);
                    isRefresh = false;
                }
                catch
                {
                    strSql =
                        @"  update Random_Exam_Computer_Server set  Is_Start=1
                      where random_exam_id=" + strId + @" and Computer_server_no='" + PrjPub.ServerNo + @"'";
                    dbCenter.ExecuteNonQuery(strSql);
                    strSql = @"select count(*)  from Random_Exam_Computer_Server where random_exam_id=" + strId;
                    int totalcount = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                    strSql = @"select count(*)  from Random_Exam_Computer_Server where Is_Start=0 and  random_exam_id=" + strId;
                    int count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                    if (totalcount == count)
                    {
                        strSql = @"update Random_Exam set Is_Start=0 where random_exam_id=" + strId;
                        dbCenter.ExecuteNonQuery(strSql);
                    }
                    else
                    {
                        strSql = @"select count(*)  from Random_Exam_Computer_Server where Is_Start=1 and  random_exam_id=" + strId;
                        count  = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                        if (count > 0)
                        {
                            strSql = @"update Random_Exam set Is_Start=1 where random_exam_id=" + strId;
                            dbCenter.ExecuteNonQuery(strSql);
                        }
                        else
                        {
                            strSql = @"select count(*)  from Random_Exam_Computer_Server where Is_Start=2 and  random_exam_id=" + strId;
                            count  = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                            if (count == totalcount)
                            {
                                strSql = @"update Random_Exam set Is_Start=2 where random_exam_id=" + strId;
                                dbCenter.ExecuteNonQuery(strSql);
                            }
                        }
                    }
                }
            }
            else
            {
                isRefresh = false;
            }

            if (isRefresh)
            {
                objBll.RandomExamRefresh();
            }

            SystemLogBLL objLogBll = new SystemLogBLL();

            objLogBll.WriteLog("“" + obj.ExamName + "”生成所有考试试卷");

            Response.Write("<script>top.returnValue='true';top.close();</script>");
        }
        private void GetPaperAfter()
        {
            // 根据 ProgressBar.htm 显示进度条界面
            string       templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");
            StreamReader reader           = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312"));
            string       html             = reader.ReadToEnd();

            reader.Close();
            Response.Write(html);
            Response.Flush();
            System.Threading.Thread.Sleep(200);

            ViewState["BeginTime"] = DateTime.Now.ToString();
            string strId = Request.QueryString.Get("RandomExamID");

            //获取当前考试的生成试卷的状态和次数
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId));

            int year      = obj.BeginTime.Year;
            int ExamCount = obj.MaxExamTimes;

            System.Threading.Thread.Sleep(10);
            string jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)1) + "'); </script>");

            Response.Write(jsBlock);
            Response.Flush();

            if (!PrjPub.IsServerCenter)
            {
                RandomExamArrangeBLL objArrangeBll = new RandomExamArrangeBLL();
                objArrangeBll.RefreshRandomExamArrange();
            }

            //RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL();
            //IList<RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId));
            //string strChooseID = "";
            //if (ExamArranges.Count > 0)
            //{
            //    strChooseID = ExamArranges[0].UserIds;
            //}
            //else
            //{
            //    strChooseID = "";
            //}

            //RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();
            //IList<RandomExamResultCurrent> examResults = objResultCurrentBll.GetRandomExamResultInfo(Convert.ToInt32(strId));
            //for (int i = 0; i < examResults.Count; i++)
            //{
            //    strChooseID = ("," + strChooseID + ",").Replace("," + examResults[i].ExamineeId + ",", ",");
            //}

            //strChooseID = strChooseID.TrimStart(',').TrimEnd(',');

            string strChooseID = Request.QueryString.Get("addIds");

            if (strChooseID == string.Empty)
            {
                return;
            }

            string[] str = strChooseID.Split('|');

            System.Threading.Thread.Sleep(10);
            jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>");
            Response.Write(jsBlock);
            Response.Flush();

            OracleAccess db = new OracleAccess();
            string       strSql;

            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            //定义全局答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>();
            //定义一个考生一次答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null;

            System.Threading.Thread.Sleep(200);
            jsBlock = string.Empty;
            int progressNum = 1;

            for (int n = 1; n <= ExamCount; n++)
            {
                for (int m = 0; m < str.Length; m++)
                {
                    RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();
                    RandomExamResultCurrent    randomExamResult    = new RandomExamResultCurrent();

                    randomExamResult.RandomExamId    = int.Parse(strId);
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.BeginDateTime   = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.ExamTime        = 0;
                    randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.Score           = 0;
                    randomExamResult.OrganizationId  = int.Parse(ConfigurationManager.AppSettings["StationID"]);
                    randomExamResult.Memo            = "";
                    randomExamResult.StatusId        = 0;
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.CorrectRate     = 0;
                    randomExamResult.ExamineeId      = int.Parse(str[m]);
                    randomExamResult.ExamSeqNo       = n;

                    int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult);
                    ViewState["RandomExamResultPK"] = nRandomExamResultPK;

                    strSql = "select a.* from Random_Exam_Arrange_Detail a "
                             + " where ','||User_Ids||',' like '%," + str[m] + ",%' "
                             + " and Random_Exam_ID=" + strId;
                    DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];


                    //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID,"
                    //         + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) "
                    //         + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                    //         + nRandomExamResultPK + ","
                    //         + randomExamResult.RandomExamId + ","
                    //         + randomExamResult.ExamineeId + ","
                    //         + "0," + dr["Computer_Room_ID"] + ") ";
                    //db.ExecuteNonQuery(strSql);


                    strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID,"
                             + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) "
                             + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                             + nRandomExamResultPK + ","
                             + randomExamResult.RandomExamId + ","
                             + randomExamResult.ExamineeId + ","
                             + "0," + dr["Computer_Room_ID"] + ",0) ";
                    db.ExecuteNonQuery(strSql);

                    RandomExamItemBLL     randomItemBLL = new RandomExamItemBLL();
                    RandomExamSubjectBLL  subjectBLL    = new RandomExamSubjectBLL();
                    RandomExamStrategyBLL strategyBLL   = new RandomExamStrategyBLL();

                    IList <RandomExamSubject> randomExamSubjects =
                        subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

                    if (randomExamSubjects != null)
                    {
                        Hashtable hashTableItemIds = new Hashtable();
                        Hashtable htSubjectItemIds = new Hashtable();
                        for (int i = 0; i < randomExamSubjects.Count; i++)
                        {
                            RandomExamSubject paperSubject = randomExamSubjects[i];
                            int nSubjectId = paperSubject.RandomExamSubjectId;
                            //  int nItemCount = paperSubject.ItemCount;

                            IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                            for (int j = 0; j < strategys.Count; j++)
                            {
                                int nStrategyId = strategys[j].RandomExamStrategyId;
                                int nItemCount  = strategys[j].ItemCount;
                                IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year);

                                // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId);

                                Random    ObjRandom      = new Random();
                                Hashtable hashTable      = new Hashtable();
                                Hashtable hashTableCount = new Hashtable();
                                int       index          = 0;
                                while (hashTable.Count < nItemCount)
                                {
                                    int k = ObjRandom.Next(itemList.Count);
                                    hashTableCount[index] = k;
                                    index = index + 1;
                                    int itemID     = itemList[k].ItemId;
                                    int examItemID = itemList[k].RandomExamItemId;
                                    if (!hashTableItemIds.ContainsKey(itemID))
                                    {
                                        hashTable[examItemID]        = examItemID;
                                        hashTableItemIds[itemID]     = itemID;
                                        htSubjectItemIds[examItemID] = examItemID;
                                    }
                                    //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                                    //{
                                    //    SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                                    //    return;
                                    //}
                                }
                            }
                        }
                        randomExamResultAnswers = new List <RandomExamResultAnswerCurrent>();
                        foreach (int key in htSubjectItemIds.Keys)
                        {
                            string strItemId = htSubjectItemIds[key].ToString();

                            RandomExamItem item = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year);

                            string nowSelectAnswer   = string.Empty;
                            string nowStandardAnswer = string.Empty;
                            if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer);
                            }

                            RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                            randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                            randomExamResultAnswer.RandomExamItemId   = int.Parse(strItemId);
                            randomExamResultAnswer.JudgeStatusId      = 0;
                            randomExamResultAnswer.JudgeRemark        = string.Empty;
                            randomExamResultAnswer.ExamTime           = 0;
                            randomExamResultAnswer.Answer             = string.Empty;
                            randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                            randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                            randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);

                            //完型填空子题
                            IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year);
                            foreach (RandomExamItem randomExamItem in randomExamItems)
                            {
                                Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer);

                                randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                                randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                                randomExamResultAnswer.RandomExamItemId   = randomExamItem.RandomExamItemId;
                                randomExamResultAnswer.JudgeStatusId      = 0;
                                randomExamResultAnswer.JudgeRemark        = string.Empty;
                                randomExamResultAnswer.ExamTime           = 0;
                                randomExamResultAnswer.Answer             = string.Empty;
                                randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                                randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                                randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);
                            }

                            System.Threading.Thread.Sleep(10);
                            jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>";
                            Response.Write(jsBlock);
                            Response.Flush();

                            progressNum++;
                        }
                    }
                    else
                    {
                        SessionSet.PageMessage = "未找到记录!";
                    }
                }
            }

            //临时添加考生无需更改考试状态,因为考试状态肯定是正在进行和生成试卷
            //objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true);
            ////如果考试是随到随考,考试状态自动变为正在进行
            //if (obj.StartMode == 1)
            //{
            //    objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1);
            //}

            SystemLogBLL objLogBll = new SystemLogBLL();

            objLogBll.WriteLog("“" + obj.ExamName + "”生成新增考生试卷");

            Response.Write("<script>top.returnValue='true';top.close();</script>");
        }
Exemplo n.º 9
0
        protected void btnInput_Click(object sender, EventArgs e)
        {
            if (lbType.SelectedIndex < 0)
            {
                SessionSet.PageMessage = "请先选题型!";
                return;
            }

            string strId = Request.QueryString.Get("id");
            RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();

            decimal totalScore = 0;
            IList <RandomExamSubject> paperStrategySubjects = new List <RandomExamSubject>();

            for (int i = 0; i < Grid1.Rows.Count; i++)
            {
                string strPaperStrategySubjectId = ((HiddenField)Grid1.Rows[i].FindControl("hfPaperStrategySubjectId")).Value;
                string strItemTypeId             = ((HiddenField)Grid1.Rows[i].FindControl("hfItemTypeId")).Value;
                string strSubjectName            = ((TextBox)Grid1.Rows[i].FindControl("txtSubjectName")).Text;
                string strUnitScore = ((TextBox)Grid1.Rows[i].FindControl("txtUnitScore")).Text;
                string strItemCount = ((TextBox)Grid1.Rows[i].FindControl("txtItemCount")).Text;

                if (strUnitScore == "")
                {
                    strUnitScore = "0";
                }

                if (strItemCount == "")
                {
                    strItemCount = "0";
                }

                totalScore += Convert.ToDecimal(strUnitScore);

                RandomExamSubject paperStrategySubject = new RandomExamSubject();
                paperStrategySubject.RandomExamSubjectId = int.Parse(strPaperStrategySubjectId);
                paperStrategySubject.RandomExamId        = int.Parse(strId);
                paperStrategySubject.ItemCount           = int.Parse(strItemCount);
                paperStrategySubject.ItemTypeId          = int.Parse(strItemTypeId);
                paperStrategySubject.OrderIndex          = 0;
                paperStrategySubject.Remark      = "";
                paperStrategySubject.SubjectName = strSubjectName;
                paperStrategySubject.UnitScore   = Convert.ToDecimal(strUnitScore);
                paperStrategySubject.TotalScore  = Convert.ToDecimal(strUnitScore);
                paperStrategySubject.Memo        = "";

                paperStrategySubjects.Add(paperStrategySubject);
            }


            if (paperStrategySubjects.Count > 0)
            {
                paperStrategySubjectBLL.UpdateRandomExamSubject(paperStrategySubjects);
            }


            RandomExamSubject RandomStrategySubject = new RandomExamSubject();

            RandomStrategySubject.RandomExamId        = int.Parse(strId);
            RandomStrategySubject.RandomExamSubjectId = Grid1.Rows.Count + 1;
            RandomStrategySubject.ItemTypeId          = int.Parse(lbType.SelectedValue);
            RandomStrategySubject.TypeName            = lbType.SelectedItem.Text;
            RandomStrategySubject.SubjectName         = lbType.SelectedItem.Text;
            RandomStrategySubject.UnitScore           = 0;
            RandomStrategySubject.TotalScore          = 0;
            RandomStrategySubject.Memo       = "";
            RandomStrategySubject.ItemCount  = 10;
            RandomStrategySubject.OrderIndex = 0;
            RandomStrategySubject.Remark     = "";

            paperStrategySubjectBLL.AddRandomExamSubject(RandomStrategySubject);

            Grid1.DataBind();
        }
Exemplo n.º 10
0
        protected void btnSaveAndNext_Click(object sender, ImageClickEventArgs e)
        {
            string strId        = Request.QueryString.Get("id");
            string strMode      = ViewState["mode"].ToString();
            string strStartMode = ViewState["startmode"].ToString();

            if (strMode != "ReadOnly")
            {
                if (Pub.HasPaper(Convert.ToInt32(strId)))
                {
                    Response.Write("<script>alert('该考试已生成试卷,不能被编辑!');window.close();</script>");
                    return;
                }

                if (Grid1.Rows.Count == 0)
                {
                    SessionSet.PageMessage = "请选择大题!";
                    return;
                }

                decimal totalScore = 0;

                IList <RandomExamSubject> paperStrategySubjects = new List <RandomExamSubject>();

                int zeroCount     = 0;
                int zeroItemCount = 0;
                for (int i = 0; i < Grid1.Rows.Count; i++)
                {
                    string strPaperStrategySubjectId = ((HiddenField)Grid1.Rows[i].FindControl("hfPaperStrategySubjectId")).Value;
                    string strItemTypeId             = ((HiddenField)Grid1.Rows[i].FindControl("hfItemTypeId")).Value;
                    string strSubjectName            = ((TextBox)Grid1.Rows[i].FindControl("txtSubjectName")).Text;
                    string strUnitScore = ((TextBox)Grid1.Rows[i].FindControl("txtUnitScore")).Text;
                    string strItemCount = ((TextBox)Grid1.Rows[i].FindControl("txtItemCount")).Text;

                    if (strUnitScore == "")
                    {
                        strUnitScore = "0";
                    }

                    if (strItemCount == "")
                    {
                        strItemCount = "0";
                    }


                    totalScore += Convert.ToDecimal(strUnitScore);

                    RandomExamSubject paperStrategySubject = new RandomExamSubject();

                    paperStrategySubject.RandomExamSubjectId = int.Parse(strPaperStrategySubjectId);
                    paperStrategySubject.RandomExamId        = int.Parse(strId);
                    paperStrategySubject.ItemCount           = int.Parse(strItemCount);
                    paperStrategySubject.ItemTypeId          = int.Parse(strItemTypeId);
                    paperStrategySubject.OrderIndex          = 0;
                    paperStrategySubject.Remark      = "";
                    paperStrategySubject.SubjectName = strSubjectName;
                    paperStrategySubject.UnitScore   = Convert.ToDecimal(strUnitScore);
                    paperStrategySubject.TotalScore  = Convert.ToDecimal(strUnitScore);
                    paperStrategySubject.Memo        = "";

                    if (strUnitScore == "0")
                    {
                        zeroCount++;
                    }

                    if (strItemCount == "0")
                    {
                        zeroItemCount++;
                    }

                    paperStrategySubjects.Add(paperStrategySubject);
                }

                if (zeroCount > 0)
                {
                    SessionSet.PageMessage = "不能设置每题为0分的大题,请输入每题分数!";
                    return;
                }

                if (zeroItemCount > 0)
                {
                    SessionSet.PageMessage = "不能设置题目数为0的大题,请输入大题题数!";
                    return;
                }

                RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
                paperStrategySubjectBLL.UpdateRandomExamSubject(paperStrategySubjects);
            }

            Response.Redirect("RandomExamManageThird.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&id=" + strId);
        }
Exemplo n.º 11
0
 public void UpdateRandomExamSubject(RandomExamSubject RandomExamSubject)
 {
     dal.UpdateRandomExamSubject(RandomExamSubject);
 }
Exemplo n.º 12
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;
            }

            RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();
            RandomExamResultCurrent    randomExamResult    = new RandomExamResultCurrent();

            randomExamResult = randomExamResultBLL.GetRandomExamResult(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();
            RandomExamResultAnswerCurrentBLL      randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            IList <RandomExamSubject>             randomExamSubjects        = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId);
            IList <RandomExamResultAnswerCurrent> examResultAnswers         = new List <RandomExamResultAnswerCurrent>();

            examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId);

            if (randomExamSubjects != null)
            {
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject      paperSubject = randomExamSubjects[i];
                    IList <RandomExamItem> PaperItems   = new List <RandomExamItem>();
                    PaperItems = randomItemBLL.GetItemsCurrent(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;

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

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

                            foreach (RandomExamResultAnswerCurrent 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);
                                    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
                            {
                                //单选


                                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 >");
                                }
                            }

                            // 组织正确答案
                            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 (strRightAnswer == strUserAnswer)
                            {
                                strScore = System.String.Format("{0:0.##}", paperSubject.UnitScore);
                            }

                            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;
            }
        }
        protected void btnSaveAndNext_Click(object sender, ImageClickEventArgs e)
        {
            string strId        = Request.QueryString.Get("id");
            string strMode      = ViewState["mode"].ToString();
            string strStartMode = ViewState["startmode"].ToString();

            string strItemType = "";

            if (strMode != "ReadOnly")
            {
                if (Grid1.Rows.Count == 0)
                {
                    SessionSet.PageMessage = "请选择大题!";
                    return;
                }

                decimal totalScore = 0;
                IList <RandomExamSubject> paperStrategySubjects = new List <RandomExamSubject>();
                for (int i = 0; i < Grid1.Rows.Count; i++)
                {
                    string strPaperStrategySubjectId = ((HiddenField)Grid1.Rows[i].FindControl("hfPaperStrategySubjectId")).Value;
                    string strItemTypeId             = ((HiddenField)Grid1.Rows[i].FindControl("hfItemTypeId")).Value;
                    string strSubjectName            = ((TextBox)Grid1.Rows[i].FindControl("txtSubjectName")).Text;
                    string strUnitScore = ((TextBox)Grid1.Rows[i].FindControl("txtUnitScore")).Text;
                    string strItemCount = ((TextBox)Grid1.Rows[i].FindControl("txtItemCount")).Text;

                    if (strUnitScore == "")
                    {
                        strUnitScore = "0";
                    }

                    if (strItemCount == "")
                    {
                        strItemCount = "0";
                    }


                    totalScore += Convert.ToDecimal(strUnitScore);

                    RandomExamSubject paperStrategySubject = new RandomExamSubject();

                    paperStrategySubject.RandomExamSubjectId = int.Parse(strPaperStrategySubjectId);
                    paperStrategySubject.RandomExamId        = int.Parse(strId);
                    paperStrategySubject.ItemCount           = int.Parse(strItemCount);
                    paperStrategySubject.ItemTypeId          = int.Parse(strItemTypeId);
                    paperStrategySubject.OrderIndex          = 0;
                    paperStrategySubject.Remark      = "";
                    paperStrategySubject.SubjectName = strSubjectName;
                    paperStrategySubject.UnitScore   = Convert.ToDecimal(strUnitScore);
                    paperStrategySubject.TotalScore  = Convert.ToDecimal(strUnitScore);
                    paperStrategySubject.Memo        = "";

                    if (i == 0)
                    {
                        strItemType = strItemTypeId;
                    }
                    else
                    {
                        strItemType = strItemType + "|" + strItemTypeId;
                    }

                    paperStrategySubjects.Add(paperStrategySubject);
                }

                RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
                paperStrategySubjectBLL.UpdateRandomExamSubject(paperStrategySubjects);
            }

            Response.Redirect("RandomExamStrategyInfo.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&itemType=" + strItemType + "&id=" + strId);
        }
Exemplo n.º 14
0
        public void FillPaper()
        {
            string strId = Request.QueryString.Get("id");

            RandomExamBLL randomExamBLL = new RandomExamBLL();

            RailExam.Model.RandomExam randomExam = randomExamBLL.GetExam(int.Parse(strId));
            ViewState["Year"] = randomExam.BeginTime.Year.ToString();

            RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();

            RailExam.Model.RandomExamResultCurrent randomExamResult = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(Request.QueryString.Get("employeeID")), Convert.ToInt32(strId));

            int RandomExamId       = Convert.ToInt32(strId);
            int randomExamResultId = randomExamResult.RandomExamResultId;

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

            RandomExamResultAnswerCurrentBLL      randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            IList <RandomExamResultAnswerCurrent> examResultAnswers         = new List <RandomExamResultAnswerCurrent>();

            examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId);

            OracleAccess db = new OracleAccess();

            if (randomExamSubjects != null)
            {
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject      paperSubject = randomExamSubjects[i];
                    IList <RandomExamItem> PaperItems   = new List <RandomExamItem>();
                    PaperItems = randomItemBLL.GetItemsCurrent(paperSubject.RandomExamSubjectId, randomExamResultId, Convert.ToInt32(ViewState["Year"].ToString()));

                    Response.Write("<br>");
                    Response.Write("<span class='StudentLeftInfo'><b> 第" + GetNo(i) + "大题:" + paperSubject.SubjectName + "</b></span>");
                    Response.Write("<br>");

                    if (PaperItems != null)
                    {
                        Response.Write("<table width='100%'  border='1'>");
                        int z     = 1;
                        int tempK = 0;
                        int count = 1;
                        for (int j = 0; j < PaperItems.Count; j++)
                        {
                            RandomExamItem paperItem = PaperItems[j];
                            int            k         = j + 1;


                            if (paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANKDETAIL && paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                z = 1;

                                if (k % 5 == 1)
                                {
                                    Response.Write("</tr >");
                                    Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + k + "</b></a></td>");
                                }
                                else
                                {
                                    Response.Write("<td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + k + "</b></a></td>");
                                }
                            }
                            else
                            {
                                if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                                {
                                    z = 1;
                                    tempK++;
                                }

                                if (count % 3 == 1)
                                {
                                    Response.Write("</tr >");
                                    Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>");
                                }
                                else
                                {
                                    Response.Write("<td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>");
                                }

                                z++;
                                count++;
                            }
                        }

                        Response.Write("</tr >");
                        Response.Write("</table>");
                    }
                }

                //ClientScript.RegisterStartupScript(GetType(), "StartStyle", "<script>StartStyle()</script>");
            }
            else
            {
                SessionSet.PageMessage = "未找到记录!";
            }
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strID = Request.QueryString.Get("id");
                ViewState["mode"]     = Request.QueryString.Get("mode");
                hfItemType.Value      = Request.QueryString.Get("itemTypeID");
                ddlType.SelectedValue = hfItemType.Value;
                if (ViewState["mode"].ToString() == "Insert")
                {
                    string subjectId = Request.QueryString.Get("subjectid");
                    hfSubjectId.Value = subjectId;
                    if (!string.IsNullOrEmpty(subjectId))
                    {
                        RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
                        RandomExamSubject    paperStrategySubject    = paperStrategySubjectBLL.GetRandomExamSubject(int.Parse(subjectId));

                        if (paperStrategySubject != null)
                        {
                            hfExamID.Value        = paperStrategySubject.RandomExamId.ToString();
                            txtSubjectName.Text   = paperStrategySubject.SubjectName;
                            ddlType.SelectedValue = paperStrategySubject.ItemTypeId.ToString();
                            labelTotalCount.Text  = paperStrategySubject.ItemCount.ToString();

                            RandomExamStrategyBLL randomExamStrategyBLL = new RandomExamStrategyBLL();
                            IList <RailExam.Model.RandomExamStrategy> RandomExamStrategys = randomExamStrategyBLL.GetRandomExamStrategys(paperStrategySubject.RandomExamSubjectId);

                            int hasCount = 0;
                            foreach (RailExam.Model.RandomExamStrategy randomExamStrategy in RandomExamStrategys)
                            {
                                hasCount += randomExamStrategy.ItemCount;
                            }

                            labelLeaveCount.Text = (paperStrategySubject.ItemCount - hasCount).ToString();

                            txtNDR.Text = labelLeaveCount.Text;

                            RandomExamResultBLL reBll = new RandomExamResultBLL();
                            IList <RailExam.Model.RandomExamResult> examResults = reBll.GetRandomExamResultByExamID(paperStrategySubject.RandomExamId);

                            if (examResults.Count > 0)
                            {
                                SaveButton.Visible = false;
                            }
                        }

                        hfSubjectId.Value = subjectId;

                        mother1.Visible = false;
                        mother2.Visible = false;
                    }

                    OracleAccess db     = new OracleAccess();
                    string       strSql = "select RANDOM_EXAM_STRATEGY_SEQ.nextval from dual";
                    DataRow      dr     = db.RunSqlDataSet(strSql).Tables[0].Rows[0];
                    hfKeyID.Value = dr[0].ToString();
                }
                else
                {
                    hfKeyID.Value = strID;
                    FillPage(int.Parse(strID));
                }
            }

            if (!string.IsNullOrEmpty(HfChapterId.Value))
            {
                if (HfRangeType.Value == "4")
                {
                    BookChapterBLL chapterBll = new BookChapterBLL();
                    BookChapter    chapter    = chapterBll.GetBookChapter(Convert.ToInt32(HfChapterId.Value));

                    txtChapterName.Text = chapter.ChapterName;
                }
                else
                {
                    BookBLL             bookBll = new BookBLL();
                    RailExam.Model.Book book    = bookBll.GetBook(Convert.ToInt32(HfChapterId.Value));

                    txtChapterName.Text = book.bookName;
                }
            }

            if (!string.IsNullOrEmpty(HfExCludeChaptersId.Value))
            {
                string strSql = "select * from Book_Chapter where Chapter_ID in (" + HfExCludeChaptersId.Value + ")";

                OracleAccess db = new OracleAccess();
                DataSet      ds = db.RunSqlDataSet(strSql);

                string strName = string.Empty;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (strName == string.Empty)
                    {
                        strName += dr["Chapter_Name"].ToString();
                    }
                    else
                    {
                        strName += "," + dr["Chapter_Name"].ToString();
                    }
                }

                txtExCludeChapters.Text = strName;
            }
        }
Exemplo n.º 16
0
        private void FillPage(int nID)
        {
            RandomExamStrategyBLL paperStrategyBookChapterBLL = new RandomExamStrategyBLL();

            RandomExamStrategy paperStrategyBookChapter = paperStrategyBookChapterBLL.GetRandomExamStrategy(nID);

            if (paperStrategyBookChapter != null)
            {
                txtMemo.Text        = paperStrategyBookChapter.Memo;
                txtChapterName.Text = paperStrategyBookChapter.RangeName;
                HfRangeName.Value   = paperStrategyBookChapter.RangeName;

                hfSubjectId.Value     = paperStrategyBookChapter.SubjectId.ToString();
                HfRangeType.Value     = paperStrategyBookChapter.RangeType.ToString();
                HfChapterId.Value     = paperStrategyBookChapter.RangeId.ToString();
                ddlType.SelectedValue = paperStrategyBookChapter.ItemTypeId.ToString();
                txtNDR.Text           = paperStrategyBookChapter.ItemCount.ToString();



                RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
                RandomExamSubject    paperStrategySubject    = paperStrategySubjectBLL.GetRandomExamSubject(int.Parse(hfSubjectId.Value));

                if (paperStrategySubject != null)
                {
                    hfExamID.Value       = paperStrategySubject.RandomExamId.ToString();
                    txtSubjectName.Text  = paperStrategySubject.SubjectName;
                    labelTotalCount.Text = paperStrategySubject.ItemCount.ToString();

                    IList <RailExam.Model.RandomExamStrategy> RandomExamStrategys = paperStrategyBookChapterBLL.GetRandomExamStrategys(paperStrategySubject.RandomExamSubjectId);

                    int hasCount = 0;
                    foreach (RailExam.Model.RandomExamStrategy randomExamStrategy in RandomExamStrategys)
                    {
                        if (randomExamStrategy.RandomExamStrategyId != nID)
                        {
                            hasCount += randomExamStrategy.ItemCount;
                        }
                    }

                    labelLeaveCount.Text = (paperStrategySubject.ItemCount - hasCount).ToString();

                    RandomExamResultBLL reBll = new RandomExamResultBLL();
                    IList <RailExam.Model.RandomExamResult> examResults = reBll.GetRandomExamResultByExamID(paperStrategySubject.RandomExamId);

                    if (examResults.Count > 0)
                    {
                        ViewState["mode"] = "ReadOnly";
                    }
                }

                string strSql = "select a.random_exam_strategy_id as RandomExamStrategyId,a.Item_Count as ItemCount,"
                                + "GetBookChapterName(b.Chapter_ID) ChapterName, b.Chapter_ID as ChapterId,b.ID_Path as IDPath "
                                + "from random_exam_strategy a"
                                + " inner join Book_Chapter b on a.Range_ID=b.Chapter_ID "
                                + " where a.Is_Mother_Item=1 and a.Mother_ID=" + nID;

                OracleAccess db = new OracleAccess();

                DataSet ds = db.RunSqlDataSet(strSql);


                if (paperStrategyBookChapter.RangeType == 3 && ds.Tables[0].Rows.Count == 0)
                {
                    txtExCludeChapters.Text = paperStrategyBookChapter.ExcludeChapterId;

                    if (string.IsNullOrEmpty(paperStrategyBookChapter.ExcludeChapterId) == false)
                    {
                        FillExcludeCategorysID(paperStrategyBookChapter.ExcludeChapterId);
                    }
                }

                int     sumTotalCount = 0;
                ItemBLL itembll       = new ItemBLL();
                if (HfRangeType.Value == "3")
                {
                    sumTotalCount = itembll.GetItemsByBookID(Convert.ToInt32(HfChapterId.Value),
                                                             Convert.ToInt32(hfItemType.Value));
                }
                else
                {
                    BookChapterBLL bookChapterBll = new BookChapterBLL();
                    BookChapter    bookChapter    = bookChapterBll.GetBookChapter(Convert.ToInt32(HfChapterId.Value));
                    sumTotalCount = itembll.GetItemsByBookChapterIdPath(bookChapter.IdPath,
                                                                        Convert.ToInt32(hfItemType.Value));
                }

                if (ds.Tables[0].Rows.Count == 0)
                {
                    mother1.Visible = false;
                    mother2.Visible = false;
                }
                else
                {
                    mother1.Visible = true;
                    mother2.Visible = true;

                    DataColumn dc1 = ds.Tables[0].Columns.Add("MaxItemCount");

                    ItemBLL item        = new ItemBLL();
                    int     sumCount    = 0;
                    int     sumMaxCount = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dr["MaxItemCount"] = item.GetItemsByBookChapterIdPath(dr["IDPath"].ToString(),
                                                                              Convert.ToInt32(hfItemType.Value));

                        sumCount    += Convert.ToInt32(dr["ItemCount"].ToString());
                        sumMaxCount += Convert.ToInt32(dr["MaxItemCount"].ToString());
                    }

                    txtNDR.Text = (paperStrategyBookChapter.ItemCount + sumCount).ToString();

                    Grid1.DataSource = ds;
                    Grid1.DataBind();

                    lblMotherInfo.Text = "其中子题最大题数:" + (sumTotalCount - sumMaxCount) + ";母题最大题数:" + sumMaxCount;
                }
                strSql              = "select * from Item a inner join Book_Chapter b on a.Chapter_ID=b.Chapter_ID " + GetSelectSql();
                lblTotalCount.Text  = db.RunSqlDataSet(strSql).Tables[0].Rows.Count.ToString();
                strSql              = " select * from  Random_Exam_Item_Select where RANDOM_EXAM_STRATEGY_ID=" + nID;
                lblSelectCount.Text = db.RunSqlDataSet(strSql).Tables[0].Rows.Count.ToString();
            }

            if (ViewState["mode"].ToString() == "ReadOnly")
            {
                SaveButton.Visible   = false;
                CancelButton.Visible = true;
                ddlType.Enabled      = false;
                txtMemo.Enabled      = false;
            }
        }
Exemplo n.º 17
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;
            }
        }
Exemplo n.º 18
0
        protected void FillPaper()
        {
            string strId = Request.QueryString.Get("id");

            if (string.IsNullOrEmpty(strId))
            {
                SessionSet.PageMessage = "缺少参数!";

                return;
            }

            int RandomExamId       = Convert.ToInt32(strId);
            int randomExamResultId = Convert.ToInt32(ViewState["RandomExamResultID"]);

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

            //RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            //IList<RandomExamResultAnswerCurrent> examResultAnswers = new List<RandomExamResultAnswerCurrent>();
            //examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId);

            IList <RandomExamItem> totalItems = randomItemBLL.GetItemsCurrent(0, randomExamResultId, Convert.ToInt32(ViewState["Year"].ToString()));

            if (randomExamSubjects != null)
            {
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject      paperSubject = randomExamSubjects[i];
                    IList <RandomExamItem> PaperItems   = new List <RandomExamItem>();
                    //PaperItems = randomItemBLL.GetItemsCurrent(paperSubject.RandomExamSubjectId, randomExamResultId, Convert.ToInt32(ViewState["Year"].ToString()));
                    PaperItems = GetSubjectItems(totalItems, paperSubject.RandomExamSubjectId);

                    int itemCount = 0;

                    if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_FILLBLANK)
                    {
                        foreach (RandomExamItem randomExamItem in PaperItems)
                        {
                            if (randomExamItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                itemCount++;
                            }
                        }
                    }
                    else
                    {
                        itemCount = PaperItems.Count;
                    }

                    Response.Write("<table width='95%' class='ExamContent'>");
                    Response.Write(" <tr> <td class='ExamBigTitle' colspan='3'>");
                    Response.Write(" " + GetNo(i) + "");
                    Response.Write("、" + paperSubject.SubjectName + "");
                    Response.Write("  (共" + itemCount + "题,共" + System.String.Format("{0:0.##}", itemCount * paperSubject.UnitScore) + "分)</td></tr >");

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

                            if (paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANKDETAIL)
                            {
                                z = 1;

                                if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                                {
                                    k = x;
                                    x++;

                                    IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(paperItem.ItemId, RandomExamId, Convert.ToInt32(ViewState["Year"].ToString()));
                                    Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' colspan='3'><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) + "分,其中"
                                                   + "每题" + System.String.Format("{0:0.##}", (randomExamItems.Count != 0 ? (decimal)paperSubject.UnitScore / (decimal)randomExamItems.Count : 0)) + "分)"
                                                   + "</td></tr >");
                                }
                                else
                                {
                                    Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' colspan='3'><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) + "分)&nbsp;&nbsp;"
                                                   + "<a href='#Test" + i + j + "' id='Empty" + i + j + "' onclick='clickEmpty(this)'style='cursor: hand;' title='清空选择'>"
                                                   + "<img src='../images/clear.png'  style='border:0'/></a>"
                                                   + "</td></tr >");
                                }
                            }
                            //else
                            //{
                            //    string strSql = "select * from Random_Exam_Item_" + ViewState["Year"] + " where Item_ID='" +
                            //                     paperItem.ItemId + "' and Random_Exam_ID=" + strId;
                            //    DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];

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

                            //    Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' colspan='2'><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)randomExamItems.Count) + "分)&nbsp;&nbsp;"
                            //            + "<a href='#Test" + i + j + "' id='Empty" + i + j + "' onclick='clickEmpty(this)'style='cursor: hand;' title='清空选择'>"
                            //            + "<img src='../images/clear.png'  style='border:0'/></a>"
                            //            +"</td></tr >");
                            //    z++;
                            //}


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

                            //RandomExamResultAnswerCurrent theExamResultAnswer = null;
                            //foreach (RandomExamResultAnswerCurrent 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();

                                    if (("," + strUserAnswer + ",").IndexOf("," + strN + ",") != -1)
                                    {
                                        Response.Write(
                                            "<tr><td class='ExamItemAnswer' colspan='3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input onclick='CheckStyle(this)' type='checkbox' checked='checked' id='Answer" +
                                            strij + "' name='Answer" + strName + "'><label for='Answer" + strij + "'> " + strN + "." + strAnswer[n] +
                                            "</label></td></tr>");
                                    }
                                    else
                                    {
                                        Response.Write(
                                            "<tr><td class='ExamItemAnswer' colspan='3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input onclick='CheckStyle(this)' type='checkbox' id='Answer" +
                                            strij + "' name='Answer" + strName + "'><label for='Answer" + strij + "'> " + strN + "." + strAnswer[n] +
                                            "</label></td></tr>");
                                    }
                                }
                            }
                            else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || paperSubject.ItemTypeId == PrjPub.ITEMTYPE_JUDGE)    //单选
                            {
                                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();

                                    if (strUserAnswer == strN)
                                    {
                                        Response.Write(
                                            "<tr><td class='ExamItemAnswer' colspan='3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input onclick='CheckStyle(this)' type='Radio' checked='checked' id='RAnswer" +
                                            strij + "' name='RAnswer" + strName + "'>  <label for='RAnswer" + strij + "' >" + strN + "." + strAnswer[n] +
                                            "</label></td></tr>");
                                    }
                                    else
                                    {
                                        Response.Write(
                                            "<tr><td class='ExamItemAnswer' colspan='3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input onclick='CheckStyle(this)' type='Radio' id='RAnswer" +
                                            strij + "' name='RAnswer" + strName + "'> <label for='RAnswer" + strij + "' >" + strN + "." + strAnswer[n] +
                                            "</label></td></tr>");
                                    }
                                }
                            }
                            else if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANKDETAIL)
                            {
                                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();

                                    if (n == 0)
                                    {
                                        int row = strAnswer.Length % 2 == 0 ? strAnswer.Length / 2 : strAnswer.Length / 2 + 1;
                                        Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' style='width:10%;vertical-align: top' RowSpan='" + row + "'><a name='Test" + i + j + "' id='Test" + i + j + "'></a>"
                                                       + "&nbsp;(" + z + ").&nbsp;"
                                                       + "<a href='#Test" + i + j + "' id='Empty" + i + j + "' onclick='clickEmpty(this)'style='cursor: hand;' title='清空选择'>"
                                                       + "<img src='../images/clear.png'  style='border:0'/></a>"
                                                       + "</td>");
                                    }

                                    if (n % 2 == 0 && n != 0)
                                    {
                                        Response.Write("<tr>");
                                    }

                                    if (strUserAnswer == strN)
                                    {
                                        Response.Write(
                                            "<td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input onclick='CheckStyle(this)' type='Radio' checked='checked' id='RAnswer" +
                                            strij + "' name='RAnswer" + strName + "'><label for='RsAnswer" + strij + "'>" + strN + "." + strAnswer[n] +
                                            "</label></td>");
                                    }
                                    else
                                    {
                                        Response.Write(
                                            "<td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input onclick='CheckStyle(this)' type='Radio' id='RAnswer" +
                                            strij + "' name='RAnswer" + strName + "'><label for='RAnswer" + strij + "'> " + strN + "." + strAnswer[n] +
                                            "</label></td>");
                                    }

                                    if (n % 2 == 1)
                                    {
                                        Response.Write("</tr>");
                                    }
                                }

                                z++;
                            }
                        }
                    }
                    Response.Write("</table>");
                }
                //<input id='btnEmpty' class='buttonLong' name='btnEmpty' type='button' value='标记未做试题' onclick='CheckEmpty()'/>&nbsp;&nbsp;&nbsp;&nbsp;
                Response.Write(" <div class='ExamButton'><input id='btnClose' class='button' name='btnSave' type='button' value='提交答卷'  onclick='SaveRecord()'/> </div><br><br><br><br><br><br>");
                ClientScript.RegisterStartupScript(GetType(), "StartStyle", "<script>StartStyle()</script>");
            }
            else
            {
                SessionSet.PageMessage = "未找到记录!";
            }
        }
Exemplo n.º 19
0
 public int AddRandomExamSubject(RandomExamSubject RandomExamSubject)
 {
     return(dal.AddRandomExamSubject(RandomExamSubject));
 }