first commit 2
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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
|
||||
]);
|
||||
?>
|
||||
Reference in New Issue
Block a user