import time import gradio as gr import datetime import pandas as pd # 1. Khởi tạo dữ liệu Journal mẫu journal_data = pd.DataFrame(columns=[ "Date", "Category", "Task", "Background", "Current condition", "Goal/Target condition", "Root Cause Analysis", "Confirmation", "Follow-up" ]) # Dữ liệu Projects với nội dung trọng tâm đầy đủ projects = [ { "id": "tdpb_1", "category": "Tư duy", "title": "🧠 Tư duy phản biện - Tổng quan", "desc": """### 📌 Nội dung trọng tâm: - **1.1 Khái niệm:** Định nghĩa Tư duy phản biện (Critical Thinking). - **1.2 Phân loại:** Tư duy logic, sáng tạo, hệ thống. - **1.3 Các loại bệnh tư duy:** Ngụy biện, thiên kiến xác nhận, tư duy lối mòn.""", "resources": [ {"name": "📁 Drive: Tài liệu Chương 1", "url": "https://drive.google.com/drive/folders/1S2HZphDorycggd59gZtwoD1g18vAkO6g"}, {"name": "📝 Bài tập rèn luyện", "url": "#"} ] }, { "id": "tdpb_2", "category": "Tư duy", "title": "🔍 Hình thức & Quy luật Logic", "desc": """### 📌 Nội dung trọng tâm: - **2.1 Các quy luật:** Luật đồng nhất, Phi mâu thuẫn, Loại trừ cái thứ ba, Lý do đầy đủ. - **2.2 Hình thức:** Khái niệm, Phán đoán và Suy luận chuẩn xác.""", "resources": [ {"name": "📁 Drive: Tài liệu Chương 2 & 3", "url": "https://drive.google.com/drive/folders/1mM_f1C95WmU05kCyIWCg7eH2Twxp76kk"}, {"name": "📊 Sơ đồ logic hệ thống", "url": "#"} ] }, { "id": "tdpb_3", "category": "Tư duy", "title": "🔍 Chương 4: Chứng minh & Bác bỏ", "desc": """### 📌 Nội dung trọng tâm: - **4.1 Chứng minh:** Cấu trúc luận điểm, luận cứ và phương pháp. - **4.2 Bác bỏ:** Cách phát hiện lỗi sai và bẻ gãy ngụy biện.""", "resources": [ {"name": "📁 Drive: Tài liệu Chương 4", "url": "https://drive.google.com/drive/u/0/folders/1YpS-hM5yMtZL-SdC4BLxPIgC_eE6TF8J"}, {"name": "📊 Sơ đồ logic", "url": "#"} ] }, { "id": "tdpb_4", "category": "Thu nhập", "title": "💰 Thu nhập & Giá trị", "desc": """### 📌 Nội dung trọng tâm: - **Tư duy tài chính:** Mối liên hệ giữa năng lực phản biện và thu nhập. - **Phân tích:** Cách tối ưu hóa nguồn lực cá nhân.""", "resources": [ {"name": "📁 Drive: Tài liệu Chương 4", "url": "https://drive.google.com/drive/u/0/folders/1ETUOnwCJWg_s-lmje1rNx9O0WcE-wzBu"}, {"name": "📊 Sơ đồ thu nhập", "url": "#"} ] }, { "id": "tdpb_6", "category": "Đặt câu hỏi", "title": "❓ Kỹ năng Đặt câu hỏi", "desc": """### 📌 Nội dung trọng tâm: - **Kỹ thuật hỏi:** Sử dụng 5W1H (Who, What, Where, When, Why, How). - **Mục tiêu:** Đặt câu hỏi đúng để mở khóa vấn đề cốt lõi.""", "resources": [ {"name": "📁 Drive: Tài liệu Chương 5", "url": "https://drive.google.com/drive/u/0/folders/1x_c1ajxMSANm1muLk76dGW9VypUZknbO"}, {"name": "📊 Sơ đồ đặt câu hỏi", "url": "#"} ] }, { "id": "tdpb_7", "category": "FTO", "title": "🔭 FTO - Quan sát thực địa", "desc": """### 📌 Nội dung trọng tâm: - **Kỹ năng FTO:** Quan sát thực tế, thu thập dữ liệu khách quan tại hiện trường. - **Báo cáo:** Chuyển đổi dữ liệu thô thành nhận định có giá trị.""", "resources": [ {"name": "📁 Drive: Tài liệu Chương 6", "url": "https://drive.google.com/drive/u/0/folders/1QKyU_19f-MZz7pJ2hscTA5B4kG-aVVGj"}, {"name": "📊 Sơ đồ quan sát", "url": "#"} ] }, { "id": "kt_tt200", "category": "Kế toán TT200", "title": "💵 Kế toán Tiền (TK 111, 112, 113)", "desc": """### 📌 Nội dung trọng tâm: - **Nguyên tắc:** Quản lý dòng tiền, kiểm kê quỹ tiền mặt hàng ngày. - **Nghiệp vụ:** Đối chiếu sổ phụ ngân hàng, xử lý chênh lệch tỷ giá (TK 413). - **Chứng từ:** Phiếu thu, Phiếu chi, Ủy nhiệm chi.""", "resources": [ {"name": "PR Check-list", "url": "https://drive.google.com/drive/u/0/folders/1DR9yD-9PUIOxwEcLiaBC7BG8DZ9M5nYg0J0WK_xm2uE"}, {"name": "Technical Accounting", "url": "https://docs.google.com/spreadsheets/d/1VXd0qSUsMT7vPrqG-3QskzOqnn3rOYsD3TnDWD1o0S0/edit?gid=1784442735#gid=1784442735"} ] }, { "id": "ifrs_all", "category": "IFRS Chuyên sâu", "title": "📑 IFRS - IAS", "desc": """### 📌 Nội dung trọng tâm: - **IFRS Hierarchy:** Hệ thống chuẩn mực kế toán quốc tế. - **Fair Value:** Tư duy về Giá trị hợp lý thay vì Giá gốc.""", "resources": [ {"name": "📄 IFRS Framework", "url": "https://nngouyenngoc913.github.io/ifrs-hierachy/"}, ] }, { "id": "template_pr", "category": "Template for PR", "title": "📋 Templates & Resources", "desc": """### 📌 Công cụ hỗ trợ: - **Templates:** Inventory, Fixed Asset, AP-AR Aging. - **Analysis:** Power Query, BI và mô hình kinh doanh (MHKD).""", "resources": [ {"name": "📄 Folder PR", "url": "https://drive.google.com/drive/u/1/folders/1s5EIxMJ1_P1AAvErAIIjhNpmDBBjwI00"}, {"name": "Power BI Analysis", "url": "https://docs.google.com/spreadsheets/d/1V07eBrpl1RnqUR3iwa_hYZbNCSgD1-PIGh9ufXG1-0I/edit?gid=1008653781#gid=1008653781"} ] } ] # 2. Các hàm xử lý def get_resources(project_id): if not project_id: return "### 💡 Chọn một học phần để xem nội dung." proj = next((p for p in projects if p["id"] == project_id), None) if not proj: return "### ❌ Không tìm thấy dữ liệu." md = f"# {proj['title']}\n" md += f"{proj.get('desc', 'Nội dung đang được cập nhật...')}\n" md += "\n---\n### 🛠️ Tài liệu học tập:\n" for res in proj['resources']: md += f"- **[{res['name']}]({res['url']})**\n" return md def handle_tracker(duration, current_task, progress=gr.Progress()): if not current_task: return "00:00", "⚠️ Hãy nhập mục tiêu phiên học!" total_secs = int(duration * 60) for elapsed in range(total_secs + 1): mins, secs = divmod(total_secs - elapsed, 60) progress(elapsed / total_secs, desc=f"Đang tập trung: {current_task}") yield f"{mins:02d}:{secs:02d}", f"📖 Đang nghiên cứu: {current_task}" time.sleep(1) yield "00:00", "✅ Tuyệt vời! Bạn đã hoàn thành phiên học." def add_reflection(cat, task, bg, curr, target, root, confirm, follow, history): new_row = { "Date": datetime.date.today().strftime("%d/%m"), "Category": cat, "Task": task, "Background": bg, "Current condition": curr, "Goal/Target condition": target, "Root Cause Analysis": root, "Confirmation": confirm, "Follow-up": follow } updated_history = pd.concat([pd.DataFrame([new_row]), history], ignore_index=True) return updated_history, "✅ Đã lưu nhật ký phản tư thành công!" # 3. Giao diện Gradio with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.HTML("