Spaces:
Running
Running
ark945 commited on
Commit ·
45deada
1
Parent(s): 51ba7a2
feat: add review progress enable toggle and 3-click clear data feature
Browse filesFiles changed (3)
171 unmodified lines17217317417517617763 unmodified lines24124224324424524636 unmodified lines28328428528628728836 unmodified lines32532632732832933033163 unmodified lines395396397398399400171 unmodified lines<!-- 1. 複習表設定 --><div class="form-section"><h3>📅 複習進度表設定</h3><div class="form-row"><div class="form-group"><label for="startDate">複習開始日期</label>63 unmodified lines<button onclick="updatePassword()" class="btn btn-secondary" style="align-self: flex-start; margin-top: 5px;">🔑 變更密碼</button></div><div style="display: flex; justify-content: flex-end; margin-top: 30px; border-top: 2px solid var(--border-color); padding-top: 20px;"><button onclick="saveAllSettings()" class="btn btn-primary" style="padding: 12px 30px; font-size: 1rem;">💾 儲存所有設定</button></div>36 unmodified linesdocument.getElementById('startDate').value = rSettings.start_date || '2026-07-01';document.getElementById('endDate').value = rSettings.end_date || '2026-08-31';document.getElementById('requiredDays').value = rSettings.required_days || 2;// 填入單元選單const selectedUnits = rSettings.selected_units || [];36 unmodified linesstart_date: document.getElementById('startDate').value,end_date: document.getElementById('endDate').value,required_days: parseInt(document.getElementById('requiredDays').value) || 2,selected_units: checkedUnits};const receiversRaw = document.getElementById('receivers').value;63 unmodified lines}}// 頁面初始化loadSettings();</script>171 unmodified lines17217317417517617717817918018118218318463 unmodified lines24824925025125225325425525625725825926026126226326436 unmodified lines30130230330430530630736 unmodified lines34434534634734834935035163 unmodified lines415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485171 unmodified lines<!-- 1. 複習表設定 --><div class="form-section"><h3>📅 複習進度表設定</h3><div class="switch-container"><label class="switch"><input type="checkbox" id="reviewEnable"><span class="slider"></span></label><span style="font-weight: 600; font-size: 1rem;">啟用複習進度表功能 (關閉時不顯示首頁頁簽)</span></div><div class="form-row"><div class="form-group"><label for="startDate">複習開始日期</label>63 unmodified lines<button onclick="updatePassword()" class="btn btn-secondary" style="align-self: flex-start; margin-top: 5px;">🔑 變更密碼</button></div><!-- 4. 危險區域 --><div class="form-section" style="border-bottom: none; margin-top: 20px;"><h3 style="color: var(--error);">⚠️ 危險區域</h3><p style="color: var(--text-muted); font-size: 0.85rem; margin-top: -5px; margin-bottom: 15px;">注意:此操作將永久清除資料庫中的所有學生複習進度紀錄 (quiz_results 表格中的資料),此動作無法復原。</p><button id="clearQuizBtn" onclick="confirmClearQuiz()" class="btn btn-secondary" style="border-color: var(--error); color: var(--error); font-weight: 600; background-color: transparent; transition: all 0.3s ease;">🗑️ 清除所有複習進度紀錄</button></div><div style="display: flex; justify-content: flex-end; margin-top: 30px; border-top: 2px solid var(--border-color); padding-top: 20px;"><button onclick="saveAllSettings()" class="btn btn-primary" style="padding: 12px 30px; font-size: 1rem;">💾 儲存所有設定</button></div>36 unmodified linesdocument.getElementById('startDate').value = rSettings.start_date || '2026-07-01';document.getElementById('endDate').value = rSettings.end_date || '2026-08-31';document.getElementById('requiredDays').value = rSettings.required_days || 2;document.getElementById('reviewEnable').checked = rSettings.enable_review !== false;// 填入單元選單const selectedUnits = rSettings.selected_units || [];36 unmodified linesstart_date: document.getElementById('startDate').value,end_date: document.getElementById('endDate').value,required_days: parseInt(document.getElementById('requiredDays').value) || 2,selected_units: checkedUnits,enable_review: document.getElementById('reviewEnable').checked};const receiversRaw = document.getElementById('receivers').value;63 unmodified lines}}let clearConfirmCount = 0;let clearTimer = null;function confirmClearQuiz() {const btn = document.getElementById('clearQuizBtn');clearConfirmCount++;if (clearTimer) clearTimeout(clearTimer);clearTimer = setTimeout(() => {clearConfirmCount = 0;btn.className = 'btn btn-secondary';btn.style.borderColor = 'var(--error)';btn.style.color = 'var(--error)';btn.style.backgroundColor = 'transparent';btn.innerText = '🗑️ 清除所有複習進度紀錄';}, 5000);if (clearConfirmCount === 1) {btn.innerText = '⚠️ 請再次點擊確認清除 (第 2/3 次確認)';btn.style.backgroundColor = '#f97316';btn.style.color = 'white';btn.style.borderColor = '#f97316';} else if (clearConfirmCount === 2) {btn.innerText = '🔥 最後一次確認!點擊即永久刪除!(第 3/3 次確認)';btn.style.backgroundColor = '#ef4444';btn.style.color = 'white';btn.style.borderColor = '#ef4444';} else if (clearConfirmCount === 3) {clearConfirmCount = 0;if (clearTimer) clearTimeout(clearTimer);clearTimer = null;btn.disabled = true;btn.innerText = '⏳ 正在清除...';fetch('/api/admin/clear_quiz_results', {method: 'POST'}).then(res => res.json()).then(data => {btn.disabled = false;btn.className = 'btn btn-secondary';btn.style.borderColor = 'var(--error)';btn.style.color = 'var(--error)';btn.style.backgroundColor = 'transparent';btn.innerText = '🗑️ 清除所有複習進度紀錄';if (data.success) {showToast(data.message || '已成功清除所有複習進度紀錄!');} else {showToast(data.message || '清除失敗', 'error');}}).catch(err => {btn.disabled = false;btn.className = 'btn btn-secondary';btn.style.borderColor = 'var(--error)';btn.style.color = 'var(--error)';btn.style.backgroundColor = 'transparent';btn.innerText = '🗑️ 清除所有複習進度紀錄';console.error(err);showToast('伺服器連線失敗', 'error');});}}// 頁面初始化loadSettings();</script>
29 unmodified lines3031323334353637383936 unmodified lines76777879808144 unmodified lines12612712812913013129 unmodified lines</header><!-- 頁籤導覽列 --><div class="tabs-container"><button class="tab-btn active" onclick="switchTab('units-tab')">📖 學習單元</button><button class="tab-btn" onclick="switchTab('progress-tab')">📅 複習進度表</button></div><!-- 學習單元分頁 --><div id="units-tab" class="tab-content active-content">36 unmodified lines</div><!-- 暑期複習進度分頁 --><div id="progress-tab" class="tab-content"><section class="card" style="padding: 24px;"><div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 20px; flex-wrap: wrap; gap: 15px;">44 unmodified lines</div></section></div></div><script>29 unmodified lines3031323334353637383940414236 unmodified lines7980818283848544 unmodified lines13013113213313413513629 unmodified lines</header><!-- 頁籤導覽列 -->{% if enable_review %}<div class="tabs-container"><button class="tab-btn active" onclick="switchTab('units-tab')">📖 學習單元</button><button class="tab-btn" onclick="switchTab('progress-tab')">📅 複習進度表</button></div>{% endif %}<!-- 學習單元分頁 --><div id="units-tab" class="tab-content active-content">36 unmodified lines</div><!-- 暑期複習進度分頁 -->{% if enable_review %}<div id="progress-tab" class="tab-content"><section class="card" style="padding: 24px;"><div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 20px; flex-wrap: wrap; gap: 15px;">44 unmodified lines</div></section></div>{% endif %}</div><script>
206 unmodified lines207208209210211212108 unmodified lines32132232332432532618 unmodified lines345346347348349350351206 unmodified linesprint(f"Supabase Set Config Error: {e}")return Falsedb = DatabaseManager()# ==========================================108 unmodified lines})return jsonify({"success": True})# ==========================================# 2. Config & Helpers# ==========================================18 unmodified lines@app.route('/')def index():units = db.get_units()return render_template('index.html', units=units)@app.route('/list/<unit>')def word_list(unit):206 unmodified lines207208209210211212213214215216217218219220108 unmodified lines32933033133233333433533633733833934034118 unmodified lines360361362363364365366367368206 unmodified linesprint(f"Supabase Set Config Error: {e}")return Falsedef clear_quiz_results(self):try:supabase.table("quiz_results").delete().neq("id", -1).execute()return Trueexcept Exception as e:print(f"Supabase Clear Quiz Results Error: {e}")return Falsedb = DatabaseManager()# ==========================================108 unmodified lines})return jsonify({"success": True})@app.route('/api/admin/clear_quiz_results', methods=['POST'])@login_requireddef api_clear_quiz_results():if db.clear_quiz_results():return jsonify({"success": True, "message": "已成功清除所有複習進度紀錄"})return jsonify({"success": False, "message": "清除失敗"})# ==========================================# 2. Config & Helpers# ==========================================18 unmodified lines@app.route('/')def index():units = db.get_units()r_settings = db.get_config("review_settings") or {}enable_review = r_settings.get("enable_review", True)return render_template('index.html', units=units, enable_review=enable_review)@app.route('/list/<unit>')def word_list(unit):
templates/admin.html+86-1
templates/index.html+5
wordApp_web.py+18-1