From 8ab14e951a87138725ca8cf17fc83d555a683ce9 Mon Sep 17 00:00:00 2001 From: peregr1nus Date: Fri, 12 Dec 2025 16:14:35 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A3=BC=EA=B4=80=EC=8B=9D=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=ED=8F=BC=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ templates/step3.html | 8 ++++++++ templates/step4.html | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/app.py b/app.py index bda15bf..6479663 100644 --- a/app.py +++ b/app.py @@ -107,6 +107,15 @@ def step3(): """3단계: 이단 일반 교리 점검""" if request.method == 'POST': data = request.get_json() + + # 7번 문항 검증 (기타의견란에 작성 필요) + other_opinions = data.get('other_opinions', '').strip() + if not other_opinions or '7번:' not in other_opinions: + return jsonify({ + 'success': False, + 'message': '7번 문항은 기타의견란에 "7번: "으로 시작하여 답변해주세요.' + }), 400 + session['general_cult_doctrine'] = data # 기본 정보에서 이단교단 확인 @@ -128,6 +137,41 @@ def step4(): """4단계: 출신 이단별 교리 점검""" if request.method == 'POST': data = request.get_json() + + # 세션에서 출신 이단 정보 가져오기 + basic_info = session.get('basic_info', {}) + cult_name = basic_info.get('cult', '') + + # 이단별 상세점검 문항 가져오기 + questions = app.config.get('CULT_DETAIL_QUESTIONS', {}).get(cult_name, []) + + # 기타의견란에 작성해야 하는 문항 번호 찾기 + required_question_numbers = [] + for i, question in enumerate(questions, 1): + if '기타의견란' in question or '기타의견' in question: + required_question_numbers.append(i) + + # 기타의견란 검증 + if required_question_numbers: + other_opinions = data.get('other_opinions', '').strip() + if not other_opinions: + return jsonify({ + 'success': False, + 'message': f'{", ".join([str(n) + "번" for n in required_question_numbers])} 문항은 기타의견란에 작성해주세요.' + }), 400 + + # 각 필수 문항 번호가 기타의견란에 포함되어 있는지 확인 + missing_questions = [] + for q_num in required_question_numbers: + if f'{q_num}번:' not in other_opinions: + missing_questions.append(q_num) + + if missing_questions: + return jsonify({ + 'success': False, + 'message': f'{", ".join([str(n) + "번" for n in missing_questions])} 문항은 기타의견란에 "{", ".join([str(n) + "번:" for n in missing_questions])}"으로 시작하여 답변해주세요.' + }), 400 + session['specific_cult_doctrine'] = data return jsonify({'success': True, 'next_step': '/step5'}) diff --git a/templates/step3.html b/templates/step3.html index 345fde6..6c6a09e 100644 --- a/templates/step3.html +++ b/templates/step3.html @@ -223,6 +223,14 @@ document.getElementById('step3Form').addEventListener('submit', async function(e const formData = new FormData(this); const data = Object.fromEntries(formData); + // 7번 문항 검증 (기타의견란에 작성 필요) + const otherOpinions = data.other_opinions || ''; + if (!otherOpinions.trim() || !otherOpinions.includes('7번:')) { + alert('7번 문항은 기타의견란에 "7번: "으로 시작하여 답변해주세요.'); + document.getElementById('other_opinions').focus(); + return; + } + try { const response = await fetch('/step3', { method: 'POST', diff --git a/templates/step4.html b/templates/step4.html index e70eb4f..9db2af5 100644 --- a/templates/step4.html +++ b/templates/step4.html @@ -59,6 +59,47 @@ document.getElementById('step4Form').addEventListener('submit', async function(e const formData = new FormData(this); const data = Object.fromEntries(formData); + // 기타의견란에 작성해야 하는 문항 번호 찾기 + const requiredQuestions = []; + const questionLabels = document.querySelectorAll('.doctrine-section .form-group label'); + questionLabels.forEach((label, index) => { + const questionText = label.textContent.trim(); + if (questionText.includes('기타의견란') || questionText.includes('기타의견')) { + // 문항 번호 추출 (예: "3. 예수님이..." -> 3) + const match = questionText.match(/^(\d+)\./); + if (match) { + requiredQuestions.push(parseInt(match[1])); + } + } + }); + + // 기타의견란 검증 + if (requiredQuestions.length > 0) { + const otherOpinions = data.other_opinions || ''; + if (!otherOpinions.trim()) { + const questionNums = requiredQuestions.map(n => n + '번').join(', '); + alert(`${questionNums} 문항은 기타의견란에 작성해주세요.`); + document.getElementById('other_opinions').focus(); + return; + } + + // 각 필수 문항 번호가 기타의견란에 포함되어 있는지 확인 + const missingQuestions = []; + for (const qNum of requiredQuestions) { + if (!otherOpinions.includes(qNum + '번:')) { + missingQuestions.push(qNum); + } + } + + if (missingQuestions.length > 0) { + const questionNums = missingQuestions.map(n => n + '번').join(', '); + const questionFormats = missingQuestions.map(n => n + '번:').join(', '); + alert(`${questionNums} 문항은 기타의견란에 "${questionFormats}"으로 시작하여 답변해주세요.`); + document.getElementById('other_opinions').focus(); + return; + } + } + try { const response = await fetch('/step4', { method: 'POST',