Refactor question type detection in editQuestion.html
- Improved the logic for determining question types by using a more explicit conditional structure. - Enhanced readability and maintainability of the code by clearly defining the conditions for 'text', 'radio', and 'checkbox' question types.
This commit is contained in:
parent
c3494cf792
commit
dbab520f56
@ -442,9 +442,15 @@
|
||||
|
||||
const questionItems = document.querySelectorAll('.question-item');
|
||||
questionItems.forEach((item, index) => {
|
||||
const questionType = item.querySelector('input[type="radio"]') ? 'radio' :
|
||||
item.querySelector('input[type="checkbox"]') ? 'checkbox' : 'text';
|
||||
|
||||
let questionType;
|
||||
if (item.querySelector('.question-content textarea')) {
|
||||
questionType = 'text';
|
||||
} else if (item.querySelector('input[type="radio"]')) {
|
||||
questionType = 'radio';
|
||||
} else {
|
||||
questionType = 'checkbox';
|
||||
}
|
||||
|
||||
const question = {
|
||||
id: index + 1,
|
||||
type: questionType,
|
||||
|
Loading…
x
Reference in New Issue
Block a user