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:
ddmt 2025-01-04 22:21:48 +08:00
parent c3494cf792
commit dbab520f56

View File

@ -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,