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);
        }
예제 #2
0
        public void JoinSets_Should_Join_Two_Separate_OpticalForms_Into_One()
        {
            var firstSet       = new List <StudentOpticalForm>();
            var secondSet      = new List <StudentOpticalForm>();
            var answerKeyForms = new List <AnswerKeyOpticalForm>
            {
                GenerateAnswerKeyFormA(),
                GeneratedAnswerKeyFormB(),
            };
            var studentForm = new StudentOpticalForm('A')
            {
                StudentId        = 1,
                StudentNumber    = 10512,
                StudentFirstName = "John",
                StudentLastName  = "Walker",
                ExamName         = "TYT",
                ExamDate         = DateTime.Today,
                ClassroomId      = 1,
                Classroom        = "12/E",
                SchoolId         = 1,
                UserId           = "1",
                CityId           = 35,
                CityName         = "Izmir",
                DistrictId       = 20,
                DistrictName     = "Bayrakli",
            };

            studentForm.SetFromScanOutput(new ScanOutput("EDCBAABDABCADBCCDECEDBDEDEBCEAACBADCCDEADEECBCCBCACEEBADBCDC", 1, 0, 'A'), answerKeyForms.First());
            studentForm.SetFromScanOutput(new ScanOutput("DDBBDAE BECBBDCAECEDBECCEB DACCDCB A  CDCDDABACDBCAEBEDBCABA", 2, 0, 'A'), answerKeyForms.First());
            firstSet.Add(studentForm);
            var studentForm2 = new StudentOpticalForm('A')
            {
                StudentId        = 1,
                StudentNumber    = 10512,
                StudentFirstName = "John",
                StudentLastName  = "Walker",
                ExamName         = "TYT",
                ExamDate         = DateTime.Today,
                ClassroomId      = 1,
                Classroom        = "12/E",
                SchoolId         = 1,
                UserId           = "1",
                CityId           = 35,
                CityName         = "Izmir",
                DistrictId       = 20,
                DistrictName     = "Bayrakli",
            };

            studentForm2.SetFromScanOutput(new ScanOutput("EDCDEAEECEAACBAECCDEAEDCBAABDBBC DBB DECCABDEBCAEBADCEEABDBD", 1, 0, 'A'), answerKeyForms.Last());
            studentForm2.SetFromScanOutput(new ScanOutput("AAECEDBECC BD A       AB                                    ", 2, 0, 'A'), answerKeyForms.Last());
            secondSet.Add(studentForm2);
            firstSet  = _evaluator.Evaluate(answerKeyForms, firstSet).ToList();
            secondSet = _evaluator.Evaluate(answerKeyForms, secondSet).ToList();
            firstSet.Should().NotBeEmpty();
            secondSet.Should().NotBeEmpty();
            var joinedSet = _evaluator.JoinSets(firstSet, secondSet);

            joinedSet.Should().HaveCount(1);
        }
예제 #3
0
 public Average Get(StudentOpticalForm form, string lessonName)
 {
     return(new Average(
                _name,
                GetGeneralAverage(lessonName),
                GetCityAverage(lessonName, form.CityId),
                GetDistrictAverage(lessonName, form.DistrictId),
                GetSchoolAverage(lessonName, form.SchoolId),
                GetClassroomAverage(lessonName, form.ClassroomId)));
 }
예제 #4
0
 internal void FillMissingSections(StudentOpticalForm form, AnswerKeyOpticalForm answerKeyForm)
 {
     foreach (var section in answerKeyForm.Sections)
     {
         if (!form.ContainsSection(section.LessonId))
         {
             form.AddEmptySection(section);
         }
     }
 }
 public StudentOrder GetStudentOrder(StudentOpticalForm form)
 {
     return(new StudentOrder(
                _orderName,
                _classroomOrderList[form.ClassroomId].IndexOf(_selector(form)) + 1,
                _schoolOrderList[form.SchoolId].IndexOf(_selector(form)) + 1,
                _districtOrderList[form.DistrictId].IndexOf(_selector(form)) + 1,
                _cityOrderList[form.CityId].IndexOf(_selector(form)) + 1,
                _generalOrderList.IndexOf(_selector(form)) + 1));
 }
예제 #6
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 Given_AddSections_When_SectionsDoNotExist_Then_Sections_ShouldBeAdded()
        {
            var form     = new StudentOpticalForm();
            var sections = new List <StudentOpticalFormSection>()
            {
                new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(1, "Turkce")),
                new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(2, "Matematik"))
            };

            form.AddSections(sections);
            form.Sections.Should()
            .Contain(s => s.LessonName == "Turkce" && s.LessonId == 1)
            .And
            .Contain(s => s.LessonName == "Matematik" && s.LessonId == 2);
        }
