/// <summary>
 /// Adding student test results to a binary tree
 /// </summary>
 /// <param name="studentTestResult">Student test results.</param>
 public void AddStudentTestResultToBinaryTree(StudentTestResult studentTestResult)
 {
     if (studentTestResult != null)
     {
         BinaryTreeStudentTestResult.Add(studentTestResult);
     }
 }
        public void GivenXmlSerialaizerWhenInputIsStudentTestResultRepositoryThenOutIsXMLFileStudentTestResultRepository()
        {
            //Arrange
            StudentTestResult studentVasaTestResult = new StudentTestResult(new Student(0, "Vasa"), new Test(TestItems.Algebra, new DateTime(10, 10, 10)), 100);
            StudentTestResult studentVovaTestResult = new StudentTestResult(new Student(1, "Andrey"), new Test(TestItems.Algebra, new DateTime(10, 10, 20)), 990);
            StudentTestResult studentDimaTestResult = new StudentTestResult(new Student(2, "Dima"), new Test(TestItems.Art, new DateTime(30, 1, 20)), 80);

            StudentTestResultRepository studentTestResultRepository = new StudentTestResultRepository();
            bool   fileIsExist = false;
            string path        = "../netcoreapp3.1/StudentTestResultRepository.xml";

            //Act
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVasaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVovaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentDimaTestResult);

            Serialization.XmlSerialaizer <StudentTestResultRepository>(studentTestResultRepository);

            FileInfo fileInfo = new FileInfo(path);

            if (fileInfo.Exists)
            {
                fileIsExist = true;
            }

            //Assert
            Assert.AreEqual(true, fileIsExist);
        }
        public StudentTestResult GetStudentTestResult(int attemptId)
        {
            var obj = new StudentTestResult();

            using (var ctx = new TestStudentDBEntities())
            {
                var attempt = ctx.TestAttempts.FirstOrDefault(a => a.Id == attemptId);
                if (attempt != null)
                {
                    obj.Student = ctx.Students.FirstOrDefault(s => s.Id == attempt.StudentId);

                    var testId             = attempt.TestId;
                    var allQuestionCount   = ctx.TestInstances.Where(t => t.Id == testId).Select(t => t.QuestionCount).FirstOrDefault();
                    var correctAnswerCount = ctx.AttemptResults.Count(r => r.AttemptId == attempt.Id && r.IsCorrect);

                    obj.AllQuestionCount   = allQuestionCount;
                    obj.RightQuestionCount = correctAnswerCount;

                    obj.PersentResult = (allQuestionCount != 0) ? ((double)correctAnswerCount / (double)allQuestionCount) * 100 : 0;

                    obj.Grade    = attempt.Grade != null?(Grade)attempt.Grade:Grade.None;
                    obj.TimeIsUp = attempt.IsTimeIsUp;
                }
            }
            return(obj);
        }
예제 #4
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            StudentTestResult studentTestResult = new StudentTestResult(FirstName, LastName, TestName, TestDate, Score);

            StudentTestCreated?.Invoke(studentTestResult);
            Close();
        }
예제 #5
0
        public void GivenAddStudentTestResultToBinaryTreeThenOutIsStudentBinaryTree()
        {
            //Arrange
            StudentTestResult              studentVasaTestResult       = new StudentTestResult(new Student(0, "Vasa"), new Test(TestItems.Algebra, new DateTime(10, 10, 10)), 100);
            StudentTestResult              studentVovaTestResult       = new StudentTestResult(new Student(1, "Andrey"), new Test(TestItems.Algebra, new DateTime(10, 10, 20)), 990);
            StudentTestResult              studentDimaTestResult       = new StudentTestResult(new Student(2, "Dima"), new Test(TestItems.Art, new DateTime(30, 1, 20)), 80);
            StudentTestResultRepository    studentTestResultRepository = new StudentTestResultRepository();
            BinaryTree <StudentTestResult> expectedBinaryTree          = new BinaryTree <StudentTestResult>();

            //Act
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVasaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVovaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentDimaTestResult);

            var actualBinaryTreeStudentTestResult = studentTestResultRepository.BinaryTreeStudentTestResult;

            expectedBinaryTree.Count = 3;
            expectedBinaryTree.Root  =
                new Node <StudentTestResult>(
                    studentVasaTestResult,
                    new Node <StudentTestResult>(
                        studentDimaTestResult), new Node <StudentTestResult>(
                        studentVovaTestResult));

            //Assert
            Assert.AreEqual(expectedBinaryTree, actualBinaryTreeStudentTestResult);
        }
