internal async Task <ProgressionData> GenerateProgressionData(Course course)
        {
            var studyTime = await _context.GetCompletedStudySessionDurationsByCourse(course.Id);

            double aggRealStudyTime      = 0;
            double aggReferenceStudyTime = 0;

            int startWeek = GetWeekNumber(course.DateFrom);
            int endWeek   = course.IsActive ? GetWeekNumber(DateTime.Now) : GetWeekNumber(course.DateTo);

            double referenceProgressPerWeek = course.WorkLoad / (GetWeekNumber(course.DateTo) - GetWeekNumber(course.DateFrom));

            var referenceProgression = new List <double>();
            var realProgression      = new List <double>();
            var labels = new List <string>();

            referenceProgression.Add(0);
            realProgression.Add(0);
            labels.Add("");

            while (startWeek <= endWeek)
            {
                foreach (var v in studyTime)
                {
                    if (GetWeekNumber(v.StartDate) == startWeek)
                    {
                        aggRealStudyTime += v.Duration;
                    }
                }

                aggReferenceStudyTime += referenceProgressPerWeek;

                referenceProgression.Add(aggReferenceStudyTime);
                realProgression.Add(aggRealStudyTime);
                labels.Add($"Uke {startWeek.ToString()}");

                startWeek++;
            }


            var progressionData = new ProgressionData(realProgression, referenceProgression, labels);

            return(progressionData);
        }
        public Chart GenerateLineChart(ProgressionData progressionData)
        {
            var chart = new Chart
            {
                Type = "line",
                Data = new ChartJSCore.Models.Data
                {
                    Labels   = progressionData.labelsProgression,
                    Datasets = new List <Dataset>()
                    {
                        new LineDataset()
                        {
                            Label            = progressionData.lblReferenceProgression,
                            Data             = progressionData.dsReferenceProgression,
                            Fill             = "+1",
                            LineTension      = 0.1,
                            BackgroundColor  = "rgba(75, 192, 192, 0.4)",
                            BorderColor      = "rgba(75,192,192,1)",
                            BorderCapStyle   = "butt",
                            BorderDash       = new List <int> {
                            },
                            BorderDashOffset = 0.0,
                            BorderJoinStyle  = "miter",
                            PointBorderColor = new List <string>()
                            {
                                "rgba(75,192,192,1)"
                            },
                            PointBackgroundColor = new List <string>()
                            {
                                "#fff"
                            },
                            PointBorderWidth = new List <int> {
                                1
                            },
                            PointHoverRadius = new List <int> {
                                5
                            },
                            PointHoverBackgroundColor = new List <string>()
                            {
                                "rgba(75,192,192,1)"
                            },
                            PointHoverBorderColor = new List <string>()
                            {
                                "rgba(220,220,220,1)"
                            },
                            PointHoverBorderWidth = new List <int> {
                                2
                            },
                            PointRadius = new List <int> {
                                1
                            },
                            PointHitRadius = new List <int> {
                                10
                            },
                            SpanGaps = false
                        },
                        new LineDataset()
                        {
                            Label            = progressionData.lblRealProgression,
                            Data             = progressionData.dsRealProgression,
                            Fill             = "start",
                            LineTension      = 0.1,
                            BackgroundColor  = "rgba(133, 206, 54, 0.4)",
                            BorderColor      = "rgba(133, 206, 54,1)",
                            BorderCapStyle   = "butt",
                            BorderDash       = new List <int> {
                            },
                            BorderDashOffset = 0.0,
                            BorderJoinStyle  = "miter",
                            PointBorderColor = new List <string>()
                            {
                                "rgba(133, 206, 54,1)"
                            },
                            PointBackgroundColor = new List <string>()
                            {
                                "#fff"
                            },
                            PointBorderWidth = new List <int> {
                                1
                            },
                            PointHoverRadius = new List <int> {
                                5
                            },
                            PointHoverBackgroundColor = new List <string>()
                            {
                                "rgba(200, 150, 150,1)"
                            },
                            PointHoverBorderColor = new List <string>()
                            {
                                "rgba(220,220,220,1)"
                            },
                            PointHoverBorderWidth = new List <int> {
                                2
                            },
                            PointRadius = new List <int> {
                                1
                            },
                            PointHitRadius = new List <int> {
                                10
                            },
                            SpanGaps = false
                        }
                    }
                }
            };

            return(chart);
        }