public void CreateTitle(ResultSlideConfiguration resultConfig)
 {
     int index;
     var question = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, 50, 20, 600, 50,
                                    "Comparación cruzada", 36,
                                    Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignCenter, out index);
 }
        public CrossComparisonEntity(ResultSlideConfiguration resultConfig)
        {
            Matriz = new Dictionary<AnswerEntity, Dictionary<AnswerEntity, double>>();

            this._resultConfig = resultConfig;

            var raiz = resultConfig.SelectedQuestions[0];
            var qRaizConfig = Globals.ThisAddIn.Session.GetQuestionSlideConfiguration(raiz.QuestionRelation.Id);

            foreach (var a in qRaizConfig.Answers)
            {
                this.Matriz.Add(a, new Dictionary<Questions.Data.AnswerEntity, double>());
            }
            var hojas = resultConfig.SelectedQuestions[1];
            var qHojasConfig = Globals.ThisAddIn.Session.GetQuestionSlideConfiguration(hojas.QuestionRelation.Id);

            foreach (var r in this.Matriz.Keys)
            {
                //var votesForRaiz = r.GetPercentValue(Convert.ToInt32(resultConfig.Decimals));
                foreach (var hoja in qHojasConfig.Answers)
                {
                    //var votesForHoja = hoja.GetPercentValue(Convert.ToInt32(resultConfig.Decimals));
                    //var CrossVotes = (votesForRaiz + votesForHoja) / 2.0;

                    var CrossVotes = r.GetCoincidencesFor(hoja);

                    if (!this.Matriz[r].ContainsKey(hoja))
                        this.Matriz[r].Add(hoja, CrossVotes);
                }

            }
        }
 public void CreateTitle(ResultSlideConfiguration resultConfig)
 {
     var qas = resultConfig.SelectedQuestions.First().QuestionRelation.Name;
     int index;
     var question = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, 50, 20, 600, 50,
                                     qas, 36,
                                     Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignCenter, out index);
 }
        public void UpdateSlide(ResultSlideConfiguration resultConfig)
        {
            CrossComparisonEntity cross = new CrossComparisonEntity(resultConfig);

            var shape = resultConfig.CrossCompConfig.ChartShape;

            var chart = shape.Chart;

            UpdateDataChart(chart, cross);
        }
 public void DrawSlide(ResultSlideConfiguration resultConfig, List<ItemList> lstQuestions)
 {
     foreach (var q in lstQuestions)
     {
         var selectedQ = new SelectedQuetions();
         selectedQ.QuestionRelation = q;
         var qConfig = Globals.ThisAddIn.Session.GetQuestionSlideConfiguration(selectedQ.QuestionRelation.Id);
         selectedQ.AnswersVoted = CreateAnswersVotedShapes(resultConfig, qConfig);
         resultConfig.SelectedQuestions.Add(selectedQ);
     }
 }
        private Microsoft.Office.Interop.PowerPoint.Shape CreateChart(ResultSlideConfiguration resultConfig, out int index)
        {
            if (resultConfig.SelectedQuestions.Count != 2)
                throw new Exception("Debe seleccionar 2 preguntas");

            CrossComparisonEntity cross = new CrossComparisonEntity(resultConfig);

            var shape = PowerPointHelper.CreateChartOn(resultConfig.SlideAssociated,30,90,600,400, out index);

            var chart = shape.Chart;

            UpdateDataChart(chart, cross);

            return shape;
        }
 public void Ordering(ResultSlideConfiguration resultConfig)
 {
     var q = resultConfig.SelectedQuestions.First();
     switch (resultConfig.ValueOrder)
     {
         case HistValueOrder.Ninguno:
             //Ordering(q.AnswersVoted);
             break;
         case HistValueOrder.Ascendente:
             var orderedAsc = q.AnswersVoted.OrderBy(x => x.AnswerAssociated.GetNumericValueForOrder((int)resultConfig.Decimals)).ToList();
             Ordering(orderedAsc);
             break;
         case HistValueOrder.Descendente:
             var orderedDesc = q.AnswersVoted.OrderByDescending(x => x.AnswerAssociated.GetNumericValueForOrder((int)resultConfig.Decimals)).ToList();
             Ordering(orderedDesc);
             break;
         default:
             break;
     }
 }
        public void ResizeCharts(ResultSlideConfiguration resultConfig)
        {
            var q = resultConfig.SelectedQuestions.First();
            foreach (var answ in q.AnswersVoted)
            {
                int answerWidth = Convert.ToInt32(-100 + (100 - resultConfig.HistWidthPercent) * PowerPointHelper.SlideWidth / 100);
                answ.AnswerTextBox.Width = answerWidth;

                int leftChart = PowerPointHelper.GetLeftByPercent(resultConfig.HistWidthPercent)-70;
                int widthChart = PowerPointHelper.GetWidthByPercent(resultConfig.HistWidthPercent, Convert.ToInt32(answ.AnswerAssociated.GetPercentValue((int)resultConfig.Decimals)));

                answ.AnswerChart.Width = widthChart;
                int leftChartValue = leftChart + widthChart + 2;

                if (resultConfig.ValueOrder != HistValueOrder.Ninguno)
                {
                    answ.AnswerChart.Left = leftChart;
                    answ.AnswerChartValue.Left = leftChartValue;
                }
                else
                {
                    //if(resultConfig.NormalConfig.CopyQuestionShpapesFormat)
                    //{
                    //    CopyQuestionShapesFormat(answ);
                    //}
                    if(resultConfig.NormalConfig.KeepTogetherResult)
                    {
                        answ.AnswerChartValue.Left = answ.AnswerChart.Left + answ.AnswerChart.Width + 2;
                        answ.AnswerChartValue.Top = answ.AnswerChart.Top + 1;
                    }

                }
                answ.AnswerChartValue.TextFrame.TextRange.Font.Size = answ.AnswerAssociated.GetValueFontSize();

            }
        }
 public void UpdateSlide(ResultSlideConfiguration resultConfig)
 {
     foreach (var q in resultConfig.SelectedQuestions)
     {
         foreach (var answ in q.AnswersVoted)
         {
             answ.AnswerChartValue.TextFrame.TextRange.Text = answ.AnswerAssociated.GetValue(resultConfig.Valuetype, (int)resultConfig.Decimals);
         }
     }
 }
 public void Ordering(ResultSlideConfiguration resultConfig)
 {
     //throw new NotImplementedException();
 }
        private void ValidateResultSlide()
        {
            var slidesCounts = _app.ActivePresentation.Slides.Count;
            if (slidesCounts == 0)
            {
                MessageBox.Show("Agregue una nueva diapositiva", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                throw new Exception("Slides empty");
            }
            var slideId = ((Microsoft.Office.Interop.PowerPoint.Slide)_app.ActiveWindow.View.Slide).SlideID;

            if (!IsResultSlide(slideId))
            {
                MessageBox.Show(Resources.ResourceManager.GetString("Msg_IsNotResultSlide"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new Exception(Resources.ResourceManager.GetString("Msg_IsNotResultSlide"));
            }
            _currentConfig = Globals.ThisAddIn.Session.GetResultSlideConfiguration(slideId);
        }
        private List<RankingAnswerVotedEntity> RankigVotedShapes(ResultSlideConfiguration resultConfig)
        {
            float initialTop = 110;
            List<RankingAnswerVotedEntity> lst = new List<RankingAnswerVotedEntity>();
            for (int i = 0; i < resultConfig.RankingConfig.TopRanking; i++)
            {
                var ansVoted = new RankingAnswerVotedEntity();

                int answerWidth = Convert.ToInt32(-100 + (100 - resultConfig.HistWidthPercent) * PowerPointHelper.SlideWidth / 100);
                int answerTextboxIndex;
                var answerTextbox = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, 50, initialTop, answerWidth, 35,
                                            "#", 24,
                                            Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out answerTextboxIndex);

                int leftChart = PowerPointHelper.GetLeftByPercent(resultConfig.HistWidthPercent)-70;
                int widthChartValue = 0;
                //if (!double.IsNaN(answer.GetPercentValue((int)resultConfig.Decimals)))
                //    widthChartValue = Convert.ToInt32(answer.GetPercentValue((int)resultConfig.Decimals));
                int widthChart = PowerPointHelper.GetWidthByPercent(resultConfig.HistWidthPercent, widthChartValue);

                int shapeChartIndex;
                var shapeChart = PowerPointHelper.CreateShapeOn(resultConfig.SlideAssociated, leftChart, initialTop, widthChart, 35, out shapeChartIndex);

                int leftChartValue = leftChart + widthChart + 2;
                int widtChartValue = 95;
                int shapeChartValueIndex;
                var shapeChartValue = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, leftChartValue, initialTop, widtChartValue, 35,
                                            "0", 14,
                                            Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out shapeChartValueIndex);

                ansVoted.AnswerTextBox = answerTextbox;
                ansVoted.AnswerTextBoxIndex = answerTextboxIndex;

                ansVoted.AnswerChart = shapeChart;
                ansVoted.AnswerChartIndex = shapeChartIndex;

                ansVoted.AnswerChartValue = shapeChartValue;
                ansVoted.AnswerChartValueIndex = shapeChartValueIndex;

                lst.Add(ansVoted);

                initialTop += 50;
            }
            return lst;
        }
        private List<RankingVotes> GetRankingVotes(ResultSlideConfiguration resultConfig)
        {
            List<VotesFlat> rankingTotal = new List<VotesFlat>();
            Dictionary<AnswerEntity, List<VotesFlat>> dictAnswer = new Dictionary<Questions.Data.AnswerEntity, List<VotesFlat>>();

            foreach (var selectedQ in resultConfig.SelectedQuestions)
            {
                var qConfig = Globals.ThisAddIn.Session.GetQuestionSlideConfiguration(selectedQ.QuestionRelation.Id);
                AnswerEntity correctAnswer = null;
                List<VotesFlat> qRanking = qConfig.GetVotesFromCorrectAnswer(out correctAnswer);
                rankingTotal.AddRange(qRanking);
                if (correctAnswer != null)
                {
                    dictAnswer.Add(correctAnswer, qRanking);
                }
            }
            List<RankingVotes> rvotes = new List<RankingVotes>();
            foreach (var rnkg in rankingTotal)
            {
                int points = ComputatePointsFromCorrectAnswer(dictAnswer, rnkg);
                var r = rvotes.Where(x => x.KeyId == rnkg.KeyId).FirstOrDefault();
                if (r == null)
                    rvotes.Add(new RankingVotes(rnkg.KeyId, rnkg.Keytime, points));
                else
                {
                    r.CorrectAnswerCount++;
                    r.TimeSum += rnkg.Keytime;
                    r.PointsSum += points;
                }
            }

            List<RankingVotes> rvotesOrd = null;
            switch (resultConfig.ValueOrder)
            {
                case HistValueOrder.Ninguno:
                case HistValueOrder.Ascendente:
                    if(resultConfig.RankingConfig.ShowPointsAcum)
                        rvotesOrd = rvotes.OrderBy(x => x.PointsSum).ThenByDescending(y => y.TimeSum).ToList();
                    else
                        rvotesOrd = rvotes.OrderBy(x => x.CorrectAnswerCount).ThenByDescending(y => y.TimeSum).ToList();
                    break;
                case HistValueOrder.Descendente:
                    if (resultConfig.RankingConfig.ShowPointsAcum)
                        rvotesOrd = rvotes.OrderByDescending(x => x.PointsSum).ThenBy(y => y.TimeSum).ToList();
                    else
                        rvotesOrd = rvotes.OrderByDescending(x => x.CorrectAnswerCount).ThenBy(y => y.TimeSum).ToList();
                    break;
            }

            return rvotesOrd.Take(resultConfig.RankingConfig.TopRanking).ToList();
        }
 public void ResizeCharts(ResultSlideConfiguration resultConfig)
 {
     //throw new NotImplementedException();
 }
Пример #15
0
 internal void SaveResultConfiguration(ResultSlideConfiguration resultConfig)
 {
     resultConfig.IsNew = false;
     this.ResultSlideConfigurations.Add(resultConfig);
 }
Пример #16
0
        private List<MirrorAnswerVotedEntity> CreateAnswersVotedShapes(ResultSlideConfiguration resultConfig, Questions.Data.QuestionSlideConfiguration qConfig, int index)
        {
            var lst = new List<MirrorAnswerVotedEntity>();

            float initialTop = 110;
            foreach (var answer in qConfig.Answers)
            {
                var ansVoted = new MirrorAnswerVotedEntity();
                //text Answer
                if (index == 1)
                {
                    int answerWidth = Convert.ToInt32(-100 + (100 - resultConfig.HistWidthPercent) * PowerPointHelper.SlideWidth / 100);
                    int answerTextboxIndex;
                    var answerTextbox = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, 50, initialTop, answerWidth, 35,
                                                answer.TextToShow, 24,
                                                Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out answerTextboxIndex);
                    ansVoted.AnswerTextBox = answerTextbox;
                    ansVoted.AnswerTextBoxIndex = answerTextboxIndex;
                }

                //chart
                int leftChart = PowerPointHelper.GetLeftByPercent(resultConfig.HistWidthPercent, (index==1?2:1));
                if (index == 2)
                    leftChart += 60;
                int widthChartValue = 0;
                if (!double.IsNaN(answer.GetPercentValue((int)resultConfig.Decimals)))
                    widthChartValue = Convert.ToInt32(answer.GetPercentValue((int)resultConfig.Decimals));
                int widthChart = PowerPointHelper.GetWidthByPercent(resultConfig.HistWidthPercent, widthChartValue);
                int shapeChartIndex;
                var shapeChart = PowerPointHelper.CreateShapeOn(resultConfig.SlideAssociated, leftChart, initialTop, widthChart, 35, out shapeChartIndex);

                //text Chart
                int leftChartValue = leftChart + widthChart;
                int widtChartValue = 95;
                int shapeChartValueIndex;
                var shapeChartValue = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, leftChartValue, initialTop, widtChartValue, 35,
                                            answer.GetValue(resultConfig.Valuetype, (int)resultConfig.Decimals), answer.GetValueFontSize(),
                                            Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out shapeChartValueIndex);

                if (index == 1)
                {
                    ansVoted.AnswerChart = shapeChart;
                    ansVoted.AnswerChartIndex = shapeChartIndex;

                    ansVoted.AnswerChartValue = shapeChartValue;
                    ansVoted.AnswerChartValueIndex = shapeChartValueIndex;

                    ansVoted.AnswerAssociated = answer;
                }
                else if (index == 2)
                {
                    ansVoted.AnswerChart2 = shapeChart;
                    ansVoted.AnswerChart2Index = shapeChartIndex;

                    ansVoted.AnswerChartValue2 = shapeChartValue;
                    ansVoted.AnswerChartValue2Index = shapeChartValueIndex;

                    ansVoted.AnswerAssociated2 = answer;
                }
                lst.Add(ansVoted);

                initialTop += 50;
            }

            return lst;
        }
