Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f28a9e40c | ||
|
|
7762c9f308 |
+35
-8
@@ -921,9 +921,6 @@ n .btn-secondary {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we have question responses
|
||||
const hasResponses = Object.keys(createSurveyResponses).length > 0;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/surveys', {
|
||||
method: 'POST',
|
||||
@@ -932,23 +929,32 @@ n .btn-secondary {
|
||||
name,
|
||||
client_name: clientName,
|
||||
site_name: siteName,
|
||||
description,
|
||||
responses: hasResponses ? createSurveyResponses : undefined
|
||||
description
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.error || 'Failed to create survey');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Clear form
|
||||
document.getElementById('surveyName').value = '';
|
||||
document.getElementById('clientName').value = '';
|
||||
document.getElementById('siteName').value = '';
|
||||
document.getElementById('surveyDescription').value = '';
|
||||
|
||||
await loadSurveys();
|
||||
loadSurvey(data.survey.id);
|
||||
|
||||
// Switch to surveys tab to show the new survey
|
||||
switchTab('surveys');
|
||||
alert('Survey created successfully! Click on it to take the survey.');
|
||||
|
||||
} catch (e) {
|
||||
alert('Failed to create survey');
|
||||
console.error('Error creating survey:', e);
|
||||
alert('Failed to create survey: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1561,7 +1567,28 @@ function confirmClearAll() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function clearAllSurveys() {
|
||||
try {
|
||||
const response = await fetch('/api/surveys', {
|
||||
method: 'DELETE'
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showNotification('All surveys deleted successfully', 'success');
|
||||
loadSurveys();
|
||||
currentSurveyId = null;
|
||||
currentSurvey = null;
|
||||
document.getElementById('takeSurveyTab').style.display = 'none';
|
||||
document.getElementById('analyzeTab').style.display = 'none';
|
||||
} else {
|
||||
showNotification(data.error || 'Failed to clear surveys', 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error clearing surveys:', e);
|
||||
showNotification('Failed to clear surveys', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// Notification helper
|
||||
function showNotification(message, type = 'info') {
|
||||
|
||||
Reference in New Issue
Block a user