Ejemplo n.º 1
0
        public async Task <KnowledgeTestResultModel> Submit(KnowledgeTestModel model)
        {
            var test = await knowledgeTestRepository.GetQuery().FirstOrDefaultAsync(x => x.Id == model.Id);

            test.ModifiedAt = DateTime.Now;

            foreach (var question in model.Questions)
            {
                var knowledgeQuestion = test.Questions.FirstOrDefault(x => x.Id == question.Id);

                knowledgeQuestion.IsProvidedCorrectAnswer = knowledgeTestResultService.IsProvidedCorrectAnswer(knowledgeQuestion, question);
            }

            await dataContext.SaveChangesAsync();

            return(knowledgeTestResultService.GetResult(test));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Submit(KnowledgeTestModel model)
        {
            var test = await testTemplatesService.Submit(model);

            return(Ok(test));
        }