@model QuestionnaireViewModel @{ ViewData["Title"] = "Questionnaire Details"; var totalAnswers = Model.Questions?.Sum(q => q.Answers?.Count ?? 0) ?? 0; var otherCount = Model.Questions?.Count(q => q.Answers != null && q.Answers.Any(a => a.IsOtherOption)) ?? 0; var typeCount = Model.Questions?.Select(q => q.Type).Distinct().Count() ?? 0; var qCount = Model.Questions?.Count ?? 0; }

Questionnaire Details

Back to List
@qCount
Questions
@totalAnswers
Total Answers
@otherCount
Other Options
@typeCount
Question Types

Overview

ID
#@Model.Id
Title
@Model.Title
Description
@if (!string.IsNullOrEmpty(Model.Description)) {
@Html.Raw(Model.Description)
} else {
No description provided
}

Questions

@qCount Question@(qCount != 1 ? "s" : "")
@if (Model.Questions != null && Model.Questions.Any()) {
@foreach (var question in Model.Questions.Select((q, index) => new { Q = q, Idx = index })) { var ansCount = question.Q.Answers?.Count ?? 0; var hasOther = question.Q.Answers != null && question.Q.Answers.Any(a => a.IsOtherOption);
@(question.Idx + 1)

@question.Q.Text

@question.Q.Type.ToString().Replace("_", " ") ID: @question.Q.Id @ansCount answer@(ansCount != 1 ? "s" : "") @if (hasOther) { Has Other }
@if (question.Q.Answers != null && question.Q.Answers.Any()) {
@foreach (var answer in question.Q.Answers.Select((a, ai) => new { A = a, Ai = ai })) {
@((char)('A' + answer.Ai))
@answer.A.Text
ID: @answer.A.Id
}
} else {
No answer options for this question
}
}
} else {

No Questions

This questionnaire doesn't contain any questions yet.

}