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("

🚀 Personal Learning Dashboard

") with gr.Tabs(): # TAB 1: KHO TÀI LIỆU with gr.Tab("📚 Trung tâm Tài liệu"): with gr.Row(): with gr.Column(scale=1): gr.Markdown("### 📂 Danh mục") dropdown_choices = [(p["title"], p["id"]) for p in projects] selector = gr.Dropdown(choices=dropdown_choices, label="Tra cứu nhanh học phần") gr.Markdown("---") categories = ["Tư duy", "Kế toán TT200", "IFRS Chuyên sâu", "Thu nhập", "Đặt câu hỏi", "FTO", "Template for PR"] for cat in categories: with gr.Accordion(cat, open=False): cat_projs = [p for p in projects if p["category"] == cat] for p in cat_projs: btn = gr.Button(p["title"], variant="secondary", size="sm") # Gán output vào resource_output btn.click(fn=lambda pid=p['id']: get_resources(pid), outputs=gr.Markdown(elem_id="res_display")) with gr.Column(scale=2): gr.Markdown("### 🔍 Nội dung chi tiết & Trọng tâm") resource_output = gr.Markdown("Hãy chọn một bài học từ danh mục bên trái.", elem_id="res_display") # TAB 2: FOCUS MODE with gr.Tab("⏱️ Focus Mode"): with gr.Row(): with gr.Column(): task_in = gr.Textbox(label="Mục tiêu phiên học", placeholder="VD: Giải bài tập IFRS 15...") dur_slider = gr.Slider(5, 60, value=25, label="Phút") btn_start = gr.Button("Bắt đầu Focus", variant="primary") with gr.Column(): timer_out = gr.Label(value="00:00") stat_out = gr.Textbox(label="Trạng thái", interactive=False) # TAB 3: REFLECTION JOURNAL with gr.Tab("📝 Reflection Journal"): gr.Markdown("### 🧠 Tư duy giải quyết vấn đề theo chuẩn A3/Lean") with gr.Row(): with gr.Column(): j_cat = gr.Dropdown(choices=["Tư duy", "Kế toán", "Kỹ năng mềm", "Dự án"], label="Category") j_task = gr.Textbox(label="Task/Problem Name", placeholder="Vấn đề cần giải quyết...") j_bg = gr.Textbox(label="Background (Bối cảnh)", lines=2) j_curr = gr.Textbox(label="Current condition (Hiện trạng)", lines=2) with gr.Column(): j_target = gr.Textbox(label="Goal (Mục tiêu hướng tới)", lines=2) j_root = gr.Textbox(label="Root Cause Analysis (Phân tích gốc rễ)", lines=2, placeholder="Sử dụng 5 Why...") j_confirm = gr.Textbox(label="Confirmation (Xác nhận giải pháp)") j_follow = gr.Textbox(label="Follow-up (Theo dõi kết quả)") save_btn = gr.Button("💾 Lưu nhật ký phản tư", variant="primary") msg_out = gr.Markdown("") gr.Markdown("---") gr.Markdown("### 📜 Lịch sử phản tư") history_table = gr.DataFrame(value=journal_data, interactive=False) # Đăng ký sự kiện selector.change(fn=get_resources, inputs=selector, outputs=resource_output) btn_start.click(fn=handle_tracker, inputs=[dur_slider, task_in], outputs=[timer_out, stat_out]) save_btn.click( fn=add_reflection, inputs=[j_cat, j_task, j_bg, j_curr, j_target, j_root, j_confirm, j_follow, history_table], outputs=[history_table, msg_out] ) if __name__ == "__main__": demo.launch(share="True")