isLoggedIn()) { redirectTo('login.php'); } $surveyId = isset($_GET['id']) ? (int)$_GET['id'] : null; if (!$surveyId) { redirectTo('surveys.php'); } // Get survey details $surveyManager = SurveyManager::getInstance(); $survey = $surveyManager->getSurveyDetails($surveyId, $_SESSION['user_id']); if (!$survey) { redirectTo('surveys.php'); } // Get survey questions $questions = $surveyManager->getSurveyQuestions($surveyId); ?> Survey Preview | <?php echo APP_NAME; ?>

*
Preview Mode

This is a preview. Responses will not be saved.

"; break; case 'long_text': $html = ""; break; case 'single_choice': $html = "
"; foreach ($options as $option) { $html .= ""; } if (!empty($config['allowOther'])) { $html .= ""; } $html .= "
"; break; case 'multiple_choice': $html = "
"; foreach ($options as $option) { $html .= ""; } if (!empty($config['allowOther'])) { $html .= ""; } $html .= "
"; break; case 'dropdown': $html = ""; break; case 'rating_scale': $start = $config['start'] ?? 1; $end = $config['end'] ?? 5; $startLabel = $config['startLabel'] ?? ''; $endLabel = $config['endLabel'] ?? ''; $html = "
"; if ($startLabel) { $html .= "
" . htmlspecialchars($startLabel) . "
"; } $html .= "
"; for ($i = $start; $i <= $end; $i++) { $html .= "
"; } $html .= "
"; if ($endLabel) { $html .= "
" . htmlspecialchars($endLabel) . "
"; } $html .= "
"; break; case 'linear_scale': $labels = $config['scale_labels'] ?? ['Strongly Disagree', 'Disagree', 'Neutral', 'Agree', 'Strongly Agree']; $html = "
"; foreach ($labels as $index => $label) { $html .= "
"; } $html .= "
"; break; case 'matrix_single': case 'matrix_multiple': $rows = $config['rows'] ?? []; $columns = $config['columns'] ?? []; $type = $question['question_type'] === 'matrix_single' ? 'radio' : 'checkbox'; $html = ""; foreach ($columns as $column) { $html .= ""; } $html .= ""; foreach ($rows as $rowIndex => $row) { $html .= ""; foreach ($columns as $colIndex => $column) { $name = $type === 'radio' ? "q_{$questionId}_{$rowIndex}" : "q_{$questionId}_{$rowIndex}[]"; $html .= ""; } $html .= ""; } $html .= "
" . htmlspecialchars($column) . "
" . htmlspecialchars($row) . "
"; break; case 'number': $min = isset($config['min']) ? "min='{$config['min']}'" : ''; $max = isset($config['max']) ? "max='{$config['max']}'" : ''; $step = isset($config['step']) ? "step='{$config['step']}'" : 'step="any"'; $html = ""; break; case 'date': $html = ""; break; case 'email': $html = ""; break; case 'phone': $html = ""; break; case 'section_header': $html = "

" . htmlspecialchars($question['question_text']) . "

"; if ($question['help_text']) { $html .= "

" . htmlspecialchars($question['help_text']) . "

"; } $html .= "
"; break; case 'descriptive_text': $html = "
" . nl2br(htmlspecialchars($question['question_text'])) . "
"; break; case 'page_break': $html = "
"; break; default: $html = ""; } return $html; } ?>