/// <summary>
        /// Get the max possible score from a grading
        /// </summary>
        /// <param name="Grading">The grading to check maximum score</param>
        /// <returns></returns>
        public static int GetMaxScore(this GradingPoints Grading)
        {
            if (Grading.IsMarkAIncluded)
            {
                return(Grading.MarkA.TopLimit);
            }

            return(Grading.MarkB.TopLimit);
        }
Beispiel #2
0
        /// <summary>
        /// Adds grading to the test
        /// </summary>
        /// <param name="NewGrading">New grading to be attached</param>
        public void AddGrading(GradingPoints NewGrading)
        {
            if (NewGrading == null)
            {
                throw new NullReferenceException("Value cannot be null");
            }

            if (NewGrading.GetMaxScore() != CreatedObject.TotalPointScore)
            {
                throw new Exception("This grading does not match this test");
            }

            CreatedObject.Grading = NewGrading;
        }
Beispiel #3
0
        public void CreatingTestFromScratch_RemovingQuestion_GoodValue()
        {
            var Builder = new TestBuilder(CorrectTest);
            
            Builder.RemoveQuestion(AddedQuestion);


            var CorrectGrading = new GradingPoints();
            CorrectGrading.UpdateMark(Marks.A, 50, 50);
            Builder.AddGrading(CorrectGrading);

            var Test = Builder.GetResult();

            Assert.IsTrue(!Test.Questions.Contains(AddedQuestion));
        }
        /// <summary>
        /// Converts values in points to percentage values
        /// </summary>
        /// <returns>New grading with value in percentage</returns>
        public static GradingPercentage ConvertToPercentage(this GradingPoints Grades)
        {
            var result = new GradingPercentage();

            var bottom    = 0;
            var top       = 0;
            var maxPoints = 0;

            if (Grades.IsMarkAIncluded)
            {
                maxPoints = Grades.MarkA.TopLimit;
                top       = PointsToPercent(Grades.MarkA.TopLimit, maxPoints);
                bottom    = PointsToPercent(Grades.MarkA.BottomLimit, maxPoints);
                result.UpdateMark(Marks.A, top, bottom);
                result.IsMarkAIncluded = true;
            }
            else
            {
                result.IsMarkAIncluded = false;
                maxPoints = Grades.MarkB.TopLimit;
            }

            top    = PointsToPercent(Grades.MarkB.TopLimit, maxPoints);
            bottom = PointsToPercent(Grades.MarkB.BottomLimit, maxPoints);
            result.UpdateMark(Marks.B, top, bottom);

            top    = bottom - 1;
            bottom = PointsToPercent(Grades.MarkC.BottomLimit, maxPoints);
            result.UpdateMark(Marks.C, top, bottom);


            top    = bottom - 1;
            bottom = PointsToPercent(Grades.MarkD.BottomLimit, maxPoints);
            result.UpdateMark(Marks.D, top, bottom);

            top    = bottom - 1;
            bottom = PointsToPercent(Grades.MarkE.BottomLimit, maxPoints);
            result.UpdateMark(Marks.E, top, bottom);

            top    = bottom - 1;
            bottom = PointsToPercent(Grades.MarkF.BottomLimit, maxPoints);
            result.UpdateMark(Marks.F, top, bottom);

            return(result);
        }
Beispiel #5
0
        public void CreatingTestFromScratch_AddingGrading_CorrectScore()
        {
            var Builder = new TestBuilder();
            var grading = new GradingPoints();
            grading.UpdateMark(Marks.A, 100, 80);

            var Question = new MultipleChoiceQuestion()
            {
                CorrectAnswerIndex = 1,
                Options = new List<string>() { "1", "2", "3" },
                Task = new TaskContent("dsdsd"),
                Scoring = new Scoring(ScoringMode.FullAnswer, 100),
            };

            Builder.AddQuestion(Question);

            Builder.AddGrading(grading);
        }
Beispiel #6
0
        public void CreatingTestFromScratch_UpdatingQuestion_GoodValue()
        {
            var Builder = new TestBuilder(CorrectTest);

            var NewQuestion = new SingleTextBoxQuestion()
            {
                CorrectAnswer = "ddd",
                Scoring = new Scoring(ScoringMode.FullAnswer, 10),
                Task = new TaskContent("dssd"),
            };

            Builder.UpdateQuestion(AddedQuestion, NewQuestion);
            var CorrectGrading = new GradingPoints();

            CorrectGrading.UpdateMark(Marks.A, 60, 50);
            Builder.AddGrading(CorrectGrading);

            var test = Builder.GetResult();

            Assert.IsTrue(test.Questions.Contains(NewQuestion));
        }
        /// <summary>
        /// Gets a mark based on a score
        /// </summary>
        /// <param name="points">Points the user scored in the test</param>
        /// <returns>The corresponding mark</returns>
        public static Marks GetMark(this GradingPoints Grading, int points)
        {
            if (Grading.IsMarkAIncluded)
            {
                if (points >= Grading.MarkA.BottomLimit)
                {
                    return(Marks.A);
                }
            }

            if (points >= Grading.MarkB.BottomLimit)
            {
                return(Marks.B);
            }

            if (points >= Grading.MarkC.BottomLimit)
            {
                return(Marks.C);
            }

            if (points >= Grading.MarkD.BottomLimit)
            {
                return(Marks.D);
            }

            if (points >= Grading.MarkE.BottomLimit)
            {
                return(Marks.E);
            }

            if (points >= Grading.MarkF.BottomLimit)
            {
                return(Marks.F);
            }

            throw new Exception("No grading available for this score!");
        }
Beispiel #8
0
        /// <summary>
        /// Cnoverts percentage values to points
        /// </summary>
        /// <param name="maxPoints">Maximum possible score</param>
        /// <returns>New points grading</returns>
        public GradingPoints ToPoints(int maxPoints)
        {
            var result = new GradingPoints();

            var top    = 0;
            var bottom = 0;

            if (IsMarkAIncluded)
            {
                result.IsMarkAIncluded = true;
                top    = PercentToPoint(MarkA.TopLimit, maxPoints);
                bottom = PercentToPoint(MarkA.BottomLimit, maxPoints);
                result.UpdateMark(Marks.A, top, bottom);
            }
            else
            {
                result.IsMarkAIncluded = false;
            }

            top    = PercentToPoint(MarkB.TopLimit, maxPoints);
            bottom = PercentToPoint(MarkB.BottomLimit, maxPoints);
            if (top == result.MarkA.BottomLimit)
            {
                top--;
            }
            while (bottom > top)
            {
                bottom--;
            }
            result.UpdateMark(Marks.B, top, bottom);

            top    = bottom - 1;
            bottom = PercentToPoint(MarkC.BottomLimit, maxPoints);
            while (bottom > top)
            {
                bottom--;
            }
            result.UpdateMark(Marks.C, top, bottom);

            top    = bottom - 1;
            bottom = PercentToPoint(MarkD.BottomLimit, maxPoints);
            while (bottom > top)
            {
                bottom--;
            }
            result.UpdateMark(Marks.D, top, bottom);

            top    = bottom - 1;
            bottom = PercentToPoint(MarkE.BottomLimit, maxPoints);
            while (bottom > top)
            {
                bottom--;
            }
            result.UpdateMark(Marks.E, top, bottom);

            top    = bottom - 1;
            bottom = PercentToPoint(MarkF.BottomLimit, maxPoints);
            while (bottom > top)
            {
                bottom--;
            }
            result.UpdateMark(Marks.F, top, bottom);

            return(result);
        }