Ejemplo n.º 1
0
 public static 试卷内容 给试卷内容中试题内容Json赋值(试卷内容 试卷内容, bool 是否加null的连线题回答)
 {
     List<Guid> listProblemId = new List<Guid>();
     foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
     {
         foreach (试卷大题中试题 testProblem in type.试卷大题中试题集合)
         {
             listProblemId.Add(testProblem.试题内容ID);
             if (testProblem.子小题集合 != null)
             {
                 foreach (试卷大题中试题 subTestProblem in testProblem.子小题集合)
                 {
                     listProblemId.Add(subTestProblem.试题内容ID);
                 }
             }
         }
     }
     List<试题内容> listProblem = 试题内容.试题内容查询.Where(a => listProblemId.Contains<Guid>(a.ID)).ToList();
     试卷内容.试题图片 = new Dictionary<string, byte[]>();
     foreach (试题内容 content in listProblem)
     {
         Dictionary<string, byte[]> oneDic = 试题外部信息.获取试题图片(content.Json字符串);
         foreach (var subOneDic in oneDic)
         {
             试卷内容.试题图片.Add(subOneDic.Key, subOneDic.Value);
         }
         content.Json字符串 = "{\"content\":" + content.Json字符串 + ",\"outside\":null}";
     }
     //给试卷大题中试题的试题内容属性赋值
     foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
     {
         foreach (试卷大题中试题 testProblem in type.试卷大题中试题集合)
         {
             foreach (试题内容 content in listProblem)
             {
                 if (testProblem.试题内容ID == content.ID)
                 {
                     //加一个null的回答,界面有需求
                     if (content.小题型Enum == 30 && 是否加null的连线题回答 == true)
                     {
                         考生连线题回答 memberLinkAnswer = new 考生连线题回答();
                         memberLinkAnswer.连线题回答集合 = new List<连线题回答>();
                         连线题回答 linkAnswer = new 连线题回答();
                         memberLinkAnswer.连线题回答集合.Add(linkAnswer);
                         testProblem.该题考试回答 = memberLinkAnswer;
                     }
                     testProblem.试题内容Json = content.Json字符串;
                     break;
                 }
                 if (testProblem .子小题集合!= null)
                 {
                     试卷大题中试题 subTestProblem = testProblem.子小题集合.FirstOrDefault(a => a.试题内容ID == content.ID);
                     if (subTestProblem != null)
                     {
                         subTestProblem.试题内容Json = content.Json字符串;
                     }
                 }
             }
         }
     }
     //回答的题中是复合题和多题干共选项题的小题集合
     int hh = 0;
     var listSubContent = listProblem.Where(a => a.父试题内容ID != null).OrderBy(a => a.本题在复合题中顺序)
         .GroupBy(a => a.父试题内容ID).ToList();
     for (int n = 0; n < listSubContent.Count; n++)
     {
         var aa = listSubContent[n].OrderBy(a => a.本题在复合题中顺序).ToList();
         List<试卷大题中试题> listSubTestProblem = new List<试卷大题中试题>();
         foreach (试题内容 content in aa)
         {
             //找到对应的试卷大题中试题
             foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
             {
                 试卷大题中试题 testProblem = type.试卷大题中试题集合.Where(a => a.试题内容ID == content.ID).FirstOrDefault();
                 if (testProblem != null)
                 {
                     listSubTestProblem.Add(testProblem);
                     //去掉子小题
                     type.试卷大题中试题集合.Remove(testProblem);
                     break;
                 }
                 foreach (试卷大题中试题 TestProblem in type.试卷大题中试题集合)
                 {
                     if (TestProblem.子小题集合 != null)
                     {
                         试卷大题中试题 subTestProblem = TestProblem.子小题集合.Where(a => a.试题内容ID == content.ID).FirstOrDefault();
                         if (subTestProblem != null)
                         {
                             listSubTestProblem.Add(subTestProblem);
                             break;
                         }
                     }
                 }
             }
         }
         foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
         {
             foreach (试卷大题中试题 testProblem in type.试卷大题中试题集合)
             {
                 if (testProblem.试题内容ID == listSubContent[n].Key)
                 {
                     testProblem.子小题集合 = listSubTestProblem;
                     hh = 1;
                     break;
                 }
             }
             if (hh == 1)
             {
                 hh = 0;
                 break;
             }
         }
     }
     return 试卷内容;
 }
Ejemplo n.º 2
0
 public static 试卷内容 去掉试卷中的试题的答案(试卷内容 试卷内容)
 {
     List<Guid> listProblemId = new List<Guid>();
     foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
     {
         foreach (试卷大题中试题 testProblem in type.试卷大题中试题集合)
         {
             listProblemId.Add(testProblem.试题内容ID);
         }
     }
     List<试题内容> listProblem = 试题内容.试题内容查询.Where(a => listProblemId.Contains<Guid>(a.ID)).ToList();
     foreach (试题内容 content in listProblem)
     {
         content.Json字符串 = 试题内容.去掉答案(content.Json字符串);
         content.Json字符串 = "{\"content\":" + content.Json字符串 + ",\"outside\":null}";
     }
     //给试卷大题中试题的试题内容属性赋值
     foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
     {
         foreach (试卷大题中试题 testProblem in type.试卷大题中试题集合)
         {
             foreach (试题内容 content in listProblem)
             {
                 if (testProblem.试题内容ID == content.ID)
                 {
                     //加一个null的回答,界面有需求
                     if (content.小题型Enum == 30)
                     {
                         考生连线题回答 memberLinkAnswer = new 考生连线题回答();
                         memberLinkAnswer.连线题回答集合 = new List<连线题回答>();
                         连线题回答 linkAnswer = new 连线题回答();
                         memberLinkAnswer.连线题回答集合.Add(linkAnswer);
                         testProblem.该题考试回答 = memberLinkAnswer;
                     }
                     testProblem.试题内容Json = content.Json字符串;
                     break;
                 }
             }
         }
     }
     //回答的题中是复合题和多题干共选项题的小题集合
     int hh = 0;
     var listSubContent = listProblem.Where(a => a.父试题内容ID != null).GroupBy(a => a.父试题内容ID).ToList();
     for (int n = 0; n < listSubContent.Count; n++)
     {
         var aa = listSubContent[n].OrderBy(a => a.本题在复合题中顺序).ToList();
         List<试卷大题中试题> listSubTestProblem = new List<试卷大题中试题>();
         foreach (试题内容 content in aa)
         {
             //找到对应的试卷大题中试题
             foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
             {
                 试卷大题中试题 testProblem = type.试卷大题中试题集合.Where(a => a.试题内容ID == content.ID).FirstOrDefault();
                 if (testProblem != null)
                 {
                     listSubTestProblem.Add(testProblem);
                     //去掉子小题
                     type.试卷大题中试题集合.Remove(testProblem);
                     break;
                 }
             }
         }
         foreach (试卷中大题 type in 试卷内容.试卷中大题集合)
         {
             foreach (试卷大题中试题 testProblem in type.试卷大题中试题集合)
             {
                 if (testProblem.试题内容ID == listSubContent[n].Key)
                 {
                     testProblem.子小题集合 = listSubTestProblem;
                     hh = 1;
                     break;
                 }
             }
             if (hh == 1)
             {
                 hh = 0;
                 break;
             }
         }
     }
     return 试卷内容;
 }