44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
include_once('./_common.php');
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$st_id = isset($_GET['st_id']) ? (int)$_GET['st_id'] : 0;
|
|
|
|
if (!$st_id) {
|
|
echo json_encode(['success' => false, 'message' => '템플릿 ID가 없습니다.']);
|
|
exit;
|
|
}
|
|
|
|
// 템플릿 정보 가져오기
|
|
$template = sql_fetch("SELECT * FROM survey_templates WHERE st_id = '$st_id'");
|
|
if (!$template) {
|
|
echo json_encode(['success' => false, 'message' => '존재하지 않는 템플릿입니다.']);
|
|
exit;
|
|
}
|
|
|
|
// 템플릿 질문들 가져오기
|
|
$questions = [];
|
|
$question_sql = "SELECT * FROM survey_template_questions WHERE st_id = '$st_id' ORDER BY stq_order ASC";
|
|
$question_result = sql_query($question_sql);
|
|
|
|
while ($question = sql_fetch_array($question_result)) {
|
|
$question_data = [
|
|
'stq_id' => $question['stq_id'],
|
|
'stq_order' => $question['stq_order'],
|
|
'stq_type' => $question['stq_type'],
|
|
'stq_title' => $question['stq_title'],
|
|
'stq_description' => $question['stq_description'],
|
|
'stq_required' => $question['stq_required'],
|
|
'stq_options' => $question['stq_options'] ? json_decode($question['stq_options'], true) : []
|
|
];
|
|
|
|
$questions[] = $question_data;
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'template' => $template,
|
|
'questions' => $questions
|
|
]);
|
|
?>
|