Пример #17
0
        private List<NormalAnswerVotedEntity> CreateAnswersVotedShapes(ResultSlideConfiguration resultConfig, Questions.Data.QuestionSlideConfiguration qConfig)
        {
            var lst = new List<NormalAnswerVotedEntity>();

            float initialTop = 110;
            foreach (var answer in qConfig.Answers)
            {
                var ansVoted = new NormalAnswerVotedEntity();

                int answerWidth = Convert.ToInt32(-100 + (100 - resultConfig.HistWidthPercent) * PowerPointHelper.SlideWidth / 100);
                int answerTextboxIndex;
                var answerTextbox = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, 50, initialTop, answerWidth, 35,
                                            answer.TextToShow, 24,
                                            Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out answerTextboxIndex);

                int leftChart = PowerPointHelper.GetLeftByPercent(resultConfig.HistWidthPercent)-70;
                int widthChartValue = 0;
                if (!double.IsNaN(answer.GetPercentValue((int)resultConfig.Decimals)))
                    widthChartValue = Convert.ToInt32(answer.GetPercentValue((int)resultConfig.Decimals));
                int widthChart = PowerPointHelper.GetWidthByPercent(resultConfig.HistWidthPercent, widthChartValue);

                int shapeChartIndex;
                var shapeChart = PowerPointHelper.CreateShapeOn(resultConfig.SlideAssociated, leftChart, initialTop, widthChart, 35, out shapeChartIndex);

                int leftChartValue = (leftChart + widthChart + 2);
                int widtChartValue = 95;
                int shapeChartValueIndex;
                var shapeChartValue = PowerPointHelper.CreateTextboxOn(resultConfig.SlideAssociated, leftChartValue, initialTop, widtChartValue, 35,
                                            answer.GetValue(resultConfig.Valuetype, (int)resultConfig.Decimals), answer.GetValueFontSize(),
                                            Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out shapeChartValueIndex);

                ansVoted.AnswerTextBox = answerTextbox;
                ansVoted.AnswerTextBoxIndex = answerTextboxIndex;

                ansVoted.AnswerChart = shapeChart;
                ansVoted.AnswerChartIndex = shapeChartIndex;

                ansVoted.AnswerChartValue = shapeChartValue;
                ansVoted.AnswerChartValueIndex = shapeChartValueIndex;

                ansVoted.AnswerAssociated = answer;

                lst.Add(ansVoted);

                initialTop += 50;
            }

            if (resultConfig.ValueOrder == HistValueOrder.Ninguno)
                if(resultConfig.NormalConfig.CopyQuestionShpapesFormat)
                    foreach (var answ in lst)
                    {
                        CopyQuestionShapesFormat(answ);
                    }

            return lst;
        }