public void SaveBlindSpotUserResponse(BlindSpotQuizAttempts response)
        {
            response.id           = _blindSpotAdapter.GetLastInsertedAttemptId() + 1;
            response.attemptcount = _blindSpotAdapter.GetLatestAttemptByUser(response.userid)?.attemptcount + 1 ?? 1;
            _blindSpotAdapter.SaveBlindSpotUserResponse(response);

            var lastRecordCount = _blindSpotAdapter.GetLastInsertedCoWorkerReply();

            foreach (var coWorker in response.selectedcoWorkers)
            {
                if (coWorker != null)
                {
                    lastRecordCount++;
                    BlindSpotCoWorkerReply coWorkerReply = new BlindSpotCoWorkerReply
                    {
                        id                 = lastRecordCount,
                        attemptid          = response.id,
                        userid             = coWorker,
                        replytimestamp     = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                        selectedadjectives = new string[] { }
                    };

                    _blindSpotAdapter.SaveBlindSpotCoWorkerResponse(coWorkerReply);
                }
            }

            BlindSpotNotification notification = new BlindSpotNotification()
            {
                userid = response.userid, coworkerid = response.selectedcoWorkers.Where(x => x != null)?.ToList()
            };

            _feedbackAdapter.SendNotification(notification);
        }
Esempio n. 2
0
        public void SaveBlindSpotUserResponse_WithAttempts_ReturnsVoid()
        {
            BlindSpotQuizAttempts attempt = new BlindSpotQuizAttempts
            {
                id = 1, selectedcoWorkers = new string[] { "Anuth" }, userid = "Hamid"
            };

            _blindSpotAdapter.Setup(x => x.GetLastInsertedAttemptId()).Returns(1);
            _blindSpotAdapter.Setup(x => x.GetLatestAttemptByUser(It.IsAny <string>())).Returns(

                new BlindSpotQuizAttempts
            {
                id = 1, attemptcount = 1
            });
            _blindSpotAdapter.Setup(x => x.GetLastInsertedCoWorkerReply()).Returns(1);
            Assert.DoesNotThrow(() => _blindSpotBusinessLogics.SaveBlindSpotUserResponse(attempt));
        }
        public List <QuizAttempts> GetBlindSpotQuizAttempts(string userId, int attempt, QuizDetails quizDetails)
        {
            var latestAttempt = _blindSpotAdapter.GetLatestAttemptByUser(userId);
            BlindSpotQuizAttempts blindSpotAttempts = new BlindSpotQuizAttempts();

            if (latestAttempt != null)
            {
                if (attempt == 1)
                {
                    blindSpotAttempts = _blindSpotAdapter.GetBlindSpotAttemptResponse(latestAttempt.attemptcount, userId);
                }
                else
                {
                    if (latestAttempt.attemptcount > 1)
                    {
                        blindSpotAttempts = _blindSpotAdapter.GetBlindSpotAttemptResponse(latestAttempt.attemptcount - 1, userId);
                    }
                }
            }

            if (blindSpotAttempts?.selectedadjectives == null)
            {
                return(new List <QuizAttempts>());
            }

            var blindSpotResponseByCoWorkers = _blindSpotAdapter.GetCoWorkerResponsesByAttempt(blindSpotAttempts.id);
            var coworkerResponses            = string.Empty;

            foreach (var coworkerResponse in blindSpotResponseByCoWorkers)
            {
                coworkerResponses += string.Join(",", coworkerResponse.selectedadjectives);
            }

            return(new List <QuizAttempts>
            {
                new QuizAttempts
                {
                    question = string.Join(",", blindSpotAttempts.selectedadjectives),
                    answer = coworkerResponses,
                    userId = blindSpotAttempts.userid,
                    attempt = blindSpotAttempts.attemptcount,
                    type = quizDetails.type
                }
            });
        }
Esempio n. 4
0
        public void GetBlindSpotQuizAttemptsTest()
        {
            var response = new BlindSpotQuizAttempts
            {
                attemptcount = 1
            };
            var quizAttemptResponse = new BlindSpotQuizAttempts();
            var request             = new QuizDetails();
            var quizResponse        = new List <BlindSpotCoWorkerReply>();

            _mokblindSpotAdapter.Setup(a => a.GetLatestAttemptByUser(It.IsAny <string>())).Returns(response);
            _mokblindSpotAdapter.Setup(a => a.GetBlindSpotAttemptResponse(It.IsAny <int>(), It.IsAny <string>())).Returns(quizAttemptResponse);

            _mokblindSpotAdapter.Setup(a => a.GetCoWorkerResponsesByAttempt(It.IsAny <long>())).Returns(quizResponse);

            _reportsAdpater = new ReportsAdapter(_mokquizAttempt.Object, _settings.Object, _mokcuriousQuizAdapter.Object, _mokgrowthMindsetQuizAdapter.Object,
                                                 _mokmakingTimeForMeQuizAdapter.Object, _mokstoryTellingForImpactAdapter.Object, _mokblindSpotAdapter.Object, _moklearningMythAdapter.Object, _mokcontinuousLearningAdapter.Object,
                                                 _mokculturalObservationAdapter.Object, _mokproductivityZoneQuizAdapter.Object, _mokreflectionToolAdapter.Object);

            var result = _reportsAdpater.GetBlindSpotQuizAttempts("", 1, request);

            Assert.IsInstanceOf <List <QuizAttempts> >(result);
        }
 public void SaveUserAttempts(BlindSpotQuizAttempts response)
 {
     _blindSpotBusinessLogics.SaveBlindSpotUserResponse(response);
 }
Esempio n. 6
0
 public void SaveBlindSpotUserResponse(BlindSpotQuizAttempts response)
 {
     _blindSpotAttemptsMongoHelper.InsertOne(response, _blindSpotAttemptCollection);
 }