Esempio n. 1
0
        /// <summary>
        /// Retrieves user profile data from DynamoDB 'user-profile'
        /// </summary>
        public async Task GetUserProfileData()
        {
            DatabaseItem items = await GetEntryByKey(this.UserID);

            if (items.TryGetValue(SCHEDULE_KEY, out AttributeValue dbSchedule))
            {
                if (items.TryGetValue(TEACH_MODE_KEY, out AttributeValue tM))
                {
                    this.teachMode = (MODE)Enum.Parse(typeof(MODE), tM.S);
                }
                else
                {
                    this.teachMode = MODE.Assess;
                }

                this.Schedule = int.Parse(dbSchedule.N);
                await this.scopeAndSequenceDB.GetSessionDataWithNumber(this.Schedule);

                log.INFO("UserProfileDB", "GetUserSchedule", "User profile exist, start the user at: " + this.Schedule);
            }
            else
            {
                await CreateNewUser();

                log.INFO("UserProfileDB", "GetUserSchedule", "User profile does not exist, start the user at: " + this.Schedule);
            }
            this.lesson = LessonFactory.GetLesson(this.scopeAndSequenceDB.Lesson);
        }
Esempio n. 2
0
        public async Task <SkillResponse> HandleRequest()
        {
            LOGGER.log.INFO("LaunchRequest", "HandleRequest");

            await this.userProfile.GetUserProfileData();

            if (userProfile.RequiresPurchase())
            {
                LOGGER.log.DEBUG("LaunchRequest", "HandleRequest", "Schedule is premium content");

                await productInventory.GetAvailableProducts();

                string productName = this.userProfile.lesson.InSkillPurchaseName;

                if (productInventory.IsUnpaid(productName))
                {
                    LOGGER.log.DEBUG("LaunchRequest", "HandleRequest", "Premium content requires purchase");

                    this.sessionAttributes.ProductName = productName;
                    return(AlexaResponse.PurchaseContentUpsell(productInventory.GetProductId(productName),
                                                               CommonPhrases.Upsell(), productName));
                }
            }

            this.sessionAttributes.UpdateSessionAttributes(userProfile);
            this.sessionAttributes.SessionState = STATE.Introduction;

            WordAttributes wordAttributes = await WordAttributes.GetWordAttributes(this.sessionAttributes.CurrentWord, LOGGER.log);

            LOGGER.log.DEBUG("Launch", "HandleRequest", "Next word: " + sessionAttributes.CurrentWord);

            return(LessonFactory.GetLesson(this.sessionAttributes.LessonType).Introduction(wordAttributes));
        }
Esempio n. 3
0
        public async Task <SkillResponse> HandleIntent()
        {
            var intentRequest = (Alexa.NET.Request.Type.IntentRequest)skillRequest.Request;

            string lessonName = GetSlotValue(intentRequest);

            LOGGER.log.INFO("MakePurchase", "HandleIntent", "Lesson to purcase to: " + lessonName);
            ILesson lessonToPurchase = LessonFactory.GetLesson(lessonName);
            await base.products.GetAvailableProducts();

            if (base.products.IsUnpaid(lessonToPurchase.InSkillPurchaseName))
            {
                LOGGER.log.DEBUG("LaunchRequest", "HandleRequest", "Premium content requires purchase");

                this.sessionAttributes.ProductName = lessonToPurchase.InSkillPurchaseName;
                return(AlexaResponse.PurchaseContentUpsell(base.products.GetProductId(lessonToPurchase.InSkillPurchaseName),
                                                           CommonPhrases.Upsell(), lessonToPurchase.InSkillPurchaseName));
            }


            await base.userProfile.ChangeLesson(lessonToPurchase);

            this.sessionAttributes.SessionState = STATE.Introduction;
            // relaunch for new lesson
            return(await new LaunchRequest(base.skillRequest).HandleRequest());
        }
Esempio n. 4
0
        public async Task <SkillResponse> HandleIntent()
        {
            var intentRequest = (Alexa.NET.Request.Type.IntentRequest)skillRequest.Request;

            string lessonType = GetSlotValue(intentRequest);

            LOGGER.log.INFO("MoveToNewLesson", "HandleIntent", "Deck to move to: " + lessonType);
            ILesson lesson = LessonFactory.GetLesson(lessonType);
            await base.userProfile.ChangeLesson(lesson);

            this.sessionAttributes.SessionState = STATE.Introduction;
            // relaunch for new lesson
            return(await new LaunchRequest(base.skillRequest).HandleRequest());
        }
Esempio n. 5
0
        public async Task <SkillResponse> HandleIntent()
        {
            LOGGER.log.INFO("Yes", "HandleIntent");

            if (base.sessionAttributes.SessionState != STATE.Introduction)
            {
                LOGGER.log.DEBUG("Yes", "HandleIntent", "Yes was said, but not in introduction");
                WordsToRead wordsToRead = new WordsToRead(this.skillRequest);
                return(await wordsToRead.HandleIntent());
            }

            base.sessionAttributes.SessionState = STATE.FirstWord;

            LOGGER.log.DEBUG("Yes", "HandleIntent", "Current Word: " + base.sessionAttributes.CurrentWord);
            WordAttributes wordAttributes = await WordAttributes.GetWordAttributes(this.sessionAttributes.CurrentWord, LOGGER.log);

            return(LessonFactory.GetLesson(this.sessionAttributes.LessonType).Dialogue(sessionAttributes.LessonMode, wordAttributes));
        }
Esempio n. 6
0
        public async Task <SkillResponse> HandleIntent()
        {
            LOGGER.log.INFO("WordsToRead", "HandleIntent", "Current Schedule: " + this.sessionAttributes.Schedule);

            ILesson lesson = LessonFactory.GetLesson(this.sessionAttributes.LessonType);

            this.sessionAttributes.SessionState = STATE.Assess;

            var request = (Alexa.NET.Request.Type.IntentRequest)skillRequest.Request;

            string currentWord = this.sessionAttributes.CurrentWord;

            LOGGER.log.INFO("WordsToRead", "HandleIntent", "Current Word: " + currentWord);

            bool wordWasSaid = ReaderSaidTheWord(request);

            LOGGER.log.DEBUG("WordsToRead", "HandleIntent", "Reader said the word? " + wordWasSaid);

            if (wordWasSaid)
            {
                lesson.QuickReply = CommonPhrases.ShortAffirmation;
                GradeBook.Passed(sessionAttributes);
                bool sessionFinished = !sessionAttributes.WordsToRead.Any();

                if (sessionFinished)
                {
                    LOGGER.log.DEBUG("WordsToRead", "HandleIntent", "Session Finished");
                    await this.userProfile.IncrementUserProfileSchedule();

                    return(ResponseBuilder.Tell(CommonPhrases.LongAffirmation + CommonPhrases.SessionFinished));
                }
            }
            else
            {
                lesson.QuickReply = CommonPhrases.ConstructiveCriticism;
                GradeBook.Missed(sessionAttributes);
            }

            WordAttributes wordAttributes = await WordAttributes.GetWordAttributes(this.sessionAttributes.CurrentWord, LOGGER.log);


            return(lesson.Dialogue(sessionAttributes.LessonMode, wordAttributes));
        }