public void InsertCultureObservationQuiz(
            List <CultureObservationToolQuizAttempts> cultureObservationToolQuizAttempts)
        {
            var latestDetails = _cultureObservationAdapter.GetLatestAttemptId();
            var latestId      = 0;
            var attemptId     = _cultureObservationAdapter.GetLatestAttemptByUser(cultureObservationToolQuizAttempts[0].userid);

            if (latestDetails != null)
            {
                latestId = latestDetails.id;
            }
            foreach (var item in cultureObservationToolQuizAttempts)
            {
                latestId++;
                item.id               = latestId;
                item.attemptcount     = (attemptId?.attemptcount ?? 0) + 1;
                item.attempttimestamp = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            }

            _cultureObservationAdapter.InsertCultureObservationAttempt(cultureObservationToolQuizAttempts);
        }
        /// <summary>
        /// For getting GetCulturalObservationQuizAttempts - Pending
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="attempt"></param>
        /// <param name="quizDetails"></param>
        /// <returns></returns>
        public List <QuizAttempts> GetCulturalObservationQuizAttempts(string userId, int attempt, QuizDetails quizDetails)
        {
            var userFilter = Builders <BsonDocument> .Filter.Eq("userid", userId);

            var latestAttempt          = _culturalObservationAdapter.GetLatestAttemptByUser(userId);
            List <BsonDocument> result = new List <BsonDocument>();

            if (latestAttempt != null)
            {
                if (attempt == 1)
                {
                    var attemptFilter = Builders <BsonDocument> .Filter.Eq("attemptcount", latestAttempt.attemptcount);

                    var userAndAttempt = Builders <BsonDocument> .Filter.And(userFilter, attemptFilter);

                    result = _quizAttempt.GetRecords(_culturalObservationAttemptsCollection, userAndAttempt);
                }
                else
                {
                    if (latestAttempt.attemptcount > 1)
                    {
                        var attemptFilter = Builders <BsonDocument> .Filter.Eq("attemptcount", latestAttempt.attemptcount - 1);

                        var userAndAttempt = Builders <BsonDocument> .Filter.And(userFilter, attemptFilter);

                        result = _quizAttempt.GetRecords(_culturalObservationAttemptsCollection, userAndAttempt);
                    }
                }
            }
            var culturalObservationQuizzes = _culturalObservationAdapter.GetCutlturalObservationQuiz();

            List <QuizAttempts> quizAttempts = new List <QuizAttempts>();

            foreach (var item in result)
            {
                item.TryGetValue("answer", out BsonValue answerValue);
                item.TryGetValue("userid", out BsonValue useridValue);
                item.TryGetValue("date", out BsonValue dateValue);
                item.TryGetValue("meetingtitle", out BsonValue meetingTitleValue);
                item.TryGetValue("scoring", out BsonValue scoringValue);
                item.TryGetValue("comments", out BsonValue commentsValue);
                item.TryGetValue("attemptcount", out BsonValue attemptValue);
                item.TryGetValue("questionid", out BsonValue questionidValue);

                var question = culturalObservationQuizzes.Where(a => a.id == Common.IntegerNullCheck(questionidValue));
                quizAttempts.Add(new QuizAttempts
                {
                    question     = question.Count() == 0 ? "" : question.Select(a => a.question).FirstOrDefault().ToString(CultureInfo.InvariantCulture),
                    answer       = Common.StringNullCheck(answerValue),
                    userId       = Common.StringNullCheck(useridValue),
                    date         = Common.StringNullCheck(dateValue),
                    meetingTitle = Common.StringNullCheck(meetingTitleValue),
                    scoring      = Common.StringNullCheck(scoringValue),
                    comments     = Common.StringNullCheck(commentsValue),
                    attempt      = Common.IntegerNullCheck(attemptValue),
                    type         = quizDetails.type
                });
            }

            return(quizAttempts);
        }