public void GetAndDisplayArsnovaVotingResults(SlideQuestionModel slideQuestionModel)
        {
            var slideSessionModel = this.GetSlideSessionModel();
            var resultsSlide      = SlideTracker.GetSlideById(slideQuestionModel.ResultsSlideId.Value);

            this.sessionManager.GetAndDisplayArsnovaVotingResults(slideSessionModel, slideQuestionModel, resultsSlide);
        }
        public void HideOrShowQuizFromSelectedSlide(Slide slide)
        {
            var slideSessionModel = this.GetSlideSessionModel();

            var slideQuestionModel = slideSessionModel.Questions.First(q => q.QuestionInfoSlideId == slide.SlideID ||
                                                                       q.QuestionTimerSlideId == slide.SlideID ||
                                                                       q.ResultsSlideId == slide.SlideID);

            if (slideQuestionModel == null)
            {
                throw new Exception("No existing arsnova question on slide.");
            }

            var questionInfoSlide  = SlideTracker.GetSlideById(slideQuestionModel.QuestionInfoSlideId);
            var questionTimerSlide = SlideTracker.GetSlideById(slideQuestionModel.QuestionTimerSlideId.Value);
            var resultsSlide       = SlideTracker.GetSlideById(slideQuestionModel.ResultsSlideId.Value);

            if (slideQuestionModel.Hidden)
            {
                questionInfoSlide.SlideShowTransition.Hidden  = MsoTriState.msoFalse;
                questionTimerSlide.SlideShowTransition.Hidden = MsoTriState.msoFalse;
                resultsSlide.SlideShowTransition.Hidden       = MsoTriState.msoFalse;
            }
            else
            {
                questionInfoSlide.SlideShowTransition.Hidden  = MsoTriState.msoTrue;
                questionTimerSlide.SlideShowTransition.Hidden = MsoTriState.msoTrue;
                resultsSlide.SlideShowTransition.Hidden       = MsoTriState.msoTrue;
            }

            slideQuestionModel.Hidden = !slideQuestionModel.Hidden;

            // recalculate question index: asrnova.click index needs to start with 0 and should not leave out any number!
            var ignoredQuestions = 0;

            for (var i = 0; i < slideSessionModel.Questions.Count; i++)
            {
                var question = slideSessionModel.Questions.FirstOrDefault(q => q.Index == i);

                if (question == null)
                {
                    continue;
                }

                if (question.Hidden)
                {
                    ignoredQuestions++;
                }
                else
                {
                    question.RecalculatedOnlineIndex = question.Index - ignoredQuestions;
                }
            }

            PresentationInformationStore.StoreSlideSessionModel(slideSessionModel);
        }
        public Slide CreateNewSlide()
        {
            var currentSlide = SlideTracker.CurrentSlide;

            while (SlideTracker.IsArsnovaSlide(currentSlide))
            {
                currentSlide = SlideTracker.GetSlideByIndex(currentSlide.SlideIndex + 1);
            }

            return(currentSlide == null
                ? this.CreateNewSlide(Globals.ThisAddIn.Application.ActivePresentation.Slides.Count + 1)
                : this.CreateNewSlide(currentSlide.SlideIndex + 1));
        }
        public void StartQuiz(SlideQuestionModel slideQuestionModel)
        {
            var slideSessionModel = this.GetSlideSessionModel();
            var resultsSlide      = SlideTracker.GetSlideById(slideQuestionModel.ResultsSlideId.Value);

            if (this.sessionInformationProvider.IsClickQuestion(slideQuestionModel.QuestionType))
            {
                // arsnova click
                var questionTimerSlide = SlideTracker.GetSlideById(slideQuestionModel.QuestionTimerSlideId.Value);
                this.sessionManager.StartClickQuestion(slideSessionModel, slideQuestionModel.Index, questionTimerSlide,
                                                       resultsSlide);
            }
            else
            {
                // arsnova.voting
                this.sessionManager.StartVotingQuestion(slideSessionModel, slideQuestionModel);
            }
        }
        public void DeleteQuizFromSelectedSlide(Slide slide)
        {
            var slideSessionModel = this.GetSlideSessionModel();

            var slideQuestionModel = slideSessionModel.Questions.First(q => q.QuestionInfoSlideId == slide.SlideID ||
                                                                       q.QuestionTimerSlideId == slide.SlideID ||
                                                                       q.ResultsSlideId == slide.SlideID);

            if (slideQuestionModel == null)
            {
                throw new Exception("No existing arsnova question on slide.");
            }

            var questionText = $"{this.localizationService.Translate("Do you really want to delete this question?")}{Environment.NewLine}{Environment.NewLine}";

            questionText += slideQuestionModel.QuestionText;

            var deleteQuestion = PopUpWindow.ConfirmationWindow(
                this.localizationService.Translate("Delete"),
                questionText);

            if (deleteQuestion)
            {
                SlideTracker.RemoveSlide(slideQuestionModel.QuestionInfoSlideId);
                if (this.IsARSnovaClickSession())
                {
                    SlideTracker.RemoveSlide(slideQuestionModel.QuestionTimerSlideId.Value);
                }
                SlideTracker.RemoveSlide(slideQuestionModel.ResultsSlideId.Value);

                if (!this.IsARSnovaClickSession())
                {
                    this.sessionManager.DeleteVotingQuestion(slideSessionModel, slideQuestionModel);
                }

                slideSessionModel.Questions.Remove(slideQuestionModel);
            }
        }
        public void CleanUpOnStart()
        {
            var slideSessionModel = PresentationInformationStore.GetStoredSlideSessionModel();

            if (slideSessionModel != null)
            {
                foreach (var slideQuestionModel in slideSessionModel.Questions)
                {
                    if (slideQuestionModel.QuestionTimerSlideId.HasValue)
                    {
                        this.slideManipulator.SetTimerOnSlide(
                            slideQuestionModel,
                            SlideTracker.GetSlideById(slideQuestionModel.QuestionTimerSlideId.Value),
                            slideQuestionModel.Countdown);
                    }

                    if (slideQuestionModel.ResultsSlideId.HasValue)
                    {
                        this.slideManipulator.CleanResultsPage(SlideTracker.GetSlideById(slideQuestionModel.ResultsSlideId.Value));
                    }
                }
            }
        }