isLoggedIn()) { die('Unauthorized'); } $db = Database::getInstance(); $selection_id = isset($_GET['selection_id']) ? (int)$_GET['selection_id'] : 29; // Default to 29 echo "
| ID | Panelist ID | Question ID | Response Text | Question | Created |
|---|---|---|---|---|---|
| " . htmlspecialchars($row['id']) . " | "; echo "" . htmlspecialchars($row['panelist_id']) . " | "; echo "" . htmlspecialchars($row['question_id']) . " | "; echo "" . htmlspecialchars(substr($row['response_text'], 0, 100)) . "... | "; echo "" . htmlspecialchars(substr($row['question_text'] ?? 'N/A', 0, 50)) . "... | "; echo "" . htmlspecialchars($row['created_at']) . " | "; echo "
Total responses found: $total
"; // Count "No response provided" entries $no_response_stmt = $db->prepare("SELECT COUNT(*) as no_response FROM synthetic_responses WHERE selection_id = ? AND response_text = 'No response provided'"); $no_response_stmt->bind_param('i', $selection_id); $no_response_stmt->execute(); $no_response_count = $no_response_stmt->get_result()->fetch_assoc()['no_response']; echo "\"No response provided\" entries: $no_response_count
"; if ($no_response_count > 0) { echo "โ ๏ธ Warning: Found $no_response_count placeholder responses that need to be regenerated
"; } } else { echo "No responses found in synthetic_responses table for selection $selection_id
"; } // Check selection details echo "Selection: " . htmlspecialchars($selection['name']) . "
"; echo "Project: " . htmlspecialchars($selection['project_title']) . "
"; echo "Sample Size: " . htmlspecialchars($selection['sample_size']) . "
"; } else { echo "Selection not found!
"; } // Check connected survey echo "Survey: " . htmlspecialchars($survey['survey_title']) . " (ID: " . $survey['survey_id'] . ")
"; // Count questions $q_stmt = $db->prepare(" SELECT COUNT(*) as question_count FROM survey_questions WHERE survey_id = ? AND question_type NOT IN ('section_header', 'descriptive_text', 'page_break') "); $q_stmt->bind_param('i', $survey['survey_id']); $q_stmt->execute(); $q_count = $q_stmt->get_result()->fetch_assoc()['question_count']; echo "Answerable Questions: $q_count
"; // Show first few questions $q_stmt = $db->prepare(" SELECT id, question_text, question_type FROM survey_questions WHERE survey_id = ? AND question_type NOT IN ('section_header', 'descriptive_text', 'page_break') ORDER BY question_order ASC LIMIT 5 "); $q_stmt->bind_param('i', $survey['survey_id']); $q_stmt->execute(); $sample_questions = $q_stmt->get_result(); echo "Sample Questions:
"; echo "No survey connected!
"; } } // Check selection members echo "Total Members: $member_count
"; // Show sample members $stmt = $db->prepare(" SELECT sm.panelist_id FROM selection_members sm WHERE sm.selection_id = ? LIMIT 5 "); $stmt->bind_param('i', $selection_id); $stmt->execute(); $members = $stmt->get_result(); echo "Sample Member IDs: "; $member_ids = []; while ($member = $members->fetch_assoc()) { $member_ids[] = $member['panelist_id']; } echo implode(', ', $member_ids) . "
"; // Check if responses exist for these specific members if (!empty($member_ids)) { echo "Member $panelist_id: $resp_count responses
"; // Show actual responses for this member if ($resp_count > 0) { $sample_resp_stmt = $db->prepare(" SELECT sr.response_text, sq.question_text FROM synthetic_responses sr LEFT JOIN survey_questions sq ON sr.question_id = sq.id WHERE sr.selection_id = ? AND sr.panelist_id = ? LIMIT 3 "); $sample_resp_stmt->bind_param('is', $selection_id, $panelist_id); $sample_resp_stmt->execute(); $sample_responses = $sample_resp_stmt->get_result(); echo "Last Generation Status: " . htmlspecialchars($progress_data['status'] ?? 'Unknown') . "
"; echo "Progress: " . htmlspecialchars($progress_data['progress'] ?? 0) . "%
"; echo "Timestamp: " . date('Y-m-d H:i:s', $progress_data['timestamp'] ?? 0) . "
"; } else { echo "No recent progress file found.
"; } // Summary and recommendations echo "More than 50% of responses are placeholders (\"No response provided\"). This indicates the GPT response parsing failed.
"; echo "Action needed: Re-generate responses with the improved worker script.
"; echo "Some responses are placeholders. The generation partially worked but could be improved.
"; echo "Suggestion: Consider re-generating for better results.
"; echo "All responses appear to contain actual content. Export should work properly.
"; echo "No responses found in database. Need to generate responses first.
"; echo ""; echo "๐งช Test Single Response "; echo "๐ Re-generate All "; echo "๐ Try Export"; echo "
"; echo "Debug completed at " . date('Y-m-d H:i:s') . "
"; ?>