Exemple #1
0
        public void Insert(DetailModel item)
        {
            Detail detail = new Detail
            {
                QuestionId = item.Question.QuestionId,
                TestId = item.TestId,
            };

            _detailRepo.Insert(detail);
            item.DetailId = detail.DetailId;
        }
Exemple #2
0
        public FullTestModel GenerateTest(int count)
        {
            if (count < 10)
                count = 40;
            if (count > 100)
                count = 100;

            IList<SubjectModel> subjects = _subjectBus.Get();
            IList<QuestionModel> questions;
            IList<QuestionModel> testQuestions = new List<QuestionModel>();
            int countQuestion = count / subjects.Count;
            int remainCount = count % subjects.Count;
            IList<int> list;
            foreach (SubjectModel subject in subjects)
            {
                questions = _questionBus.FindBySubjectId(subject.SubjectId).Reduce();

                int c = countQuestion + ((remainCount-- > 0) ? 1 : 0);
                list = RandUnique(0, questions.Count, c);

                foreach (int idx in list)
                {
                    testQuestions.Add(questions[idx]);
                }
            }

            Test test = new Test
            {
                CreationTime = DateTime.Now,
                TotalQuestion = testQuestions.Count,
                TotalCorrect = 0,
                UserId = 1,
                FinalTime = null,
            };

            _testRepo.Insert(test);
            foreach (QuestionModel question in testQuestions)
            {
                Detail detail = new Detail
                {
                    QuestionId = question.QuestionId,
                    TestId = test.TestId
                };

                _detailBus.Insert(detail);
            }

            return FillTheTest(test);
        }
Exemple #3
0
 public void Insert(Detail item)
 {
     _detailRepo.Insert(item);
 }
 partial void DeleteDetail(Detail instance);
 partial void UpdateDetail(Detail instance);
 partial void InsertDetail(Detail instance);