예제 #8
0
        public void Add(StudentOpticalForm form, StudentOpticalFormSection section)
        {
            if (!_dictionary.ContainsKey(section.LessonName))
            {
                _dictionary.Add(section.LessonName, new Dictionary <int, List <float> >());
            }

            var secondaryKey = _secondaryKeySelector(form);

            if (!_dictionary[section.LessonName].ContainsKey(secondaryKey))
            {
                _dictionary[section.LessonName].Add(secondaryKey, new List <float>());
            }

            _dictionary[section.LessonName][secondaryKey].Add(_valueSelector(section));
        }
        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);
        }
        public void EmptyCorrectAnswers_Should_NotAddedToScoreAndSuccessPercentCalculations()
        {
            var studentOpticalForm = new StudentOpticalForm()
            {
                Sections = new List <StudentOpticalFormSection>
                {
                    new StudentOpticalFormSection()
                    {
                        Answers = "ABCDA CDAA".ParseStudentAnswers("ABCDA CDAA")
                    }
                }
            };

            studentOpticalForm.Evaluate(0, null);
            studentOpticalForm.Score.Should().Be(100);
            studentOpticalForm.SuccessPercent.Should().Be(100);
        }
예제 #11
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);
        }
예제 #12
0
        public async Task ShouldDeleteTheForm_And_ReevaluateTheExam(int userId, StudentOpticalForm sform)
        {
            var client = _webApplicationFactory.CreateClientWithUserId(userId);

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

            response.EnsureSuccessStatusCode();
            var form = (await GetListAsync <StudentOpticalForm>(
                            client, forms.First().ExamId)).First();
            await client.DeleteAsync($"{ApiPath}/{form.Id}");

            form = (await GetListAsync <StudentOpticalForm>(
                        client, forms.First().ExamId)).FirstOrDefault();
            form.Should().BeNull();
            var events = Consumer.Instance.GetAll <IEvaluateExam>().ToList();

            events.Should().Contain(e => e.ExamId == forms.First().ExamId);
        }
        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);
        }
예제 #14
0
        public void FillMissingSections_Should_FillMissingSections()
        {
            var answerKeyForms = new List <AnswerKeyOpticalForm>
            {
                GenerateAnswerKeyFormA(),
                GeneratedAnswerKeyFormB(),
            };
            var evaluator   = new Evaluator(answerKeyForms);
            var studentForm = new StudentOpticalForm('A')
            {
                StudentId        = 6456,
                StudentNumber    = 543,
                StudentFirstName = "Nazmi",
                StudentLastName  = "Altun",
                ExamName         = "Test-54353",
                ExamDate         = DateTime.Today.AddDays(-2),
                ClassroomId      = 65,
                Classroom        = "11/B",
                SchoolId         = 4,
                UserId           = "4",
                CityId           = 35,
                CityName         = "Izmir",
                DistrictId       = 20,
                DistrictName     = "Bayrakli",
            };

            studentForm.SetFromScanOutput(new ScanOutput("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 1), answerKeyForms.First());
            evaluator.FillMissingSections(studentForm, answerKeyForms.First());
            studentForm.Sections.Count.Should().Be(answerKeyForms.First().Sections.Count);

            foreach (var section in answerKeyForms.First().Sections)
            {
                studentForm.Sections.First(s => s.LessonId == section.LessonId)
                .Answers.Count().Should().Be(section.Answers.Count);
            }
        }
예제 #15
0
        public void ShouldEvaluateExpectedly()
        {
            var answerKeyForms = new List <AnswerKeyOpticalForm>
            {
                GenerateAnswerKeyFormA(),
                GeneratedAnswerKeyFormB(),
            };

            var evaluator    = new Evaluator(answerKeyForms);
            var studentForms = new List <StudentOpticalForm>();
            var studentForm  = new StudentOpticalForm('A')
            {
                StudentId        = 1,
                StudentNumber    = 10512,
                StudentFirstName = "John",
                StudentLastName  = "Walker",
                ExamName         = "TYT",
                ExamDate         = DateTime.Today,
                ClassroomId      = 1,
                Classroom        = "12/E",
                SchoolId         = 1,
                UserId           = "1",
                CityId           = 35,
                CityName         = "Izmir",
                DistrictId       = 20,
                DistrictName     = "Bayrakli",
            };

            studentForm.SetFromScanOutput(new ScanOutput("EDCBAABDABCADBCCDECEDBDEDEBCEAACBADCCDEADEECBCCBCACEEBADBCDC", 1), answerKeyForms.First());
            studentForm.SetFromScanOutput(new ScanOutput("DDBBDAE BECBBDCAECEDBECCEB DACCDCB A  CDCDDABACDBCAEBEDBCABA", 2), answerKeyForms.First());
            studentForms.Add(studentForm);
            studentForm = new StudentOpticalForm('B')
            {
                StudentId        = 2,
                StudentNumber    = 10301,
                StudentFirstName = "Mary",
                StudentLastName  = "Bloody",
                ExamName         = "TYT",
                ExamDate         = DateTime.Today,
                ClassroomId      = 2,
                Classroom        = "12/C",
                UserId           = "1",
                SchoolId         = 1,
                CityId           = 35,
                CityName         = "Izmir",
                DistrictId       = 20,
                DistrictName     = "Bayrakli",
            };
            studentForm.SetFromScanOutput(new ScanOutput("EDCDEAEECEAACBAECCDEAEDCBAABDBBC DBB DECCABDEBCAEBADCEEABDBD", 1), answerKeyForms.Last());
            studentForm.SetFromScanOutput(new ScanOutput("AAECEDBECC BD A       AB                                    ", 2), answerKeyForms.Last());
            studentForms.Add(studentForm);

            studentForms = evaluator.Evaluate(studentForms);
            studentForms.First().Should().Match <StudentOpticalForm>(
                x => x.Net == 95 &&
                x.Score == 416.68f &&
                Math.Round(x.SuccessPercent) == 79);
            studentForms.Last().Should().Match <StudentOpticalForm>(
                x => x.Net == 60.5f &&
                x.Score == 301.66f &&
                Math.Round(x.SuccessPercent) == 50);
            studentForms.First().Orders
            .First(o => o.Name == "NET")
            .Should().Match <StudentOrder>(x =>
                                           x.GeneralOrder == 1 &&
                                           x.ClassroomOrder == 1 &&
                                           x.SchoolOrder == 1 &&
                                           x.DistrictOrder == 1 &&
                                           x.CityOrder == 1);
            studentForms.First().Orders
            .First(o => o.Name == answerKeyForms.First().ScoreFormulas.First().ScoreName)
            .Should().Match <StudentOrder>(x =>
                                           x.GeneralOrder == 1 &&
                                           x.ClassroomOrder == 1 &&
                                           x.SchoolOrder == 1 &&
                                           x.DistrictOrder == 1 &&
                                           x.CityOrder == 1);
            studentForms.Last().Orders
            .First(o => o.Name == "NET")
            .Should().Match <StudentOrder>(x =>
                                           x.GeneralOrder == 2 &&
                                           x.ClassroomOrder == 1 &&
                                           x.SchoolOrder == 2 &&
                                           x.DistrictOrder == 2 &&
                                           x.CityOrder == 2);
            studentForms.First().Sections
            .First(s => s.LessonName == "Tr")
            .Averages.First(a => a.Name == "NET")
            .Should().Match <Average>(
                x => x.City == 35.25f &&
                x.School == 35.25f &&
                x.Classroom == 37.5f &&
                x.District == 35.25f);
        }
        public void Given_AddSections_When_SectionsExist_Then_Sections_ShouldBeOverriden()
        {
            var form = new StudentOpticalForm()
            {
                Sections = new List <StudentOpticalFormSection>()
                {
                    new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(1, "Turkce"))
                    {
                        Answers = new List <QuestionAnswer>()
                        {
                            new QuestionAnswer(1, 'A'),
                            new QuestionAnswer(2, 'B'),
                            new QuestionAnswer(3, 'C'),
                        }
                    },
                    new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(2, "Matematik"))
                    {
                        Answers = new List <QuestionAnswer>()
                        {
                            new QuestionAnswer(1, 'D'),
                            new QuestionAnswer(2, 'C'),
                            new QuestionAnswer(3, 'D'),
                            new QuestionAnswer(4, 'B'),
                            new QuestionAnswer(5, 'A'),
                        }
                    }
                }
            };
            var sections = new List <StudentOpticalFormSection>()
            {
                new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(1, "Turkce"))
                {
                    Answers = new List <QuestionAnswer>()
                    {
                        new QuestionAnswer(1, 'E'),
                        new QuestionAnswer(2, 'D')
                    }
                },
                new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(2, "Matematik"))
                {
                    Answers = new List <QuestionAnswer>()
                    {
                        new QuestionAnswer(1, 'A'),
                        new QuestionAnswer(2, 'B'),
                        new QuestionAnswer(3, 'E'),
                    }
                },
                new StudentOpticalFormSection(new AnswerKeyOpticalFormSection(3, "Fen"))
                {
                    Answers = new List <QuestionAnswer>()
                    {
                        new QuestionAnswer(1, 'B'),
                        new QuestionAnswer(2, 'C')
                    }
                },
            };

            form.AddSections(sections);
            form.Sections.Should()
            .HaveCount(sections.Count)
            .And
            .Contain(s => s.LessonName == "Turkce" &&
                     string.Join(',', s.Answers.Select(a => a.Answer)) == "E,D")
            .And
            .Contain(s => s.LessonName == "Matematik" &&
                     string.Join(',', s.Answers.Select(a => a.Answer)) == "A,B,E")
            .And
            .Contain(s => s.LessonName == "Fen" &&
                     string.Join(',', s.Answers.Select(a => a.Answer)) == "B,C");
        }