예제 #6
0
        public StudentTestResult GetStudentResultById(Guid id)
        {
            StudentTestResult studentResult = new StudentTestResult();

            try
            {
                studentResult = Database.StudentTestResults.GetById(id);
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex.Message);
            }
            return(studentResult);
        }
예제 #7
0
 public void UpdateStudResult(double mark, Guid idStudResult)
 {
     try
     {
         StudentTestResult studentResult = GetStudentResultById(idStudResult);
         studentResult.PercentOfRightAnswers = mark;
         Database.StudentTestResults.Update(studentResult);
         Database.StudentTestResults.Save();
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
     }
 }
예제 #8
0
        private void AddStudentTestResult(StudentTestResult studentTestResult)
        {
            studentTestResults.Add(studentTestResult);
            if (visibleStudentsTestsResults == null)
            {
                visibleStudentsTestsResults = new List<StudentTestResult>(studentTestResults);
            }
            else
            {
                visibleStudentsTestsResults.Add(studentTestResult);
            }

            ShowStudentsTestsResults();
        }
        public void GivenXmlDeserializeWhenInputIsPathToFileOutIsNewStudentTestResultRepository(string pathToXmlFile)
        {
            //Arrange
            StudentTestResult studentVasaTestResult = new StudentTestResult(new Student(0, "Vasa"), new Test(TestItems.Algebra, new DateTime(10, 10, 10)), 100);
            StudentTestResult studentVovaTestResult = new StudentTestResult(new Student(1, "Andrey"), new Test(TestItems.Algebra, new DateTime(10, 10, 20)), 990);
            StudentTestResult studentDimaTestResult = new StudentTestResult(new Student(2, "Dima"), new Test(TestItems.Art, new DateTime(30, 1, 20)), 80);

            StudentTestResultRepository studentTestResultRepository = new StudentTestResultRepository();

            //Act
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVasaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVovaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentDimaTestResult);

            var actualDeserialazedObj = Serialization.XmlDeserialize <StudentTestResultRepository>(pathToXmlFile);

            //Assert
            Assert.AreEqual(studentTestResultRepository, actualDeserialazedObj);
        }
예제 #10
0
        public Guid AddStudResultReturnId(string idStud, Guid idTest, DateTime timeStert, DateTime timeStop)
        {
            try
            {
                StudentTestResult studentResult = new StudentTestResult();
                studentResult.Id = Guid.NewGuid();
                studentResult.StudentProfileId = idStud;
                studentResult.TestId           = idTest;
                studentResult.StartTest        = timeStert;
                studentResult.EndtTest         = timeStop;

                Database.StudentTestResults.Create(studentResult);
                Database.StudentTestResults.Save();
                return(studentResult.Id);
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex.Message);
                return(Guid.Empty);
            }
        }
        //Action for adding the score
        public JsonResult SubmitScore(StudentScore result)
        {
            using (var db = new ApplicationDbContext())
            {
                //First get the test we are taking
                var test = (from t in db.Tests
                            where t.id == result.TestId
                            select t).FirstOrDefault();
                //Then get the student taking the test
                var student = (from s in db.Students
                               where s.id == result.StudentId
                               select s).FirstOrDefault();
                //Get the question count of this particular test
                var count = (from t in db.Tests
                             join tqd in db.TestQuestionDeploys on t.id equals tqd.Test.id
                             where t.id == result.TestId
                             select tqd).Count();
                //Then create the StudentTestResult object with these value, and save it
                var TestResult = new StudentTestResult()
                {
                    Test    = test,
                    Student = student,
                    Score   = result.Score
                };

                db.StudentTestResults.Add(TestResult);
                db.SaveChanges();

                //Then we will calculate the mean score for this particular test, to see how the students doing
                List <float> scores = (from str in db.StudentTestResults
                                       where str.Test.id == result.TestId
                                       select str.Score).ToList <float>();
                float avg = scores.Average();
                test.Rating = avg;
                db.SaveChanges();
            }
            return(Json("Score submitted"));
        }
예제 #12
0
 public JsonResult StudentResult(StudentTestResult result)
 {
     return(Json("Ok"));
 }