diff --git a/Web/Areas/Admin/Controllers/QuestionnaireController.cs b/Web/Areas/Admin/Controllers/QuestionnaireController.cs index aafc7a7..a6c08f8 100644 --- a/Web/Areas/Admin/Controllers/QuestionnaireController.cs +++ b/Web/Areas/Admin/Controllers/QuestionnaireController.cs @@ -250,18 +250,18 @@ namespace Web.Areas.Admin.Controllers } - else - { + //else + //{ - var newQuestion = new Question - { - Text = questionViewModel.Text, - Type = questionViewModel.Type, - Answers = questionViewModel.Answers?.Select(a => new Answer { Text = a.Text }).ToList() ?? new List() - }; + // var newQuestion = new Question + // { + // Text = questionViewModel.Text, + // Type = questionViewModel.Type, + // Answers = questionViewModel.Answers?.Select(a => new Answer { Text = a.Text }).ToList() ?? new List() + // }; - existingQuestionnaire.Questions.Add(newQuestion); - } + // existingQuestionnaire.Questions.Add(newQuestion); + //} //if (existingQuestion != null) //{ diff --git a/Web/Areas/Admin/Views/Questionnaire/Create.cshtml b/Web/Areas/Admin/Views/Questionnaire/Create.cshtml index ec80f65..5a2678b 100644 --- a/Web/Areas/Admin/Views/Questionnaire/Create.cshtml +++ b/Web/Areas/Admin/Views/Questionnaire/Create.cshtml @@ -10,9 +10,7 @@
Create questionnaire
-
- - +
@@ -27,21 +25,15 @@
-
-

Create Questions

-
- - @for (int i = 0; i < Model.Questions?.Count; i++) {
- -
@@ -52,31 +44,24 @@ {
- +
} - - +
- - - + | + +
- }
- - - -
-
@@ -86,8 +71,6 @@
- - @section Scripts { @@ -100,97 +83,107 @@ } - + + // Remove answer dynamically + $("#questions-container").on("click", ".remove-answer", function () { + $(this).closest('.answer-group').remove(); + }); + + // Remove question dynamically + $(document).on("click", ".remove-question", function () { + $(this).closest('.question-group').remove(); + }); + + // Save question + $("#questions-container").on("click", ".save-question", function () { + var questionGroup = $(this).closest('.question-group'); + questionGroup.find('.edit-question').show(); + questionGroup.find('.remove-question').hide(); + questionGroup.find('.save-question').hide(); + questionGroup.find('.question-type').prop('disabled', true).hide(); // Hide question type + questionGroup.find('textarea').prop('disabled', true); + questionGroup.find('.answers-container').slideUp(); + questionGroup.addClass('collapsed'); + }); + + // Edit question + $("#questions-container").on("click", ".edit-question", function () { + var questionGroup = $(this).closest('.question-group'); + questionGroup.find('.save-question').show(); + questionGroup.find('.remove-question').show(); + questionGroup.find('.edit-question').hide(); + questionGroup.find('.question-type').prop('disabled', false).show(); // Show question type + questionGroup.find('textarea').prop('disabled', false); + questionGroup.find('.answers-container').slideDown(); + questionGroup.removeClass('collapsed'); + }); + }); + - - - - - - - } \ No newline at end of file diff --git a/Web/Areas/Admin/Views/Questionnaire/Edit.cshtml b/Web/Areas/Admin/Views/Questionnaire/Edit.cshtml index 0911f84..fc697c2 100644 --- a/Web/Areas/Admin/Views/Questionnaire/Edit.cshtml +++ b/Web/Areas/Admin/Views/Questionnaire/Edit.cshtml @@ -42,7 +42,7 @@ -
+
@@ -56,8 +56,8 @@
-
-

Next Question

+
+

NEXT QUESTION

@@ -89,14 +89,14 @@ - +
}
- +
- + } @@ -217,7 +217,7 @@
- +
`; // Append the new answer to the specific question diff --git a/Web/wwwroot/css/site.css b/Web/wwwroot/css/site.css index eacf892..3498c3a 100644 --- a/Web/wwwroot/css/site.css +++ b/Web/wwwroot/css/site.css @@ -35,11 +35,48 @@ --font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } +.question { + margin:1rem 2rem 0rem 2rem; +} +.question-details{ + padding:0 4rem 0 4rem; +} +.answers { + margin: 3rem !important; +} +#customCard { + background-color: #f2f2f2 !important; + margin: 3rem; + padding: 3rem 0 2rem 0; +} +.question-title { + color: #007bff; + font-weight: bold; +} .question-group { margin-bottom: 20px; /* Adjust the value to control the spacing */ } + +.question-separator { + display: flex; + align-items: center; +} + +.line-container { + flex-grow: 1; +} + +.next-question-container { + margin: 0 10px; /* Adjust margin as needed */ + text-align: center; +} + +.next-question { + margin: 0; +} + *, *::before, *::after {