Exemplo n.º 1
0
        private int CreateJPaperByUser(DateTime createTime, int queClass, int subId)
        {
            int paperId = _onlineTestContext.Paper.SingleOrDefault(p => p.CreateTime.Equals(createTime) && p.SubId == subId).Id;
            //找到题目ID
            List <Question> testQuestions = GetTestQuestions(subId, queClass);

            foreach (var testQuestion in testQuestions)
            {
                Jpaper jpaper = new Jpaper()
                {
                    PapId = paperId,
                    QueId = testQuestion.Id,
                };
                _onlineTestContext.Jpaper.Add(jpaper);
            }
            _onlineTestContext.SaveChanges();
            return(paperId);
        }
Exemplo n.º 2
0
 private bool CreateJPaperByAdmin(DateTime createTime, int subId, int[] queIds)
 {
     try
     {
         int paperId = _onlineTestContext.Paper.SingleOrDefault(p => p.CreateTime.Equals(createTime) && p.SubId == subId).Id;
         foreach (int id in queIds)
         {
             Jpaper jpaper = new Jpaper()
             {
                 PapId = paperId,
                 QueId = id,
             };
             _onlineTestContext.Jpaper.Add(jpaper);
             _onlineTestContext.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }