Example #1
0
        private RealExam GetRandomExam(DAL.Exam exam)
        {
            RealExam randomExam = realExamController.GetRandomExam(exam);

            realExamsCache.Add(randomExam);
            System.Diagnostics.Debug.WriteLine("Exam fetched is:" + randomExam.title);
            return(randomExam);
        }
Example #2
0
        public RealExam GetRealExam(int id)
        {
            RealExam cachedExam = realExamsCache.Find(realExam => realExam.Id == id);

            if (cachedExam == null)
            {
                DAL.Exam exam = examController.GetById(id);
                if (!exam.staticQuestions)
                {
                    return(GetRandomExam(exam));
                }
                RealExam newExam = realExamController.GetStaticExamModel(exam);
                realExamsCache.Add(newExam);
                System.Diagnostics.Debug.WriteLine("Exam fetched is:" + newExam.title);
                return(newExam);
            }
            if (!cachedExam.staticQuestions)
            {
                return(GetRandomExam(examController.GetById(id)));
            }
            System.Diagnostics.Debug.WriteLine("Exam cached is:" + cachedExam.title);
            return(cachedExam);
        }