public void Given_Evaluate_WhenScoreFormulaProvided_Score_ShouldBeCalculated()
        {
            var answerKeyOpticalForm = new AnswerKeyOpticalForm
            {
                Booklet = 'A',
                IncorrectEliminationRate = 0,
                ScoreFormulas            = new List <ScoreFormula>()
                {
                    new ScoreFormula(175, "Scholarship", 11)
                    {
                        Coefficients = new List <LessonCoefficient>()
                        {
                            new LessonCoefficient("Tr", 4.33f),
                            new LessonCoefficient("Math", 3.296f),
                            new LessonCoefficient("Science", 2.601f),
                            new LessonCoefficient("Social Science", 2.773f)
                        }
                    }
                }
            };

            answerKeyOpticalForm.AddSection(CreateSection(1, "Tr", 15));
            answerKeyOpticalForm.AddSection(CreateSection(2, "Math", 15));
            answerKeyOpticalForm.AddSection(CreateSection(3, "Science", 10));
            answerKeyOpticalForm.AddSection(CreateSection(4, "Social Science", 8));
            var answers     = Enumerable.Repeat('A', 48);
            var studentForm = new StudentOpticalForm('A');
            var random      = new Random();

            studentForm.SetFromScanOutput(new ScanOutput(answers, 0, random.Next(1000), 'A'), answerKeyOpticalForm);

            studentForm.Evaluate(answerKeyOpticalForm.IncorrectEliminationRate, answerKeyOpticalForm.ScoreFormulas);
            studentForm.Net.Should().Be(48);
            studentForm.Score.Should().Be(337.58f);
        }
        public void Given_Evaluate_ShouldCalculateExpectedly()
        {
            var answerKeyOpticalForm = new AnswerKeyOpticalForm
            {
                Booklet = 'A',
                IncorrectEliminationRate = 4,
            };

            answerKeyOpticalForm.AddSection(new AnswerKeyOpticalFormSection(1, "Test", 20, default, default)
        public void GivenExpand_WhenAllFormsMatched_ThenAllFormsShouldReturn()
        {
            var form = new AnswerKeyOpticalForm
            {
                Booklet  = 'A',
                ExamDate = DateTime.UtcNow.AddDays(-10),
                ExamId   = 10,
                ExamName = "Test",
                IncorrectEliminationRate = 4,
                ScoreFormulas            = new List <ScoreFormula>()
                {
                    new ScoreFormula(100, "TYT", 11)
                    {
                        Coefficients = new List <LessonCoefficient>()
                        {
                            new LessonCoefficient("Math", 2)
                        }
                    }
                }
            };

            form.AddSection(
                new AnswerKeyOpticalFormSection(1, "Test")
            {
                Answers = new List <AnswerKeyQuestionAnswer>()
                {
                    new AnswerKeyQuestionAnswer(1, 2, 3, 4, 'A', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(2, 3, 4, 1, 'B', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(3, 4, 1, 2, 'C', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(4, 1, 2, 3, 'D', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(5, 6, 7, 8, 'A', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(6, 7, 8, 5, 'C', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(7, 8, 5, 6, 'B', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(8, 5, 6, 7, 'A', 0, string.Empty),
                }
            });

            var forms = form.Expand();

            forms.Should().Contain(f => f.Booklet == 'A' &&
                                   f.Sections.Count == 1 &&
                                   f.ScoreFormulas.First().Coefficients.First().Lesson == "Math" &&
                                   string.Join(",", f.Answers.Select(a => a.Answer).ToArray()) == "A,B,C,D,A,C,B,A");
            forms.Should().Contain(f => f.Booklet == 'B' &&
                                   f.Sections.Count == 1 &&
                                   f.ScoreFormulas.First().Coefficients.First().Lesson == "Math" &&
                                   string.Join(",", f.Answers.Select(a => a.Answer).ToArray()) == "D,A,B,C,A,A,C,B");
            forms.Should().Contain(f => f.Booklet == 'C' &&
                                   f.Sections.Count == 1 &&
                                   f.ScoreFormulas.First().Coefficients.First().Lesson == "Math" &&
                                   string.Join(",", f.Answers.Select(a => a.Answer).ToArray()) == "C,D,A,B,B,A,A,C");
            forms.Should().Contain(f => f.Booklet == 'D' &&
                                   f.Sections.Count == 1 &&
                                   f.ScoreFormulas.First().Coefficients.First().Lesson == "Math" &&
                                   string.Join(",", f.Answers.Select(a => a.Answer).ToArray()) == "B,C,D,A,C,B,A,A");
        }
Ejemplo n.º 4
0
 internal void FillMissingSections(StudentOpticalForm form, AnswerKeyOpticalForm answerKeyForm)
 {
     foreach (var section in answerKeyForm.Sections)
     {
         if (!form.ContainsSection(section.LessonId))
         {
             form.AddEmptySection(section);
         }
     }
 }
Ejemplo n.º 5
0
        public async Task FormWithScoreShouldBeAdded()
        {
            var scoreFormula = new ScoreFormula(100, "5. Grade");

            scoreFormula.Coefficients.Add(new LessonCoefficient("Turkish", 3.333f));
            scoreFormula.Coefficients.Add(new LessonCoefficient("Social Science", 3.333f));
            scoreFormula.Coefficients.Add(new LessonCoefficient("Basic Mathematics", 3.334f));
            scoreFormula.Coefficients.Add(new LessonCoefficient("Science", 3.334f));
            var answerKeyForm = new AnswerKeyOpticalForm(
                'A',
                new List <ScoreFormula> {
                scoreFormula
            });

            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(1, "Turkish", 40, 1, 1)
            {
                Answers = ParseAnswers("CECBEEBADEEBACBDBBEDDAEDDACEABDEDCBDBABD"),
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(6, "Social Science", 20, 1, 2)
            {
                Answers = ParseAnswers("EAEADADECEEDCDEAEDBA"),
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(5, "Basic Mathematics", 40, 2, 3)
            {
                Answers = ParseAnswers("DDBECACAACBCBECAEAADCDCDEDABAACCBDBAEDCB"),
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(2, "Science", 20, 2, 4)
            {
                Answers = ParseAnswers("DBCCEEBAEECAACBBDECE"),
            });
            var studentForm = new StudentOpticalForm('A');

            studentForm.SetFromScanOutput(new ScanOutput("CE EEE       C   EA DAE  ADEBEDEDCADEBAEDBE     D  B DEAEAAA", 1), answerKeyForm);
            studentForm.SetFromScanOutput(new ScanOutput("CB                                      A     CE  D         ", 2), answerKeyForm);
            studentForm.Evaluate(4, answerKeyForm.ScoreFormulas);

            var userId = RandomGen.Next(10000);

            studentForm.UserId = userId.ToString();
            studentForm.ExamId = RandomGen.Next();

            using (var testServer = Create(userId))
            {
                var client = testServer.CreateClient();

                var forms = new List <StudentOpticalForm>
                {
                    studentForm,
                };
                var response = await client.PostAsync(ApiPath, forms.ToJsonContent());

                response.EnsureSuccessStatusCode();
            }
        }
        public void Give_Evaluate_When_FormulaChanges_ThenCalculatedFormulas_Should_Be_Changed()
        {
            var answerKeyOpticalForm = new AnswerKeyOpticalForm
            {
                Booklet = 'A',
                IncorrectEliminationRate = 0,
                ScoreFormulas            = new List <ScoreFormula>()
                {
                    new ScoreFormula(100, "LGS", 8)
                    {
                        Coefficients = new List <LessonCoefficient>()
                        {
                            new LessonCoefficient("Tr", 4),
                            new LessonCoefficient("Math", 3)
                        }
                    }
                }
            };

            answerKeyOpticalForm.AddSection(CreateSection(1, "Tr", 3));
            answerKeyOpticalForm.AddSection(CreateSection(2, "Math", 3));

            var random      = new Random();
            var answers     = Enumerable.Repeat('A', 6);
            var studentForm = new StudentOpticalForm('A');

            studentForm.Grade = 8;
            studentForm.SetFromScanOutput(new ScanOutput(answers, 0, random.Next(1000), 'A'), answerKeyOpticalForm);
            studentForm.Evaluate(0, answerKeyOpticalForm.ScoreFormulas);
            var previousScoreName = studentForm.Scores.First().Key;
            var previousScore     = studentForm.Scores.First().Value;

            answerKeyOpticalForm.ScoreFormulas = new List <ScoreFormula>()
            {
                new ScoreFormula(100, "TYT", 10)
                {
                    Coefficients = new List <LessonCoefficient>()
                    {
                        new LessonCoefficient("Tr", 1),
                        new LessonCoefficient("Math", 1)
                    }
                }
            };
            studentForm.Evaluate(0, answerKeyOpticalForm.ScoreFormulas);
            studentForm.Scores.First().Key.Should().NotBe(previousScoreName);
            studentForm.Scores.First().Value.Should().NotBe(previousScore);
        }
Ejemplo n.º 7
0
        public void ShouldCalculateCorrectScore()
        {
            var scoreFormula = new ScoreFormula(100, "TYT", 11);

            scoreFormula.Coefficients.Add(new LessonCoefficient("Turkish", 3.333f));
            scoreFormula.Coefficients.Add(new LessonCoefficient("Social Science", 3.333f));
            scoreFormula.Coefficients.Add(new LessonCoefficient("Basic Mathematics", 3.334f));
            scoreFormula.Coefficients.Add(new LessonCoefficient("Science", 3.334f));

            var answerKeyForm = new AnswerKeyOpticalForm(
                'A',
                new List <ScoreFormula> {
                scoreFormula
            });

            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(1, "Turkish", 40, 1, 1)
            {
                Answers = "CECBEEBADEEBACBDBBEDDAEDDACEABDEDCBDBABD".ParseAnswerkeyAnswers()
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(6, "Social Science", 20, 1, 2)
            {
                Answers = "EAEADADECEEDCDEAEDBA".ParseAnswerkeyAnswers()
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(5, "Basic Mathematics", 40, 2, 3)
            {
                Answers = "DDBECACAACBCBECAEAADCDCDEDABAACCBDBAEDCB".ParseAnswerkeyAnswers()
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(2, "Science", 20, 2, 4)
            {
                Answers = "DBCCEEBAEECAACBBDECE".ParseAnswerkeyAnswers()
            });

            var studentForm = new StudentOpticalForm('A');
            var random      = new Random();

            studentForm.SetFromScanOutput(new ScanOutput("CE EEE       C   EA DAE  ADEBEDEDCADEBAEDBE     D  B DEAEAAA", 1, random.Next(), 'A'), answerKeyForm);
            studentForm.SetFromScanOutput(new ScanOutput("CB                                      A     CE  D         ", 2, random.Next(), 'A'), answerKeyForm);
            studentForm.Evaluate(4, answerKeyForm.ScoreFormulas);
            studentForm.Net.Should().Be(15.25f);
            studentForm.Score.Should().Be(150.83f);
            Math.Round(studentForm.SuccessPercent).Should().Be(13f);
        }
        public void GivenExpand_WhenOnlyOneFormExists_ThenShouldReturnOneForm()
        {
            var form = new AnswerKeyOpticalForm
            {
                Booklet  = 'A',
                ExamDate = DateTime.UtcNow.AddDays(-10),
                ExamId   = 10,
                ExamName = "Test",
                IncorrectEliminationRate = 4,
            };

            form.AddSection(new AnswerKeyOpticalFormSection(1, "Test")
            {
                Answers = new List <AnswerKeyQuestionAnswer>()
                {
                    new AnswerKeyQuestionAnswer(1, 0, 0, 0, 'A', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(2, 0, 0, 0, 'B', 0, string.Empty),
                    new AnswerKeyQuestionAnswer(3, 0, 0, 0, 'C', 0, string.Empty),
                }
            });

            form.Expand().Should().HaveCount(1);
        }
        public void Given_UpdateAnswers_WhenAnyCorrectAnswerChanged_Then_ResultsShouldChange()
        {
            var answerKeyForm = new AnswerKeyOpticalForm('A', null);

            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(1, "Mat", 3, 1, 1)
            {
                Answers = "AAA".ParseAnswerkeyAnswers()
            });
            answerKeyForm.AddSection(new AnswerKeyOpticalFormSection(2, "TR", 3, 1, 2)
            {
                Answers = "BBB".ParseAnswerkeyAnswers()
            });
            var form   = new StudentOpticalForm('A');
            var random = new Random();

            form.SetFromScanOutput(new ScanOutput("AAABBB", 1, random.Next(1000), 'A'), answerKeyForm);
            form.Evaluate(0, null);
            form.CorrectCount.Should().Be(6);
            answerKeyForm.Sections.First().Answers = "CCC".ParseAnswerkeyAnswers();
            form.UpdateCorrectAnswers(answerKeyForm);
            form.Evaluate(0, null);
            form.CorrectCount.Should().Be(3);
        }