public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            HttpContext.Session.SetInt32("AssignmentID", (int)id);
            submitAssignment = _context.SubmitAssignments.ToList();

            submitAssignment = submitAssignment.Where(x => x.AssignmentID == HttpContext.Session.GetInt32("AssignmentID")).ToList();
            scoreArray       = new int[submitAssignment.Count()];



            for (int i = 0; i < submitAssignment.Count(); i++)
            {
                scoreArray[i] = submitAssignment[i].Points;
            }
            List <int> scoreList     = scoreArray.ToList();
            List <int> boxPlotScores = SubmitAssignment.calulateBoxPlot(scoreList);

            min = boxPlotScores[0];
            q1  = boxPlotScores[1];
            med = boxPlotScores[2];
            q3  = boxPlotScores[3];
            max = boxPlotScores[4];

            if (submitAssignment == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 2
0
        public void TestingBoxPlot()
        {
            //Testing Even indexed arrays
            List <int> escores = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            List <int> eshouldReturn = new List <int> {
                1, 3, 5, 8, 10
            };
            List <int> etemp = SubmitAssignment.calulateBoxPlot(escores);

            CollectionAssert.AreEqual(etemp, eshouldReturn);

            //Testing Odd indexed arrays
            List <int> oscores = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };
            List <int> oshouldReturn = new List <int> {
                1, 2, 5, 7, 9
            };
            List <int> otemp = SubmitAssignment.calulateBoxPlot(oscores);

            CollectionAssert.AreEqual(otemp, oshouldReturn);

            //Testing Even indexed arrays
            List <int> zscores       = new List <int>();
            List <int> zshouldReturn = new List <int> {
                0, 0, 0, 0, 0
            };
            List <int> ztemp = SubmitAssignment.calulateBoxPlot(zscores);

            CollectionAssert.AreEqual(ztemp, zshouldReturn);

            //Testint Arrays with one index
            List <int> sscores = new List <int> {
                5
            };
            List <int> sshouldReturn = new List <int> {
                5, 5, 5, 5, 5
            };
            List <int> stemp = SubmitAssignment.calulateBoxPlot(sscores);

            CollectionAssert.AreEqual(stemp, sshouldReturn);
        }