Exemple #1
0
        public IActionResult CreateAnswers(int onlineTestId, string questionId, [FromQuery] int numberOfAnswers)
        {
            var model = new AnswersListCreateInputModel
            {
                OnlineTestId       = onlineTestId,
                QuestionId         = questionId,
                AnswerCreateInputs = new List <AnswerCreateInputModel>(),
            };

            for (int i = 0; i < numberOfAnswers; i++)
            {
                model.AnswerCreateInputs.Add(new AnswerCreateInputModel());
            }

            return(this.View(model));
        }
Exemple #2
0
        public async Task <IActionResult> CreateAnswers
            (int onlineTestId, string questionId, int currQuestion, AnswersListCreateInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var answerType = AnswerType.RadioButtons;

            foreach (var answerInput in input.AnswerCreateInputs)
            {
                await this.examsService.CreateAnswerAsync(questionId, answerType, answerInput.Text, answerInput.Points);
            }

            return(this.RedirectToAction("CreateQuestion", "Exams", new { onlineTestId, currQuestion }));
        }