public void Test_ResultIntegration_Add_SholdBeOk()
        {
            int expectedAmount = 4;
            int unrelatedId    = 3;

            _student.Id = unrelatedId;
            Result resultToSave = ObjectMother.GetNewValidResult(_student, _evaluation);
            Result resultSaved  = _service.Add(resultToSave);

            resultSaved.Id.Should().BeGreaterThan(0);
            IList <Result> results = _service.GetAll();

            results.Count.Should().Be(expectedAmount);
        }
        public async Task <IActionResult> GetAllEntries()
        {
            var entries = await _resultService.GetAll();

            Console.WriteLine("Inside get all entries " + entries);

            return(Ok(entries));
        }
        // GET: Results
        public ActionResult Index(int?examCoreStudentGroupID)
        {
            List <Result> results = new List <Result>();

            if (examCoreStudentGroupID == null)
            {
                results = _resultService.GetAll().ToList();
            }
            else
            {
                results = _resultService.GetResultsByStudentGroupAndExam2(examCoreStudentGroupID);
            }

            return(View(results));
        }
Ejemplo n.º 4
0
        public async Task <bool> UpdateCompletion(User user, Guid subjectId, CancellationToken token = default)
        {
            var subject = await AvailableSubjects.FirstOrDefaultAsync(x => x.Id == subjectId, token);

            if (subject == null)
            {
                return(false);
            }

            if (!await _progressionService.Exists(user, subject, token))
            {
                var firstModule  = subject.Modules.First(x => x.Order == subject.Modules.Min(module => module.Order));
                var firstConcept = firstModule.Concepts.First(x => x.Order == firstModule.Concepts.Min(concept => concept.Order));

                await _progressionService.Create(user, subject, firstConcept, token);
            }

            var entry = await _progressionService.Get(user, subject, token);

            var results = (await _resultService.GetAll(user, subject, token)).ToList();

            var validResultsCount = results.Count(result => result.Answer.Valid);
            var resultsCount      = results.Count;

            var questionsCount =
                subject.Modules.Sum(module =>
                                    module.Concepts.Sum(concept =>
                                                        concept.Exercises.Sum(exercise => exercise.Questions.Count) + concept.Lessons.Sum(lesson => lesson.Exercises.Sum(exercise => exercise.Questions.Count))));

            var completion = (resultsCount * 100d) / questionsCount;
            var score      = (validResultsCount * 100d) / questionsCount;

            return(await _progressionService.ExecuteTransaction(set =>
            {
                entry.Completion = completion;
                entry.Completed = resultsCount == questionsCount;

                if (entry.Completed)
                {
                    entry.Score = score;
                }
                else
                {
                    entry.Score = 0;
                }
            }, token));
        }
        public void Test_ResultService_GetAll_ShouldBeOk()
        {
            int expectedAmount = 1;

            _evaluation = ObjectMother.GetExistentValidEvaluation();
            _student    = ObjectMother.GetExistentValidStudent();
            _mockRepository.Setup(sr => sr.GetAll()).Returns(new List <Result> {
                ObjectMother.GetExistentValidResult(_student, _evaluation)
            });

            List <Result> results = _service.GetAll().ToList();

            results.Count.Should().Be(expectedAmount);
            results.First().Evaluation.Should().Be(_evaluation);
            results.First().Student.Should().Be(_student);
            _mockRepository.Verify(sr => sr.GetAll());
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <IEnumerable <Result> > > GetFromExercise(Guid exerciseId)
        {
            var exercise = await _exercises.Get(exerciseId, HttpContext.RequestAborted);

            if (exercise == null)
            {
                return(NotFound());
            }

            var result = await _results.GetAll(HttpContext.GetUser(), exercise, HttpContext.RequestAborted);

            if (result == null || !result.Any())
            {
                return(NoContent());
            }

            return(Ok(result));
        }
Ejemplo n.º 7
0
        // GET: Result
        public ActionResult Index()
        {
            var results = resultService.GetAll();

            return(View(results));
        }
Ejemplo n.º 8
0
        // GET: Admin/Result
        public async Task <ActionResult> Index()
        {
            List <Result> results = await _service.GetAll();

            return(View(results));
        }