public virtual ActionResult Index(Guid assessmentId) { var assessment = _assessmentHelper.GetAssessment(assessmentId); var questionAnswer = _questionAnswerHelper.GetQuestionAnswer(assessment); var viewModel = _questionViewModelBuilder.BuildQuestionViewModel(assessment, questionAnswer); return(View(viewModel)); }
public void IndexGET_GivenAssessmentId_QuestionBuilderShouldBeCalled() { var assessmentId = Guid.NewGuid(); var questionId = Guid.NewGuid(); var assessment = new Assessment() { CurrentWorkflowQuestionId = questionId }; var questionAnswer = new QuestionAnswer(); A.CallTo(() => _assessmentHelper.GetAssessment(assessmentId)).Returns(assessment); A.CallTo(() => _questionAnswerHelper.GetQuestionAnswer(assessment)).Returns(questionAnswer); _questionController.Index(assessmentId); A.CallTo(() => _questionViewModelBuilder.BuildQuestionViewModel(assessment, questionAnswer)).MustHaveHappened(Repeated.Exactly.Once); }
public AssessmentStatusEnum SetAssessmentNextStep(Guid assessmentId, Guid questionOptionId, string furtherInformation) { var assessment = _assessmentHelper.GetAssessment(assessmentId); var workflowStep = _workflowStepHelper.GetWorkflowStep(questionOptionId, assessment); if (workflowStep == null) { throw new WorkflowStepNotFoundException(); } if (!assessment.ReadOnly) { var questionAnswer = _questionAnswerHelper.GetQuestionAnswer(assessment); if (HasAnsweredPreviously(questionAnswer)) { _questionAnswerHelper.RemoveQuestionAnswer(questionAnswer); } _questionAnswerHelper.AddQuestionAnswer(questionOptionId, furtherInformation, assessment); } if (HasNextStep(workflowStep)) { var resetQuestionId = assessment.ResetWorkflowQuestionId; if (assessment.ReadOnly && HasProgressesedToRestartQuestion(assessment, workflowStep)) { _assessmentHelper.UpdateAssessmentReadonly(assessmentId, false); resetQuestionId = null; } _assessmentHelper.UpdateAssessmentQuestions(assessmentId, workflowStep.NextWorkflowQuestionId.Value, assessment.CurrentWorkflowQuestionId, resetQuestionId); } _assessmentHelper.UpdateAssessmentStatus(assessmentId, (AssessmentStatusEnum)workflowStep.OutcomeStatusId); SaveChanges(); return((AssessmentStatusEnum)workflowStep.OutcomeStatusId); }