示例#1
0
        // GET: YesNo
        public virtual ActionResult Index(Guid id, Guid questionId)
        {
            var survey   = _db.SurveyInstances.First(s => s.ExternalId == id);
            var question = survey.QuestionInstances.First(q => q.ExternalId == questionId);


            var model = new SimpleQuestionFormViewModel()
            {
                Title = question.Question.QuestionText,
                Input = new LookupViewModel()
                {
                    Value          = question.Answer,
                    PossibleValues = new List <LookupItem>()
                    {
                        new LookupItem()
                        {
                            Key = true.ToString(), Description = "Ja"
                        },
                        new LookupItem()
                        {
                            Key = false.ToString(), Description = "Nee"
                        },
                    }
                }
            };

            return(View(model));
        }
示例#2
0
        public virtual async Task <ActionResult> Index(Guid id, Guid questionId, SimpleQuestionFormViewModel form)
        {
            var survey   = _db.SurveyInstances.First(s => s.ExternalId == id);
            var question = survey
                           .QuestionInstances
                           .First(q => q.ExternalId == questionId);

            question.Answer = form.Input.Value;
            question.State  = QuestionState.Answered;

            await _db.SaveChangesAsync();

            return(RedirectToAction(MVC.Survey.Resume(id)));
        }
示例#3
0
        public virtual async Task <ActionResult> Index(Guid id, Guid questionId, SimpleQuestionFormViewModel form)
        {
            var survey   = _db.SurveyInstances.First(s => s.ExternalId == id);
            var question = survey
                           .QuestionInstances
                           .First(q => q.ExternalId == questionId);

            //in real life ga je de resultaten iets slimmer stockeren, maar dat mogen jullie zelf uitmodeleren :-)
            question.Answer = form.Input.Value;
            question.State  = QuestionState.Answered;

            await _db.SaveChangesAsync();

            return(RedirectToAction(MVC.Survey.Resume(id)));
        }
示例#4
0
        // GET: YesNo
        public virtual ActionResult Index(Guid id, Guid questionId)
        {
            var survey             = _db.SurveyInstances.First(s => s.ExternalId == id);
            var question           = survey.QuestionInstances.First(q => q.ExternalId == questionId);
            var questionDefinition = (MultipleChoice)question.Question;

            var model = new SimpleQuestionFormViewModel()
            {
                Title = question.Question.QuestionText,
                Input = new LookupViewModel()
                {
                    Value          = question.Answer,
                    PossibleValues = questionDefinition.PossibleAnswers.Select(a => new LookupItem()
                    {
                        Key = a.Category, Description = a.Category
                    })
                }
            };

            return(View(model));
        }