From 98ec7a656101ebb7e0640d160e057ea59ebdcb2c Mon Sep 17 00:00:00 2001 From: Qais Yousuf Date: Tue, 23 Apr 2024 20:00:09 +0200 Subject: [PATCH] All question type frontend completed --- .../DisplayQuestionnaire.cshtml | 755 ++++++++++-------- 1 file changed, 439 insertions(+), 316 deletions(-) diff --git a/Web/Views/QuestionnaireResponse/DisplayQuestionnaire.cshtml b/Web/Views/QuestionnaireResponse/DisplayQuestionnaire.cshtml index 008ec72..3e9791b 100644 --- a/Web/Views/QuestionnaireResponse/DisplayQuestionnaire.cshtml +++ b/Web/Views/QuestionnaireResponse/DisplayQuestionnaire.cshtml @@ -6,15 +6,10 @@ @@ -240,11 +317,11 @@ - +

@Model.Title

@Html.Raw(Model.Description)

- +
@@ -280,229 +357,275 @@ }
-

@(i + 1). @question.Text

+

@(i + 1). @question.Text

-
- @switch (question.Type) - { - case QuestionType.Text: - @foreach (var answer in question.Answers) - { - - - } - break; - case QuestionType.CheckBox: - case QuestionType.Multiple_choice: - case QuestionType.Demographic: + @switch (question.Type) + { + case QuestionType.Text: + @foreach (var answer in question.Answers) + { -
- - @foreach (var answer in question.Answers) - { -
- - -
- - } - -
- break; - case QuestionType.TrueFalse: -
- - @foreach (var answer in question.Answers) - { -
- - - -
- - - } - - -
- - break; - case QuestionType.Open_ended: - - @foreach (var answer in question.Answers) - { - - - - } - - break; - - case QuestionType.Slider: - - @foreach(var answer in question.Answers) - { - - - - 50 - - } - - break; - case QuestionType.Rating: -
- - @foreach (var answer in question.Answers) - { -
-
@answer.Text
- - -
- } -
- - break; - case QuestionType.Ranking: -
- -
    - @foreach (var answer in question.Answers) - { -
  • - @answer.Text - - - -
  • - } -
-
- + + + } break; - - case QuestionType.Likert: + case QuestionType.CheckBox: + case QuestionType.Multiple_choice: + case QuestionType.Demographic: - @if (Model.Questions.Any(q => q.Type == QuestionType.Likert)) +
+ + @foreach (var answer in question.Answers) { - +
+ + +
-
- + } - @foreach (var questions in Model.Questions.Where(q => q.Type == QuestionType.Likert)) - { -
- -
- @foreach (var answer in questions.Answers) - { - - } -
-
- - } +
+ break; + case QuestionType.TrueFalse: +
+ + @foreach (var answer in question.Answers) + { +
+ + + +
+ + } + +
+ + break; + case QuestionType.Open_ended: + + @foreach (var answer in question.Answers) + { + + + + } + + break; + + case QuestionType.Slider: + + @foreach (var answer in question.Answers) + { + + + + 50 + + } + + break; + case QuestionType.Rating: +
+ + @foreach (var answer in question.Answers) + { +
+
@answer.Text
+ +
} - break; - case QuestionType.Matrix: +
- @if (Model.Questions.Any(q => q.Type == QuestionType.Matrix)) // Check for Matrix type questions - { - @foreach (var matrixQuestion in Model.Questions.Where(q => q.Type == QuestionType.Matrix)) // Iterate through Matrix questions - { -
- - - - - - @foreach (var option in matrixQuestion.Answers) // Assuming these are the consistent answer options across all sub-questions - { - - } - - - - - - @foreach (var option in matrixQuestion.Answers) // Use consistent options for each sub-question - { - - } - - -
Question@option.Text
@matrixQuestion.Text - -
- -
- } - } - - break; - case QuestionType.Image: - @if (Model.Questions.Any(q => q.Type == QuestionType.Image)) - { - - - @foreach (var imageQuestion in Model.Questions.Where(q => q.Type == QuestionType.Image)) - { -
-
- @foreach (var answer in imageQuestion.Answers) - { -
- Image option - -
- } -
-
- } - } - break; - default: - break; - } -
+ case QuestionType.Ranking: + +
+

drag and drop to move the answers

+
    + @{ + int index = 1; // Initialize the index to start numbering from 1 + } + @foreach (var answer in question.Answers) + { +
  • + @index. @answer.Text + + + + + +
  • + index++; // Increment the index for the next item + } +
+
+ + + + + + + break; + + case QuestionType.Likert: + +
+ +
+ +
+ @foreach (var answer in question.Answers) + { + + } +
+
+ + +
+ + break; + case QuestionType.Matrix: + +
+ + + + + @foreach (var option in question.Answers) // Assuming these are the consistent answer options across all sub-questions + { + + } + + + + + + @foreach (var option in question.Answers) // Use consistent options for each sub-question + { + + } + + +
Question@option.Text
@question.Text + +
+
+ + break; + case QuestionType.Image: + + + +
+
+ @foreach (var answer in question.Answers) + { +
+ Image option + +
+ } +
+
+ + + break; + default: + + break; + } +
@if (i > 0) { @@ -519,7 +642,7 @@
- +
@@ -531,8 +654,9 @@ @{ - + } + - @*