All question type frontend completed

This commit is contained in:
Qais Yousuf 2024-04-23 20:00:09 +02:00
parent 1a43f8b456
commit 98ec7a6561

View file

@ -6,15 +6,10 @@
<style> <style>
body { body {
height: 100% !important; height: 100% !important;
background-color:#141c27 !important; background-color: #141c27 !important;
} }
#QuestionCard{
height:auto;
padding:15px;
}
#rowSectionError { #rowSectionError {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
@ -26,10 +21,10 @@
} }
output{ output {
color:white !important; color: white !important;
font-weight:bold; font-weight: bold;
} }
#boxBanner { #boxBanner {
display: block; display: block;
@ -37,11 +32,11 @@
margin: 5px; margin: 5px;
} }
.QuestionContainer{ .QuestionContainer {
padding-top:100px; padding-top: 100px;
padding-bottom:100px; padding-bottom: 100px;
} }
.stepper { .stepper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -53,18 +48,17 @@
width: 150px; width: 150px;
height: 30px; height: 30px;
border-radius: 3px; border-radius: 3px;
background-color:transparent; background-color: transparent;
margin-bottom:10px; margin-bottom: 10px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
color: white; /* Text color */ color: white; /* Text color */
font-weight: bold; font-weight: bold;
border: 0.05px solid #294255; border: 0.05px solid #294255;
box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.18); box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.18);
-webkit-box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.18); -webkit-box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.18);
-moz-box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.18); -moz-box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.18);
} }
.step-indicator.active { .step-indicator.active {
@ -75,21 +69,19 @@
} }
h4, h5,h6, p, label { h4, h5, h6, p, label {
color:aliceblue; color: aliceblue;
} }
.card{ .card {
box-shadow: 0px 0px 36px -12px rgba(20,101,230,1); box-shadow: 0px 0px 36px -12px rgba(20,101,230,1);
-webkit-box-shadow: 0px 0px 36px -12px rgba(20,101,230,1); -webkit-box-shadow: 0px 0px 36px -12px rgba(20,101,230,1);
-moz-box-shadow: 0px 0px 36px -12px rgba(20,101,230,1); -moz-box-shadow: 0px 0px 36px -12px rgba(20,101,230,1);
border-radius:10px; border-radius: 10px;
background-color:transparent; background-color: transparent;
padding:50px; padding: 50px;
} }
@ -146,19 +138,17 @@
.rank-list li { .rank-list li {
padding: 5px; padding: 5px;
margin-bottom: 2px; margin-bottom: 2px;
color:white color: white
} }
.likert { .likert {
box-shadow: 0px 0px 7px 0px rgba(20,101,230,1); box-shadow: 0px 0px 7px 0px rgba(20,101,230,1);
-moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1); -moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1);
-webkit-box-shadow:0px 0px 7px 0px rgba(20,101,230,1); -webkit-box-shadow: 0px 0px 7px 0px rgba(20,101,230,1);
border-radius: 5px; border-radius: 5px;
background-color: transparent; background-color: transparent;
padding: 20px; padding: 20px;
} }
.likert .statement { .likert .statement {
@ -179,7 +169,7 @@
display: block; display: block;
cursor: pointer; cursor: pointer;
padding: 20px; padding: 20px;
background-color: #182c4b; background-color: #33b3ae;
border-radius: 2px; border-radius: 2px;
margin: 3px; margin: 3px;
transition: background-color 0.3s; transition: background-color 0.3s;
@ -189,28 +179,26 @@
.likert input[type="radio"]:checked + label { .likert input[type="radio"]:checked + label {
background-color: transparent; background-color: transparent;
color: white; color: white;
font-size:1rem; font-size: 1rem;
} }
.card-deck .card { .card-deck .card {
cursor: pointer; cursor: pointer;
padding:0px; padding: 10px;
border: 2px solid transparent; border: 2px solid transparent;
box-shadow: 0px 0px 36px -12px rgba(20,101,230,1); box-shadow: 0px 0px 36px -12px rgba(20,101,230,1);
-webkit-box-shadow: 0px 0px 5px 0px rgba(20,101,230,1); -webkit-box-shadow: 0px 0px 5px 0px rgba(20,101,230,1);
-moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1); -moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1);
background-color: transparent;
background-color:transparent;
transition: border 0.3s ease; /* Add transition for a smooth effect */ transition: border 0.3s ease; /* Add transition for a smooth effect */
} }
img{ /* img{
border-radius:3px; border-radius:3px;
box-shadow: 0px 0px 36px -12px rgba(20,101,230,1); box-shadow: 0px 0px 36px -12px rgba(20,101,230,1);
-webkit-box-shadow: 0px 0px 5px 0px rgba(20,101,230,1); -webkit-box-shadow: 0px 0px 5px 0px rgba(20,101,230,1);
-moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1); -moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1);
} }
*/
.card-deck .card:hover { .card-deck .card:hover {
border: 2px solid #007bff; border: 2px solid #007bff;
transition: border 0.3s ease; /* Ensure the transition applies to the hover state as well */ transition: border 0.3s ease; /* Ensure the transition applies to the hover state as well */
@ -230,6 +218,95 @@
display: none; /* Hide radio button */ display: none; /* Hide radio button */
} }
.matrix-question .table {
box-shadow: 0px 0px 7px 0px rgba(20,101,230,1);
-moz-box-shadow: 0px 0px 36px -12px rgba(20, 101, 230, 1);
-webkit-box-shadow: 0px 0px 7px 0px rgba(20,101,230,1);
border-radius: 5px;
background-color: transparent;
padding: 20px;
width: 100%;
}
.matrix-question th, .matrix-question td {
text-align: left; /* Aligns text to the left */
border: 2px solid white;
width: 100%;
}
.matrix-question th {
background-color: #33b3ae; /* Semi-transparent background for headers */
color: white; /* White text color for headers */
}
.matrix-question td {
background-color: #33b3ae; /* Semi-transparent background for headers */
color: white;
text-align: left;
}
input[type="radio"] {
border: 1px solid #007bff !important;
}
.matrix-question input[type="radio"] {
border: 1px solid #007bff !important;
}
.sortable-list {
list-style: none;
padding: 0;
}
.draggable-item:hover {
background-color: #e0e0e0;
}
button {
margin-left: 10px;
}
.draggable-item {
padding: 10px;
margin-bottom: 5px;
background-color: #f8f9fa; /* Light gray background for default state */
border: 1px solid #ccc;
cursor: grab; /* Cursor indicates that this item is draggable */
transition: background-color 0.3s ease; /* Smooth transition for background color */
border-radius: 5px;
margin: 10px;
display: flex; /* Enable flexbox */
align-items: center; /* Center items vertically */
justify-content: space-between; /* Spread out content */
}
.draggable-item.selected {
background-color: #33b3ae;
; /* Blue background for selected state */
color: white; /* White text color for better visibility */
}
.up-button, .down-button {
margin: 0 5px; /* Spacing between buttons */
}
.answer-index {
font-weight: bold;
}
.draggable-item .bi-grip-vertical {
margin-right: auto; /* Pushes all elements to the right of it to the far right */
}
.draggable-item button {
margin-left: 5px; /* Space between buttons */
}
</style> </style>
@ -280,229 +357,275 @@
} }
<div class="step @(i == 0 ? "active" : "")"> <div class="step @(i == 0 ? "active" : "")">
<p class="font-weight-normal">@(i + 1). @question.Text</p> <p class="font-weight-normal">@(i + 1). @question.Text</p>
<div id="QuestionCard">
@switch (question.Type)
{
case QuestionType.Text:
@foreach (var answer in question.Answers)
{
<input type="Text" class="form-control" id="question@(i + 1)" name="Questions[@i].SelectedText" rows="3" placeholder="Enter answer"></input>
<input class="form-control hidden-textarea" id="question@(i + 1)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" rows="3" placeholder="Enter answer"></input>
}
break;
case QuestionType.CheckBox:
case QuestionType.Multiple_choice:
case QuestionType.Demographic:
<div class="form-group">
@foreach (var answer in question.Answers)
{
<div class="form-check">
<input class="form-check-input" id="question@(i)_answer@(answer.Id)" type="checkbox" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
<label class="form-check-label" for="question@(i)_answer@(answer.Id)">
@answer.Text
</label>
</div>
}
</div>
break;
case QuestionType.TrueFalse:
<div class="form-check">
@foreach (var answer in question.Answers)
{
<div class="form-check">
<input class="form-check-input answer-input" type="radio" id="question@(i)_answer@(answer.Id)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
<label class="form-check-label" for="question@(i)_answer@(answer.Id)">
@answer.Text
</label>
</div>
}
@switch (question.Type)
{
case QuestionType.Text:
@foreach (var answer in question.Answers)
{
</div> <input type="Text" class="form-control" id="question@(i + 1)" name="Questions[@i].SelectedText" rows="3" placeholder="Enter answer"></input>
<input class="form-control hidden-textarea" id="question@(i + 1)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" rows="3" placeholder="Enter answer"></input>
}
break;
case QuestionType.CheckBox:
case QuestionType.Multiple_choice:
case QuestionType.Demographic:
break; <div class="form-group">
case QuestionType.Open_ended:
@foreach (var answer in question.Answers) @foreach (var answer in question.Answers)
{ {
<div class="form-check">
<input class="form-check-input" id="question@(i)_answer@(answer.Id)" type="checkbox" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
<label class="form-check-label" for="question@(i)_answer@(answer.Id)">
@answer.Text
</label>
</div>
<textarea type="Text" class="form-control" id="question@(i + 1)" name="Questions[@i].SelectedText" value="@answer.Text" rows="3" placeholder="Enter answer"></textarea>
<input type="hidden" class="form-control" id="question@(i + 1)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" rows="3" placeholder="Enter answer"></input>
} }
break; </div>
break;
case QuestionType.TrueFalse:
<div class="form-check">
case QuestionType.Slider: @foreach (var answer in question.Answers)
@foreach(var answer in question.Answers)
{ {
<input type="range" class="form-range " id="question@(i + 1)" name="Questions[@i].SelectedText" min="0" max="100" step="1"> <div class="form-check">
<input type="hidden" class="form-range " id="question@(i + 1)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" min="0" max="100" step="1"> <input class="form-check-input answer-input" type="radio" id="question@(i)_answer@(answer.Id)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
<label class="form-check-label" for="question@(i)_answer@(answer.Id)">
@answer.Text
</label>
</div>
<output id="question@(i + 1)_output">50</output>
<script>
document.getElementById('question@(i + 1)').addEventListener('input', function () {
document.getElementById('question@(i + 1)_output').value = this.value;
});
</script>
} }
break; </div>
case QuestionType.Rating:
<div class="rating" data-question="@i" >
@foreach (var answer in question.Answers) break;
{ case QuestionType.Open_ended:
<div class="rating-item">
<div class="rating-label">@answer.Text</div>
<input type="radio" id="question@(i)_rating@(answer.Id)"
name="Questions[@i].SelectedAnswerIds"
value="@answer.Id" class="rating-input" hidden>
<label for="question@(i)_rating@(answer.Id)" class="bi bi-star-fill rating-star"></label>
</div>
}
</div>
break; @foreach (var answer in question.Answers)
case QuestionType.Ranking: {
<div class="ranking" data-question="@i">
<ul class="rank-list"> <textarea type="Text" class="form-control" id="question@(i + 1)" name="Questions[@i].SelectedText" value="@answer.Text" rows="3" placeholder="Enter answer"></textarea>
@foreach (var answer in question.Answers) <input type="hidden" class="form-control" id="question@(i + 1)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" rows="3" placeholder="Enter answer"></input>
{ }
<li data-answer-id="@answer.Id">
@answer.Text
<button type="button" class="up-button btn btn-primary btn-sm" onclick="moveUp(this)"><i class="bi bi-arrow-up"></i> Up</button>
<button type="button" class="down-button btn btn-info btn-sm" onclick="moveDown(this)"><i class="bi bi-arrow-down"></i> Down</button>
<input type="hidden" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
</li>
}
</ul>
</div>
break; break;
case QuestionType.Likert: case QuestionType.Slider:
@if (Model.Questions.Any(q => q.Type == QuestionType.Likert)) @foreach (var answer in question.Answers)
{
<input type="range" class="form-range " id="question@(i + 1)" name="Questions[@i].SelectedText" min="0" max="100" step="1">
<input type="hidden" class="form-range " id="question@(i + 1)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" min="0" max="100" step="1">
<output id="question@(i + 1)_output">50</output>
<script>
document.getElementById('question@(i + 1)').addEventListener('input', function () {
document.getElementById('question@(i + 1)_output').value = this.value;
});
</script>
}
break;
case QuestionType.Rating:
<div class="rating" data-question="@i">
@foreach (var answer in question.Answers)
{ {
<div class="rating-item">
<div class="rating-label">@answer.Text</div>
<div class="likert"> <input type="radio" id="question@(i)_rating@(answer.Id)"
name="Questions[@i].SelectedAnswerIds"
value="@answer.Id" class="rating-input" hidden>
@foreach (var questions in Model.Questions.Where(q => q.Type == QuestionType.Likert)) <label for="question@(i)_rating@(answer.Id)" class="bi bi-star-fill rating-star"></label>
{
<div class="statement">
<label>Please indicate your level of agreement with the following statements:</label>
<div class="responses">
@foreach (var answer in questions.Answers)
{
<label class="likert-option">
<input class="form-check-input" type="radio" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
@answer.Text
</label>
}
</div>
</div>
}
</div> </div>
} }
break; </div>
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
{
<div class="matrix-question">
<table class="table table-responsive">
<thead>
<tr>
<th>Question</th>
@foreach (var option in matrixQuestion.Answers) // Assuming these are the consistent answer options across all sub-questions
{
<th>@option.Text</th>
}
</tr>
</thead>
<tbody>
<tr>
<td>@matrixQuestion.Text</td>
@foreach (var option in matrixQuestion.Answers) // Use consistent options for each sub-question
{
<td>
<input type="radio" name="Questions[@i].SelectedAnswerIds" value="@option.Id">
</td>
}
</tr>
</tbody>
</table>
</div>
}
}
break;
case QuestionType.Image:
@if (Model.Questions.Any(q => q.Type == QuestionType.Image))
{
<script>
function selectImageCard(answerId, questionId) {
// Clear previously selected
var cards = document.querySelectorAll('.image-question[data-question-id="' + questionId + '"] .card');
cards.forEach(function (card) {
card.classList.remove('selected');
});
// Set new selected
var selectedCard = document.getElementById('card_' + answerId);
selectedCard.classList.add('selected');
// Set the radio button as checked
var radioButton = document.getElementById('image_answer_' + answerId);
radioButton.checked = true;
}
</script>
@foreach (var imageQuestion in Model.Questions.Where(q => q.Type == QuestionType.Image))
{
<div class="image-question" data-question-id="@imageQuestion.Id">
<div class="card-deck">
@foreach (var answer in imageQuestion.Answers)
{
<div class="card image-card" id="card_@answer.Id" onclick="selectImageCard('@answer.Id', '@imageQuestion.Id')">
<img src="@answer.Text" alt="Image option" class="img-fluid" />
<input type="radio" id="image_answer_@answer.Id" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" hidden />
</div>
}
</div>
</div>
}
}
break;
default:
<div class="alert alert-danger" role="alert">
Unsupported question type.
</div>
break; break;
} case QuestionType.Ranking:
</div>
<div class="ranking-question">
<p class="ml-3">drag and drop to move the answers</p>
<ul class="sortable-list" id="ranking_@question.Id">
@{
int index = 1; // Initialize the index to start numbering from 1
}
@foreach (var answer in question.Answers)
{
<li class="draggable-item" draggable="true" id="@answer.Id" ondragstart="dragStart(event);" ondragover="allowDrop(event);" ondrop="drop(event);">
<span class="answer-index">@index. </span> @answer.Text
<i class="bi bi-grip-vertical mr-auto"></i>
<input type="hidden" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
<button type="button" class="up-button btn btn-primary btn-sm " onclick="moveUp(this.parentElement)">
<i class="bi bi-arrow-up"></i> Up
</button>
<button type="button" class="down-button btn btn-info btn-sm" onclick="moveDown(this.parentElement)">
<i class="bi bi-arrow-down"></i> Down
</button>
</li>
index++; // Increment the index for the next item
}
</ul>
</div>
<script>
function allowDrop(ev) {
ev.preventDefault(); // Necessary to allow a drop event
}
function dragStart(ev) {
ev.dataTransfer.setData("text", ev.target.id); // Stores the id of the draggable item
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
var draggedElement = document.getElementById(data);
var dropTarget = ev.target.closest('.draggable-item');
if (dropTarget) {
var targetRect = dropTarget.getBoundingClientRect();
var midPoint = targetRect.top + (targetRect.height / 2); // Calculate the midpoint of the drop target
var list = dropTarget.parentNode;
if (ev.clientY < midPoint) {
// Drop above the target
list.insertBefore(draggedElement, dropTarget);
} else {
// Drop below the target
if (dropTarget.nextSibling) {
list.insertBefore(draggedElement, dropTarget.nextSibling);
} else {
list.appendChild(draggedElement); // In case the target is the last child
}
}
}
}
// Click to select item
document.querySelectorAll('.draggable-item').forEach(item => {
item.addEventListener('click', function () {
// Remove previous selections
removeSelected(this.parentNode);
// Mark this as selected
this.classList.add('selected');
});
});
// Function to remove selected class from siblings
function removeSelected(parent) {
parent.querySelectorAll('.draggable-item').forEach(sibling => {
sibling.classList.remove('selected');
});
}
</script>
break;
case QuestionType.Likert:
<div class="likert">
<div class="statement">
<label>Please indicate your level of agreement with the following statements:</label>
<div class="responses">
@foreach (var answer in question.Answers)
{
<label class="likert-option">
<input class="form-check-input" type="radio" id="question@(i)_answer@(answer.Id)" name="Questions[@i].SelectedAnswerIds" value="@answer.Id">
@answer.Text
</label>
}
</div>
</div>
</div>
break;
case QuestionType.Matrix:
<div class="matrix-question">
<table class="table table-responsive">
<thead>
<tr>
<th>Question</th>
@foreach (var option in question.Answers) // Assuming these are the consistent answer options across all sub-questions
{
<th>@option.Text</th>
}
</tr>
</thead>
<tbody>
<tr>
<td>@question.Text</td>
@foreach (var option in question.Answers) // Use consistent options for each sub-question
{
<td>
<input type="radio" name="Questions[@i].SelectedAnswerIds" value="@option.Id">
</td>
}
</tr>
</tbody>
</table>
</div>
break;
case QuestionType.Image:
<script>
function selectImageCard(answerId, questionId) {
// Clear previously selected
var cards = document.querySelectorAll('.image-question[data-question-id="' + questionId + '"] .card');
cards.forEach(function (card) {
card.classList.remove('selected');
});
// Set new selected
var selectedCard = document.getElementById('card_' + answerId);
selectedCard.classList.add('selected');
// Set the radio button as checked
var radioButton = document.getElementById('image_answer_' + answerId);
radioButton.checked = true;
}
</script>
<div class="image-question" data-question-id="@question.Id">
<div class="card-deck">
@foreach (var answer in question.Answers)
{
<div class="card image-card" id="card_@answer.Id" onclick="selectImageCard('@answer.Id', '@question.Id')">
<img src="@answer.Text" alt="Image option" class="img-fluid" />
<input type="radio" id="image_answer_@answer.Id" name="Questions[@i].SelectedAnswerIds" value="@answer.Id" hidden />
</div>
}
</div>
</div>
break;
default:
<div class="alert alert-danger" role="alert">
Unsupported question type.
</div>
break;
}
<div class="mt-3"> <div class="mt-3">
@if (i > 0) @if (i > 0)
{ {
@ -531,8 +654,9 @@
@{ @{
<partial name="_ValidationScriptsPartial" /> <partial name="_ValidationScriptsPartial" />
} }
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById('questionnaireForm'); const form = document.getElementById('questionnaireForm');
@ -559,38 +683,38 @@
// Ensure we only add listeners once by checking if they've been added already // Ensure we only add listeners once by checking if they've been added already
if (!window.hasEventListenersAdded) { if (!window.hasEventListenersAdded) {
const upButtons = document.querySelectorAll('.up-button'); const upButtons = document.querySelectorAll('.up-button');
const downButtons = document.querySelectorAll('.down-button'); const downButtons = document.querySelectorAll('.down-button');
upButtons.forEach(button => { upButtons.forEach(button => {
button.addEventListener('click', function () { button.addEventListener('click', function () {
moveUp(this); moveUp(this);
});
}); });
});
downButtons.forEach(button => { downButtons.forEach(button => {
button.addEventListener('click', function () { button.addEventListener('click', function () {
moveDown(this); moveDown(this);
});
}); });
});
window.hasEventListenersAdded = true; // Set a flag to indicate listeners are added window.hasEventListenersAdded = true; // Set a flag to indicate listeners are added
} }
function moveUp(button) { function moveUp(button) {
var li = button.parentNode; var li = button.parentNode;
if (li.previousElementSibling) { if (li.previousElementSibling) {
li.parentNode.insertBefore(li, li.previousElementSibling); li.parentNode.insertBefore(li, li.previousElementSibling);
}
} }
}
function moveDown(button) { function moveDown(button) {
var li = button.parentNode; var li = button.parentNode;
if (li.nextElementSibling) { if (li.nextElementSibling) {
li.parentNode.insertBefore(li.nextElementSibling, li); li.parentNode.insertBefore(li.nextElementSibling, li);
}
} }
}
function updateOrder() { function updateOrder() {
document.querySelectorAll('.rank-list').forEach((list, index) => { document.querySelectorAll('.rank-list').forEach((list, index) => {
list.querySelectorAll('li').forEach((li, idx) => { list.querySelectorAll('li').forEach((li, idx) => {
@ -675,30 +799,30 @@
showStep(currentStep); showStep(currentStep);
}); });
document.addEventListener("DOMContentLoaded", function () { // document.addEventListener("DOMContentLoaded", function () {
const stepper = document.querySelector('.stepper'); // const stepper = document.querySelector('.stepper');
if (!stepper) { // if (!stepper) {
console.error('Stepper not found!'); // console.error('Stepper not found!');
return; // return;
} // }
let shownTypes = new Set(); // Set to track shown question types // let shownTypes = new Set(); // Set to track shown question types
const stepIndicators = stepper.querySelectorAll('.step-indicator'); // const stepIndicators = stepper.querySelectorAll('.step-indicator');
stepIndicators.forEach(indicator => { // stepIndicators.forEach(indicator => {
const type = indicator.querySelector('.step-label').textContent.trim(); // Get the text content of the step-label // const type = indicator.querySelector('.step-label').textContent.trim(); // Get the text content of the step-label
if (shownTypes.has(type)) { // if (shownTypes.has(type)) {
// If this type has already been shown, hide this indicator // // If this type has already been shown, hide this indicator
indicator.style.display = 'none'; // indicator.style.display = 'none';
} else { // } else {
// Otherwise, mark this type as shown // // Otherwise, mark this type as shown
shownTypes.add(type); // shownTypes.add(type);
} // }
}); // });
}); // });
</script> </script>
@* <script> @* <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById('questionnaireForm'); const form = document.getElementById('questionnaireForm');
@ -845,7 +969,6 @@
}); });
} }
// Add submit event listener to the form
showStep(currentStep); showStep(currentStep);
updateStepper(); updateStepper();