Пример #1
0
 /// <summary>
 /// 填充“当按课程出题时”的各项题题分值
 /// </summary>
 /// <param name="uid"></param>
 private void _fillItemForAll(Song.Entities.TestPaper tp)
 {
     Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForAll(tp);
     for (int i = 0; i < this.rptItemForAll.Items.Count; i++)
     {
         //当前索引行的试题类型
         Song.Entities.TestPaperItem pi = null;
         foreach (Song.Entities.TestPaperItem p in tpi)
         {
             if (p.TPI_Type == i + 1)
             {
                 pi = p;
             }
         }
         if (pi == null)
         {
             continue;
         }
         //几道题
         TextBox tbCount = (TextBox)this.rptItemForAll.Items[i].FindControl("tbItemCount");
         //占多少分数比
         TextBox tbScore = (TextBox)this.rptItemForAll.Items[i].FindControl("tbItemScore");
         //占多少分
         Label   lbNumber = (Label)this.rptItemForAll.Items[i].FindControl("lbItemNumber");
         TextBox tbNumber = (TextBox)this.rptItemForAll.Items[i].FindControl("tbItemNumber");
         tbCount.Text  = pi.TPI_Count.ToString();
         lbNumber.Text = tbNumber.Text = pi.TPI_Number.ToString();
         tbScore.Text  = pi.TPI_Percent.ToString();
     }
 }
Пример #2
0
        /// <summary>
        /// 随机出题
        /// </summary>
        /// <returns></returns>
        private string randomJson()
        {
            //取果是第一次打开,则随机生成试题,此为获取试卷
            Song.Entities.TestPaper pager = Business.Do <ITestPaper>().PagerSingle(tpid);
            Dictionary <TestPaperItem, Questions[]> dics = Business.Do <ITestPaper>().Putout(pager); //生成试卷
            //
            List <Questions> list = new List <Questions>();                                          //缓存
            string           json = "[";

            foreach (var di in dics)
            {
                //++++++++按题型输出
                Song.Entities.TestPaperItem pi   = (Song.Entities.TestPaperItem)di.Key; //试题类型
                Song.Entities.Questions[]   ques = (Song.Entities.Questions[])di.Value; //当前类型的试题
                int   type  = (int)pi.TPI_Type;                                         //试题类型
                int   count = ques.Length;                                              //试题数目
                float num   = (float)pi.TPI_Number;                                     //占用多少分
                if (count < 1)
                {
                    continue;
                }
                string tpiJosn = "{'type':'" + type + "','count':'" + count + "','number':'" + num + "',";
                tpiJosn += "'ques':[";
                tpiJosn  = tpiJosn.Replace("'", "\"");
                //++++++++试题输出
                string quesJson = string.Empty;
                for (int n = 0; n < ques.Length; n++)
                {
                    quesJson += getQuesJson(ques[n]) + ",";
                    list.Add(ques[n]);      //存入列表,用于缓存存储
                }
                if (quesJson.EndsWith(","))
                {
                    quesJson = quesJson.Substring(0, quesJson.Length - 1);
                }
                //--------试题输出结束
                tpiJosn += quesJson + "]}";
                json    += tpiJosn + ",";
                //--------按题型输出结束
            }
            if (json.EndsWith(","))
            {
                json = json.Substring(0, json.Length - 1);
            }
            json += "]";
            //缓存
            if (list.Count > 0)
            {
                string uid = string.Format("ExamResults:{0}-{1}-{2}", examid, tpid, stid);    //缓存的uid
                Song.Entities.Examination exam = Business.Do <IExamination>().ExamSingle(examid);
                if (exam != null)
                {
                    Random rn = new Random(stid);
                    Business.Do <IQuestions>().CacheAdd(list.ToArray <Song.Entities.Questions>(), exam.Exam_Span + rn.Next(10), uid);
                }
            }
            return(json);
        }
Пример #3
0
 /// <summary>
 ///  填充“当按章节出题时”的各项题题分值
 /// </summary>
 /// <param name="tp"></param>
 private void _fileItemForOutline(Song.Entities.TestPaper tp)
 {
     //各题型的占比
     Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForOlPercent(tp);
     if (tpi == null)
     {
         return;
     }
     for (int i = 0; i < this.rptOutlineScore.Items.Count; i++)
     {
         //当前索引行的试题类型
         Song.Entities.TestPaperItem pi = null;
         foreach (Song.Entities.TestPaperItem p in tpi)
         {
             if (p.TPI_Type == i + 1)
             {
                 pi = p;
             }
         }
         if (pi == null)
         {
             continue;
         }
         //占多少分数比
         TextBox tbScore = (TextBox)this.rptOutlineScore.Items[i].FindControl("tbQuesScore");
         tbScore.Text = pi.TPI_Percent > 0 ? pi.TPI_Percent.ToString() : "";
     }
     //各章节的各题型试题数量
     for (int i = 0; i < this.rptOutline.Items.Count; i++)
     {
         Label lbOlid = (Label)this.rptOutline.Items[i].FindControl("lbOlid"); //章节id控件
         int   olid   = Convert.ToInt32(lbOlid.Text);                          //章节id
         //内嵌repeat,用于显示题型
         Repeater rptItems = (Repeater)this.rptOutline.Items[i].FindControl("rtpOutlineItem");
         Song.Entities.TestPaperItem[] tpiol = Business.Do <ITestPaper>().GetItemForOlCount(tp, olid);    //当前章节的各试题抽取数量
         for (int j = 0; j < rptItems.Items.Count; j++)
         {
             //当前索引行的试题类型
             Song.Entities.TestPaperItem pi = null;
             foreach (Song.Entities.TestPaperItem p in tpiol)
             {
                 if (p.TPI_Type == j + 1)
                 {
                     pi = p;
                 }
             }
             if (pi == null)
             {
                 continue;
             }
             //几道题
             TextBox tbCount = (TextBox)rptItems.Items[j].FindControl("tbQuesCount");
             tbCount.Text = pi.TPI_Count > 0 ? pi.TPI_Count.ToString() : "";
         }
     }
 }