Пример #1
0
        public IActionResult AutoCheck(string formId)
        {
            // Try to get the quiz form
            Form form = _formsRepository.GetById(formId);

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

            // Loop through the answer sets
            foreach (FormAnswersSet answerSet in _answersRepository.GetAll(formId))
            {
                // Get the stored scores
                Dictionary <string, int> scores = _scoresRepository.GetScore(formId, answerSet.Id);

                // Combine the data into a extended form answers model
                ExtendedFormAnswersSet model = AnswerChecking.ConstructExtendedFormAnswersSet(answerSet, form, scores);

                // Save the score if no manual checking is required
                if (model.ManualCheckingRequiredCount == 0)
                {
                    // Extract the scores
                    scores = model.Answers.ToDictionary(x => x.QuestionId, x => x.AssignedPoints.Value);

                    // Update the score
                    _scoresRepository.UpdateScore(formId, answerSet.Id, scores);
                }
            }

            // Redirect to the overview
            return(RedirectToAction("Index", new { formId }));
        }
Пример #2
0
        public IActionResult Get(string id)
        {
            Form form = _formsRepository.GetById(id);

            // TODO: error handling
            // Redirect to 404 if the form is hidden or inactive

            return(View(form));
        }
Пример #3
0
        public IActionResult Index(string id)
        {
            if (_formsRepository.ExistsAndAvailable(id))
            {
                Form form = _formsRepository.GetById(id);

                // TODO: error handling
                // Redirect to 404 if the form is hidden or inactive

                return(View(form));
            }
            else
            {
                return(NotFound());
            }
        }