2746 lines
127 KiB
HTML
2746 lines
127 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Consolidated Thesis Documents</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 20px;
|
|
background-color: #f9f9f9;
|
|
line-height: 1.6;
|
|
}
|
|
.document-separator {
|
|
page-break-before: always;
|
|
border-top: 3px solid #333;
|
|
margin: 30px 0;
|
|
}
|
|
.document-header {
|
|
background-color: #e9ecef;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin-bottom: 20px;
|
|
border-left: 4px solid #007bff;
|
|
}
|
|
.document-title {
|
|
color: #2c3e50;
|
|
font-size: 24px;
|
|
margin: 0;
|
|
}
|
|
.document-source {
|
|
color: #6c757d;
|
|
font-size: 14px;
|
|
margin-top: 5px;
|
|
}
|
|
.document-content {
|
|
background-color: white;
|
|
padding: 20px;
|
|
border-radius: 5px;
|
|
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
|
margin-bottom: 30px;
|
|
}
|
|
.toc {
|
|
background-color: #f8f9fa;
|
|
padding: 20px;
|
|
border-radius: 5px;
|
|
margin-bottom: 30px;
|
|
border-left: 4px solid #28a745;
|
|
}
|
|
.toc h2 {
|
|
color: #2c3e50;
|
|
margin-top: 0;
|
|
}
|
|
.toc ul {
|
|
list-style-type: decimal;
|
|
padding-left: 20px;
|
|
}
|
|
.toc li {
|
|
margin-bottom: 8px;
|
|
}
|
|
.toc a {
|
|
text-decoration: none;
|
|
color: #007bff;
|
|
}
|
|
.toc a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
h1 {
|
|
color: #343a40;
|
|
border-bottom: 2px solid #007bff;
|
|
padding-bottom: 10px;
|
|
}
|
|
.footer {
|
|
text-align: center;
|
|
margin-top: 30px;
|
|
padding: 15px;
|
|
color: #6c757d;
|
|
font-size: 12px;
|
|
border-top: 1px solid #dee2e6;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Consolidated Thesis Collection</h1>
|
|
<div class="toc">
|
|
<h2>Table of Contents</h2>
|
|
<ul>
|
|
<li><a href="#doc-1">1. Lesson SQLite Database Implementation</a></li>
|
|
<li><a href="#doc-2">2. Presentaion School Schedule Assistant Bot Student Project</a></li>
|
|
<li><a href="#doc-3">3. Professional Thesis Scheduler Bot</a></li>
|
|
<li><a href="#doc-4">4. Scheduler Bot Telegram & CSV Database</a></li>
|
|
<li><a href="#doc-5">5. Student Database Search System Beginner's Guide</a></li>
|
|
<li><a href="#doc-6">6. Thesis Intelligent School Schedule Management System 23 Jan 2026</a></li>
|
|
<li><a href="#doc-7">7. Thesis AI7 Building A Scheduler Bot A Student Project</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="document-separator" id="doc-1"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">1. Lesson SQLite Database Implementation</h2>
|
|
<div class="document-source">Source file: Lesson_ SQLite Database Implementation.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="slide-counter" id="slide-counter">Slide 1 of 12</div>
|
|
|
|
<div class="container">
|
|
<!-- Slide 1: Title Slide -->
|
|
<div class="slide active" id="slide1">
|
|
<div style="flex: 1; display: flex; flex-direction: column; justify-content: center;">
|
|
<div class="lesson-title">Upgrading to Database Storage</div>
|
|
<div class="subject-topic">DT/ICT: SQLite Database Implementation</div>
|
|
<div class="subject-title">Digital Technologies / Information Communication Technologies</div>
|
|
|
|
<div style="margin-top: 40px; text-align: center;">
|
|
<p style="font-size: 1.3rem; color: #7f8c8d;">From CSV to SQLite Database</p>
|
|
<p style="margin-top: 20px;">Taking your Telegram Scheduler Bot to the next level</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn1" disabled="">Previous</button>
|
|
<button id="nextBtn1">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 2: Rules -->
|
|
<div class="slide" id="slide2">
|
|
<h2>Classroom Guidelines</h2>
|
|
|
|
<div class="rules-container">
|
|
<h3>How Points Are Earned:</h3>
|
|
|
|
<p><strong>+2 Points</strong> - You attended class</p>
|
|
<p><strong>+1 Point</strong> - You listened quietly during instruction</p>
|
|
<p><strong>+1 Point</strong> - You attempted all assigned work</p>
|
|
<p><strong>+1 Point</strong> - You completed all assigned work</p>
|
|
|
|
<p style="margin-top: 25px; font-weight: bold; color: #27ae60;">
|
|
Maximum: 5 points per class session
|
|
</p>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn2" disabled="">Previous</button>
|
|
<button id="nextBtn2">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 3: Learning Outcomes -->
|
|
<div class="slide" id="slide3">
|
|
<h2>Learning Outcomes</h2>
|
|
<p class="subject-title">By the end of this lesson, you will be able to:</p>
|
|
|
|
<div class="outcomes-container">
|
|
<ol>
|
|
<li>Understand the difference between CSV and database storage</li>
|
|
<li>Implement SQLite database in an existing Python application</li>
|
|
<li>Create and manage database tables with proper schema design</li>
|
|
<li>Implement CRUD operations (Create, Read, Update, Delete) in Python</li>
|
|
<li>Upgrade an existing Telegram bot from CSV to SQLite database</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="database-concept">
|
|
<p><strong>CRUD Operations:</strong> The four basic functions of persistent storage:</p>
|
|
<ul>
|
|
<li><strong>C</strong>reate - Add new data</li>
|
|
<li><strong>R</strong>ead - Retrieve data</li>
|
|
<li><strong>U</strong>pdate - Modify existing data</li>
|
|
<li><strong>D</strong>elete - Remove data</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn3" disabled="">Previous</button>
|
|
<button id="nextBtn3">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 4: Why This Matters -->
|
|
<div class="slide" id="slide4">
|
|
<h2>Why This Matters</h2>
|
|
|
|
<div class="why-container">
|
|
<p><strong>Real-world Database Applications:</strong></p>
|
|
<ul>
|
|
<li>Every modern website uses databases (Facebook, Amazon, Google)</li>
|
|
<li>Mobile apps store user data, preferences, and content</li>
|
|
<li>Business systems track inventory, orders, and customers</li>
|
|
<li>Gaming platforms save player progress and achievements</li>
|
|
</ul>
|
|
|
|
<p style="margin-top: 30px;"><strong>Career Relevance:</strong></p>
|
|
<p>Database skills are required for:</p>
|
|
<ul>
|
|
<li>Backend Developer</li>
|
|
<li>Full Stack Developer</li>
|
|
<li>Data Analyst</li>
|
|
<li>Software Engineer</li>
|
|
<li>DevOps Engineer</li>
|
|
</ul>
|
|
|
|
<p style="margin-top: 20px;"><strong>Industry Demand:</strong> Database management is consistently ranked among the top technical skills employers seek.</p>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn4" disabled="">Previous</button>
|
|
<button id="nextBtn4">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 5: Project Overview -->
|
|
<div class="slide" id="slide5">
|
|
<h2>Project Overview: What We're Building</h2>
|
|
|
|
<div class="content-container">
|
|
<table class="comparison-table">
|
|
<tbody><tr>
|
|
<th>Feature</th>
|
|
<th class="v2-col">Current v2 (CSV)</th>
|
|
<th class="v3-col">New v3 (SQLite)</th>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Data Storage</strong></td>
|
|
<td class="v2-col">schedule_template RS.csv file</td>
|
|
<td class="v3-col">schedule.db database file</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Data Access</strong></td>
|
|
<td class="v2-col">Read-only from CSV</td>
|
|
<td class="v3-col">Read/Write via database</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Persistence</strong></td>
|
|
<td class="v2-col">Manual file editing required</td>
|
|
<td class="v3-col">Automatic, persists between runs</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>New Features</strong></td>
|
|
<td class="v2-col">None</td>
|
|
<td class="v3-col">Interactive /add command</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Scalability</strong></td>
|
|
<td class="v2-col">Limited by CSV format</td>
|
|
<td class="v3-col">Supports complex queries</td>
|
|
</tr>
|
|
</tbody></table>
|
|
|
|
<div class="project-files">
|
|
<h3>Required Files for This Lesson:</h3>
|
|
<ul>
|
|
<li><code>telegram_scheduler_v2.py</code> - Your existing working bot</li>
|
|
<li><code>telegram_scheduler_v3.py</code> - New version we'll create</li>
|
|
<li><code>schedule_template RS.csv</code> - Original schedule data</li>
|
|
<li><code>schedule.db</code> - Will be created automatically</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn5" disabled="">Previous</button>
|
|
<button id="nextBtn5">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 6: Setup Instructions -->
|
|
<div class="slide" id="slide6">
|
|
<h2>Step-by-Step Complete Setup Guide</h2>
|
|
<p class="lead">Check your Python installation before starting</p>
|
|
|
|
<div class="content-container">
|
|
<p><strong>Open PowerShell:</strong></p>
|
|
<p>Press <code>Windows + R</code>, type <code>powershell</code>, press <code>Enter</code></p>
|
|
|
|
<p><strong>Check Python Version:</strong></p>
|
|
<div class="terminal">
|
|
<span class="terminal-command">python --version</span>
|
|
<span class="terminal-comment"># Should show: Python 3.x.x</span>
|
|
|
|
<span class="terminal-comment"># If that doesn't work, try:</span>
|
|
<span class="terminal-command">python3 --version</span>
|
|
<span class="terminal-comment"># Or on some systems:</span>
|
|
<span class="terminal-command">py --version</span>
|
|
</div>
|
|
|
|
<div class="database-concept">
|
|
<p><strong>Required Python Libraries:</strong></p>
|
|
<ul>
|
|
<li><code>python-telegram-bot</code> - For Telegram bot functionality</li>
|
|
<li><code>sqlite3</code> - Comes built-in with Python</li>
|
|
<li><code>pandas</code> - For CSV reading (optional for v3)</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn6" disabled="">Previous</button>
|
|
<button id="nextBtn6">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 7: Create Project Folder -->
|
|
<div class="slide" id="slide7">
|
|
<h2>Create Your Project Folder</h2>
|
|
<p class="lead">Organize your files properly from the start</p>
|
|
|
|
<div class="content-container">
|
|
<p><strong>Open PowerShell or Command Prompt:</strong></p>
|
|
<p>Make sure you're not in the Python shell (should see <code>C:\></code> or <code>PS C:\></code>)</p>
|
|
|
|
<p><strong>Navigate to Desktop or Documents:</strong></p>
|
|
<p>Let's create a folder on your Desktop for easy access:</p>
|
|
|
|
<div class="terminal">
|
|
<span class="terminal-comment"># Go to Desktop (Windows)</span>
|
|
<span class="terminal-command">cd Desktop</span>
|
|
|
|
<span class="terminal-comment"># Create a new folder for your project</span>
|
|
<span class="terminal-command">mkdir telegram_scheduler_db</span>
|
|
|
|
<span class="terminal-comment"># Go into your new folder</span>
|
|
<span class="terminal-command">cd telegram_scheduler_db</span>
|
|
|
|
<span class="terminal-comment"># Copy your existing files here:</span>
|
|
<span class="terminal-comment"># 1. telegram_scheduler_v2.py</span>
|
|
<span class="terminal-comment"># 2. schedule_template RS.csv</span>
|
|
<span class="terminal-comment"># 3. Any other related files</span>
|
|
</div>
|
|
|
|
<div class="project-files">
|
|
<p><strong>Expected Folder Structure:</strong></p>
|
|
<div class="terminal">
|
|
telegram_scheduler_db/
|
|
├── telegram_scheduler_v2.py # Your working bot
|
|
├── telegram_scheduler_v3.py # We'll create this
|
|
├── schedule_template RS.csv # Your schedule data
|
|
├── requirements.txt # Dependencies
|
|
└── venv/ # Virtual environment
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn7" disabled="">Previous</button>
|
|
<button id="nextBtn7">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 8: Set Up Virtual Environment -->
|
|
<div class="slide" id="slide8">
|
|
<h2>Set Up Virtual Environment (venv)</h2>
|
|
<p class="lead">Isolate project dependencies for clean development</p>
|
|
|
|
<div class="content-container">
|
|
<p><strong>Why Virtual Environment?</strong></p>
|
|
<ul>
|
|
<li>Keeps project dependencies separate</li>
|
|
<li>Avoids version conflicts between projects</li>
|
|
<li>Makes sharing and deployment easier</li>
|
|
</ul>
|
|
|
|
<p><strong>Create Virtual Environment:</strong></p>
|
|
<p>Make sure you're in your <code>telegram_scheduler_db</code> folder, then run:</p>
|
|
|
|
<div class="terminal">
|
|
<span class="terminal-comment"># Create virtual environment named 'venv'</span>
|
|
<span class="terminal-command">python -m venv venv</span>
|
|
|
|
<span class="terminal-comment"># Check if venv folder was created</span>
|
|
<span class="terminal-command">dir</span>
|
|
<span class="terminal-comment"># You should see a 'venv' folder in the list</span>
|
|
</div>
|
|
|
|
<p><strong>Activate Virtual Environment:</strong></p>
|
|
<p>Windows PowerShell:</p>
|
|
<div class="terminal">
|
|
<span class="terminal-command">venv\Scripts\Activate.ps1</span>
|
|
<span class="terminal-comment"># If you get an error about execution policy, run this first:</span>
|
|
<span class="terminal-command">Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser</span>
|
|
<span class="terminal-command">venv\Scripts\Activate.ps1</span>
|
|
</div>
|
|
|
|
<p><strong>Success Indicator:</strong> You should see <code>(venv)</code> at the start of your command line.</p>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn8" disabled="">Previous</button>
|
|
<button id="nextBtn8">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 9: Install Required Libraries -->
|
|
<div class="slide" id="slide9">
|
|
<h2>Install Required Libraries</h2>
|
|
<p class="lead">Get the Python packages needed for this project</p>
|
|
|
|
<div class="content-container">
|
|
<p><strong>First, activate your venv:</strong></p>
|
|
<p>Make sure you see <code>(venv)</code> before the prompt.</p>
|
|
|
|
<p><strong>Install required packages:</strong></p>
|
|
<div class="terminal">
|
|
<span class="terminal-comment"># Install the Telegram bot library</span>
|
|
<span class="terminal-command">pip install python-telegram-bot</span>
|
|
|
|
<span class="terminal-comment"># Install pandas for CSV handling (optional for v3)</span>
|
|
<span class="terminal-command">pip install pandas</span>
|
|
|
|
<span class="terminal-comment"># Verify installations</span>
|
|
<span class="terminal-command">pip show python-telegram-bot</span>
|
|
<span class="terminal-command">pip show pandas</span>
|
|
</div>
|
|
|
|
<p><strong>Create Requirements File:</strong></p>
|
|
<div class="terminal">
|
|
<span class="terminal-command">pip freeze > requirements.txt</span>
|
|
|
|
<span class="terminal-comment"># View the requirements file</span>
|
|
<span class="terminal-command">type requirements.txt</span>
|
|
<span class="terminal-comment"># (Mac/Linux: use 'cat requirements.txt' instead of 'type')</span>
|
|
</div>
|
|
|
|
<div class="database-concept">
|
|
<p><strong>Why requirements.txt matters:</strong></p>
|
|
<ul>
|
|
<li>Anyone can install exact same versions with <code>pip install -r requirements.txt</code></li>
|
|
<li>Ensures your project works the same on different computers</li>
|
|
<li>Essential for collaboration and deployment</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn9" disabled="">Previous</button>
|
|
<button id="nextBtn9">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 10: Lesson Structure -->
|
|
<div class="slide" id="slide10">
|
|
<h2>Today's Lesson Structure</h2>
|
|
|
|
<div class="content-container">
|
|
<p><strong>Phase 1: Database Concepts (15 minutes)</strong></p>
|
|
<ul>
|
|
<li>Understanding CSV vs Database storage</li>
|
|
<li>Introduction to SQLite</li>
|
|
<li>Database schema design</li>
|
|
<li>CRUD operations explained</li>
|
|
</ul>
|
|
|
|
<p><strong>Phase 2: Code Implementation (30 minutes)</strong></p>
|
|
<ul>
|
|
<li>Creating v3 file from v2 template</li>
|
|
<li>Adding SQLite database functions</li>
|
|
<li>Implementing /add command with conversation flow</li>
|
|
<li>Updating existing commands to use database</li>
|
|
</ul>
|
|
|
|
<p><strong>Phase 3: Testing & Practice (15 minutes)</strong></p>
|
|
<ul>
|
|
<li>Testing database creation</li>
|
|
<li>Adding new classes via /add command</li>
|
|
<li>Verifying data persistence</li>
|
|
<li>Troubleshooting common issues</li>
|
|
</ul>
|
|
|
|
<div class="project-files">
|
|
<p><strong>Key Files We'll Create:</strong></p>
|
|
<ul>
|
|
<li><code>telegram_scheduler_v3.py</code> - Main database implementation</li>
|
|
<li><code>schedule.db</code> - SQLite database file (auto-created)</li>
|
|
<li><code>database_operations.py</code> - Optional helper module</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn10" disabled="">Previous</button>
|
|
<button id="nextBtn10">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 11: What You'll Learn -->
|
|
<div class="slide" id="slide11">
|
|
<h2>What You'll Achieve Today</h2>
|
|
|
|
<div class="content-container">
|
|
<p>By the end of this lesson, you will have:</p>
|
|
|
|
<div class="outcomes-container">
|
|
<ul>
|
|
<li>✅ Created a working v3 Telegram bot with SQLite database</li>
|
|
<li>✅ Implemented database CRUD operations in Python</li>
|
|
<li>✅ Added interactive /add command to your bot</li>
|
|
<li>✅ Converted CSV-based application to database-driven</li>
|
|
<li>✅ Gained practical experience with real database implementation</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="database-concept">
|
|
<p><strong>Key Technical Skills You'll Develop:</strong></p>
|
|
<ul>
|
|
<li>SQLite database setup and management</li>
|
|
<li>Database schema design principles</li>
|
|
<li>Python database programming with sqlite3</li>
|
|
<li>Telegram bot conversation handling</li>
|
|
<li>Data persistence and state management</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<p style="margin-top: 20px; text-align: center; color: #27ae60;">
|
|
<strong>Ready to upgrade your bot from v2 to v3?</strong>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn11" disabled="">Previous</button>
|
|
<button id="nextBtn11">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 12: Next Steps -->
|
|
<div class="slide" id="slide12">
|
|
<div class="content-container">
|
|
<h1>Next Steps</h1>
|
|
|
|
<p><strong>After this introductory presentation:</strong></p>
|
|
|
|
<div class="outcomes-container">
|
|
<ol>
|
|
<li>Follow along with the detailed implementation guide</li>
|
|
<li>Create your <code>telegram_scheduler_v3.py</code> file</li>
|
|
<li>Implement the SQLite database functions</li>
|
|
<li>Test your upgraded bot thoroughly</li>
|
|
<li>Show your working bot to receive credit</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="database-concept">
|
|
<p><strong>Support & Resources:</strong></p>
|
|
<ul>
|
|
<li>Detailed code examples in the implementation guide</li>
|
|
<li>Step-by-step instructions for each function</li>
|
|
<li>Troubleshooting tips for common issues</li>
|
|
<li>Ask questions anytime during the implementation</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<p style="margin-top: 30px; color: #7f8c8d;">
|
|
Digital Technologies / ICT<br>
|
|
Database Implementation Project
|
|
</p>
|
|
|
|
<p style="text-align: center; margin-top: 20px;">
|
|
<strong>Let's begin the implementation!</strong>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="prevBtn12" disabled="">Previous</button>
|
|
<button id="nextBtn12">Next</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const totalSlides = 12;
|
|
let currentSlide = 1;
|
|
|
|
function updateSlideCounter() {
|
|
document.getElementById('slide-counter').textContent = `Slide ${currentSlide} of ${totalSlides}`;
|
|
}
|
|
|
|
function showSlide(slideNumber) {
|
|
for (let i = 1; i <= totalSlides; i++) {
|
|
const slide = document.getElementById(`slide${i}`);
|
|
if (slide) slide.classList.remove('active');
|
|
}
|
|
|
|
const currentSlideElement = document.getElementById(`slide${slideNumber}`);
|
|
if (currentSlideElement) {
|
|
currentSlideElement.classList.add('active');
|
|
currentSlide = slideNumber;
|
|
updateSlideCounter();
|
|
updateButtons();
|
|
}
|
|
}
|
|
|
|
function updateButtons() {
|
|
const prevButtons = document.querySelectorAll('[id^="prevBtn"]');
|
|
prevButtons.forEach(btn => {
|
|
btn.disabled = currentSlide === 1;
|
|
});
|
|
|
|
const nextButtons = document.querySelectorAll('[id^="nextBtn"]');
|
|
nextButtons.forEach(btn => {
|
|
if (currentSlide === totalSlides) {
|
|
btn.textContent = 'Complete Introduction';
|
|
} else {
|
|
btn.textContent = 'Next';
|
|
}
|
|
});
|
|
}
|
|
|
|
document.querySelectorAll('[id^="nextBtn"]').forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
if (currentSlide < totalSlides) {
|
|
showSlide(currentSlide + 1);
|
|
} else {
|
|
alert('Introduction complete! Now proceed to the detailed SQLite implementation guide to upgrade your v2 bot to v3.');
|
|
}
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('[id^="prevBtn"]').forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
if (currentSlide > 1) {
|
|
showSlide(currentSlide - 1);
|
|
}
|
|
});
|
|
});
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'ArrowRight' || e.key === ' ' || e.key === 'PageDown') {
|
|
if (currentSlide < totalSlides) {
|
|
showSlide(currentSlide + 1);
|
|
}
|
|
} else if (e.key === 'ArrowLeft' || e.key === 'PageUp') {
|
|
if (currentSlide > 1) {
|
|
showSlide(currentSlide - 1);
|
|
}
|
|
}
|
|
});
|
|
|
|
updateSlideCounter();
|
|
updateButtons();
|
|
showSlide(1);
|
|
</script>
|
|
|
|
</div>
|
|
<div class="document-separator" id="doc-2"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">2. Presentaion School Schedule Assistant Bot Student Project</h2>
|
|
<div class="document-source">Source file: Presentaion_School Schedule Assistant Bot _ Student Project.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="presentation-container">
|
|
<!-- Slide 1: Title Slide -->
|
|
<div class="slide active" id="slide1">
|
|
<div class="title-slide">
|
|
<div>
|
|
<h1 class="thesis-title">School Schedule Assistant Bot</h1>
|
|
<p class="thesis-subtitle">A Telegram-based Solution for Student Organization</p>
|
|
</div>
|
|
|
|
<div class="author-info">
|
|
<div class="institution">
|
|
Student Thesis Project
|
|
</div>
|
|
|
|
<div class="supervisor-info">
|
|
Supervisor: <strong>Bob Santos</strong>
|
|
</div>
|
|
|
|
<div class="supervisor-info">
|
|
Student Developer: <strong>Gregory</strong>
|
|
</div>
|
|
|
|
<div class="date">
|
|
Academic Year 2025-2026
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 2: Project Overview -->
|
|
<div class="slide" id="slide2">
|
|
<div class="slide-header">
|
|
<h1>Project Overview</h1>
|
|
<p class="lead">A digital assistant for modern student life</p>
|
|
</div>
|
|
|
|
<div>
|
|
<h3>Project Description</h3>
|
|
<p>A friendly digital assistant that provides instant class schedule information through Telegram. Designed to help students stay organized and never miss classes.</p>
|
|
|
|
</div>
|
|
|
|
<h3>Key Features</h3>
|
|
|
|
<div class="feature-list">
|
|
<div class="feature-item">
|
|
<div class="feature-bullet">1</div>
|
|
<div class="feature-text">
|
|
<strong>Always Available</strong> - Accessible 24/7 through Telegram messenger on any device
|
|
</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-bullet">2</div>
|
|
<div class="feature-text">
|
|
<strong>Accurate Information</strong> - Provides up-to-date schedule information with real-time updates
|
|
</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-bullet">3</div>
|
|
<div class="feature-text">
|
|
<strong>Teacher-Friendly</strong> - Teachers can update schedules without technical knowledge using familiar spreadsheet tools
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Slide 3: How It Works -->
|
|
<div class="slide" id="slide3">
|
|
<h2>How Students Use It</h2>
|
|
<p class="lead">Simple text commands anyone can understand</p>
|
|
|
|
<h3>Basic Commands</h3>
|
|
<p>Students ask questions using simple commands starting with "/".</p>
|
|
|
|
<div class="demo-section">
|
|
<p><strong>Example 1: Find current class</strong></p>
|
|
<div class="demo-message">
|
|
Student: <strong>/whereami</strong><br>
|
|
Bot: "You should be in Math class, Room 201"
|
|
</div>
|
|
|
|
<p><strong>Example 2: See today's schedule</strong></p>
|
|
<div class="demo-message">
|
|
Student: <strong>/schedule</strong><br>
|
|
Bot: "Today: 9:00 Math, 10:00 Science..."
|
|
</div>
|
|
|
|
<p><strong>Example 3: Prepare for tomorrow</strong></p>
|
|
<div class="demo-message">
|
|
Student: <strong>/tomorrow</strong><br>
|
|
Bot: "Tomorrow: 9:00 English, 10:00 Physics..."
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 4: How It's Made Simple -->
|
|
<div class="slide" id="slide4">
|
|
<h2>Technology Made Simple</h2>
|
|
<p class="lead">Easy for everyone - students, teachers, administrators</p>
|
|
|
|
<h3>For Students</h3>
|
|
<p>• No new app to download - uses Telegram</p>
|
|
<p>• Simple text commands</p>
|
|
<p>• Available 24/7 from any smartphone</p>
|
|
|
|
<h3>For Teachers</h3>
|
|
<p>• No programming knowledge needed</p>
|
|
<p>• Use Excel or Google Sheets</p>
|
|
<p>• Edit spreadsheet → Save → Bot updates automatically</p>
|
|
|
|
</div>
|
|
|
|
<!-- Slide 6: Database and Testing -->
|
|
<div class="slide" id="slide5">
|
|
<h2>Better Storage and Testing</h2>
|
|
<p class="lead">Improving reliability and user experience</p>
|
|
|
|
<h3>Better Storage System</h3>
|
|
<p>• Moving from spreadsheets to reliable database</p>
|
|
<p>• Faster responses with many users</p>
|
|
<p>• More secure information storage</p>
|
|
|
|
<h3>Real Student Testing</h3>
|
|
<p>• Test with real students before school-wide launch</p>
|
|
<p>• Collect feedback for improvements</p>
|
|
<p>• Ensure it works for all user types</p>
|
|
|
|
</div>
|
|
|
|
<!-- Slide 7: Benefits and Conclusion -->
|
|
<div class="slide" id="slide6">
|
|
<div class="slide-header">
|
|
<h1>Future Possibilities</h1>
|
|
<p class="lead">This bot could be extended in several interesting ways:</p>
|
|
</div>
|
|
|
|
<div class="tech-section">
|
|
<h3>Expansion Opportunities</h3>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">👥</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Multiple User Support</span>
|
|
<span class="tech-desc">Allow different students to have personalized schedules</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">👨🏫</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Teacher Information</span>
|
|
<span class="tech-desc">Include which teacher is teaching each class and their contact information</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">🗺️</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Classroom Maps</span>
|
|
<span class="tech-desc">Add links to maps showing where classrooms are located</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">📚</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Homework Integration</span>
|
|
<span class="tech-desc">Connect to homework assignment systems</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">🔔</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Mobile Notifications</span>
|
|
<span class="tech-desc">Send push notifications before class starts</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">📅</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Special Schedules</span>
|
|
<span class="tech-desc">Handle exam weeks, holidays, and special event days</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tech-item">
|
|
<div class="tech-icon">📊</div>
|
|
<div class="tech-content">
|
|
<span class="tech-name">Statistics Tracking</span>
|
|
<span class="tech-desc">Track which commands are used most often to improve the bot</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="benefit-item">
|
|
<p><strong>Scalability:</strong> These enhancements would make the bot even more valuable for students and faculty.</p>
|
|
<p>Each addition builds on the solid foundation already established.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Navigation -->
|
|
<div class="navigation">
|
|
<button class="nav-btn" id="prev-btn" onclick="prevSlide()">← Back</button>
|
|
|
|
<div class="slide-counter">
|
|
<span id="current-slide">1</span> of <span id="total-slides">7</span>
|
|
<div class="progress-bar">
|
|
<div class="progress-fill" id="progress-fill" style="width: 12.5%;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<button class="nav-btn" id="next-btn" onclick="nextSlide()">Next →</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let currentSlide = 1;
|
|
const totalSlides = 6;
|
|
|
|
function showSlide(slideNumber) {
|
|
// Hide all slides
|
|
document.querySelectorAll('.slide').forEach(slide => {
|
|
slide.classList.remove('active');
|
|
});
|
|
|
|
// Show selected slide
|
|
document.getElementById(`slide${slideNumber}`).classList.add('active');
|
|
|
|
// Scroll to top of slide
|
|
document.getElementById(`slide${slideNumber}`).scrollTop = 0;
|
|
|
|
// Update slide counter
|
|
document.getElementById('current-slide').textContent = slideNumber;
|
|
document.getElementById('total-slides').textContent = totalSlides;
|
|
|
|
// Update progress bar
|
|
const progressPercentage = (slideNumber / totalSlides) * 100;
|
|
document.getElementById('progress-fill').style.width = `${progressPercentage}%`;
|
|
|
|
// Update button states
|
|
document.getElementById('prev-btn').disabled = slideNumber === 1;
|
|
document.getElementById('next-btn').disabled = slideNumber === totalSlides;
|
|
|
|
// Update button text on last slide
|
|
if (slideNumber === totalSlides) {
|
|
document.getElementById('next-btn').textContent = 'Finish';
|
|
} else {
|
|
document.getElementById('next-btn').textContent = 'Next →';
|
|
}
|
|
}
|
|
|
|
function nextSlide() {
|
|
if (currentSlide < totalSlides) {
|
|
currentSlide++;
|
|
showSlide(currentSlide);
|
|
}
|
|
}
|
|
|
|
function prevSlide() {
|
|
if (currentSlide > 1) {
|
|
currentSlide--;
|
|
showSlide(currentSlide);
|
|
}
|
|
}
|
|
|
|
// Initialize
|
|
showSlide(1);
|
|
|
|
// Keyboard navigation
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'ArrowRight' || e.key === ' ' || e.key === 'Enter') {
|
|
nextSlide();
|
|
} else if (e.key === 'ArrowLeft') {
|
|
prevSlide();
|
|
}
|
|
});
|
|
|
|
// Touch swipe for mobile
|
|
let touchStartY = 0;
|
|
let touchEndY = 0;
|
|
|
|
document.addEventListener('touchstart', (e) => {
|
|
touchStartY = e.changedTouches[0].screenY;
|
|
});
|
|
|
|
document.addEventListener('touchend', (e) => {
|
|
touchEndY = e.changedTouches[0].screenY;
|
|
handleSwipe();
|
|
});
|
|
|
|
function handleSwipe() {
|
|
const swipeThreshold = 100;
|
|
|
|
if (touchEndY < touchStartY - swipeThreshold) {
|
|
// Swipe up - next slide
|
|
nextSlide();
|
|
}
|
|
|
|
if (touchEndY > touchStartY + swipeThreshold) {
|
|
// Swipe down - previous slide
|
|
prevSlide();
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</div>
|
|
<div class="document-separator" id="doc-3"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">3. Professional Thesis Scheduler Bot</h2>
|
|
<div class="document-source">Source file: Professional_Thesis_Scheduler_Bot.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="page">
|
|
<div class="header">
|
|
<h1>Thesis: Development and Analysis of a Telegram-Based Joke Bot</h1>
|
|
<div class="subtitle">Bridging Simplicity with Digital Humor Delivery</div>
|
|
<div class="author">Student Developer</div>
|
|
<div class="date">December 2024</div>
|
|
</div>
|
|
|
|
<h2>Abstract</h2>
|
|
<p>This document presents the design, implementation, and analysis of a minimalistic Telegram chatbot created for automated joke delivery. Developed using Python and the <span class="highlight">python-telegram-bot</span> framework, this project serves as a case study in creating lightweight, functional digital companions. The bot demonstrates how simple code can produce meaningful user engagement while exploring the role of humor in digital communication.</p>
|
|
|
|
<h2>Introduction</h2>
|
|
<p>In today's digital landscape, chatbots have become increasingly common across messaging platforms, serving various purposes from customer service to entertainment. This project focuses on creating a Telegram bot with a singular, joyful purpose: telling jokes. By emphasizing simplicity and narrow scope, this bot illustrates how minimal programming can generate tangible user satisfaction and engagement. This work contributes to discussions about accessible AI tools, human-computer interaction, and humor's role in technology.</p>
|
|
|
|
<h2>System Architecture</h2>
|
|
<p>The bot employs a straightforward, event-driven architecture built on several key components:</p>
|
|
|
|
<h3>Core Framework</h3>
|
|
<p>Utilizes the <span class="highlight">python-telegram-bot</span> library (version 20+), providing an asynchronous interface for Telegram's Bot API. This choice enables efficient message handling without complex setup.</p>
|
|
|
|
<h3>Command Structure</h3>
|
|
<p>The bot implements two primary commands:</p>
|
|
<ul>
|
|
<li><strong>/start</strong>: Initializes user interaction with welcome instructions</li>
|
|
<li><strong>/joke</strong>: Triggers random selection and delivery of pre-defined jokes</li>
|
|
</ul>
|
|
|
|
<h3>Data Management</h3>
|
|
<p>Uses a static Python list (<span class="highlight">JOKE_LIST</span>) as a lightweight database containing three curated, family-friendly jokes with emoji embellishments for enhanced engagement.</p>
|
|
|
|
<h3>Execution Method</h3>
|
|
<p>The bot operates via long polling (<span class="highlight">app.run_polling()</span>), maintaining persistent connection to Telegram's servers to listen for user commands continuously.</p>
|
|
|
|
<h2>Code Implementation</h2>
|
|
<p>The complete implementation comprises fewer than 30 functional lines of code:</p>
|
|
|
|
<div class="code-block">from telegram import Update
|
|
from telegram.ext import Application, CommandHandler, ContextTypes
|
|
import random
|
|
|
|
JOKE_LIST = [
|
|
"Why did the robot go to school? To recharge his brain! 🔋",
|
|
"Knock knock!\nWho's there?\nLettuce!\nLettuce who?\nLettuce in!",
|
|
"Why don't eggs tell jokes? They'd crack each other up! 🥚"
|
|
]
|
|
|
|
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
await update.message.reply_text("Hi! Type /joke for a funny joke! 😄")
|
|
|
|
async def send_joke(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
joke = random.choice(JOKE_LIST)
|
|
await update.message.reply_text(joke)
|
|
|
|
def main():
|
|
BOT_TOKEN = "7864875699:AAEWf6ff1DYNzPvW6Dbn7D2W5aavg9KPhgY"
|
|
|
|
app = Application.builder().token(BOT_TOKEN).build()
|
|
app.add_handler(CommandHandler("start", start))
|
|
app.add_handler(CommandHandler("joke", send_joke))
|
|
print("Bot is running... Press Ctrl+C to stop.")
|
|
app.run_polling()
|
|
|
|
if __name__ == "__main__":
|
|
main()</div>
|
|
|
|
<h3>Design Philosophy</h3>
|
|
<p>The implementation embodies a "less is more" approach with:</p>
|
|
<ul>
|
|
<li><strong>Minimal Dependencies</strong>: Only essential libraries</li>
|
|
<li><strong>Stateless Design</strong>: No user data persistence required</li>
|
|
<li><strong>Simple Error Handling</strong>: Leverages framework defaults</li>
|
|
</ul>
|
|
|
|
<h2>Joke Content Analysis</h2>
|
|
<p>The bot's humor collection demonstrates thoughtful content strategy:</p>
|
|
|
|
<div class="joke-example">
|
|
<strong>Sample Joke 1:</strong> "Why did the robot go to school? To recharge his brain! 🔋"<br>
|
|
<em>Analysis:</em> Combines technology theme with educational context, using battery emoji for visual enhancement.
|
|
</div>
|
|
|
|
<div class="joke-example">
|
|
<strong>Sample Joke 2:</strong> Knock-knock format with "Lettuce" pun<br>
|
|
<em>Analysis:</em> Uses classic joke structure familiar to most users, incorporating wordplay.
|
|
</div>
|
|
|
|
<div class="joke-example">
|
|
<strong>Sample Joke 3:</strong> "Why don't eggs tell jokes? They'd crack each other up! 🥚"<br>
|
|
<em>Analysis:</strong> Food-based humor with visual egg emoji, employing double meaning of "crack up."
|
|
</div>
|
|
|
|
<h2>Educational Value</h2>
|
|
<p>This project demonstrates several important programming concepts for learners:</p>
|
|
|
|
<h3>Core Concepts Illustrated</h3>
|
|
<ul>
|
|
<li><strong>API Integration</strong>: Connecting to external services (Telegram)</li>
|
|
<li><strong>Event-Driven Programming</strong>: Responding to user commands</li>
|
|
<li><strong>Randomization</strong>: Using Python's random module for content selection</li>
|
|
<li><strong>Asynchronous Operations</strong>: Handling multiple potential users</li>
|
|
<li><strong>Modular Design</strong>: Separating concerns into functions</li>
|
|
</ul>
|
|
|
|
<h3>Learning Pathway</h3>
|
|
<p>From this foundation, students can expand to:</p>
|
|
<ul>
|
|
<li>Database integration for storing jokes</li>
|
|
<li>User preference tracking</li>
|
|
<li>Natural language processing for understanding free-form requests</li>
|
|
<li>Integration with external APIs for dynamic content</li>
|
|
</ul>
|
|
|
|
<h2>Conclusion</h2>
|
|
<p>The Telegram joke bot, despite its apparent simplicity, serves as a compelling artifact in human-computer interaction studies. It demonstrates that minimal code—when focused on a clear, joyful purpose—can generate meaningful engagement. The project highlights that technology need not be complex to be effective; sometimes, a few lines of code and well-chosen humor can connect with users on a human level. As conversational AI evolves, this bot stands as a reminder of foundational principles in digital design: clarity of purpose, user-centered thinking, and the power of simplicity.</p>
|
|
|
|
<p>This project proves that programming isn't solely about technical complexity but about creating solutions that address human needs—in this case, the universal need for laughter and connection. It serves as an excellent starting point for aspiring developers to understand real-world application of coding principles while creating something genuinely enjoyable.</p>
|
|
|
|
<div class="footer">
|
|
Thesis: Telegram Joke Bot Development | Page 1 of 1
|
|
</div>
|
|
<div class="page-number">1</div>
|
|
</div>
|
|
</div>
|
|
<div class="document-separator" id="doc-4"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">4. Scheduler Bot Telegram & CSV Database</h2>
|
|
<div class="document-source">Source file: Scheduler Bot_ Telegram & CSV Database.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="slide-counter" id="slide-counter">Slide 3 of 8</div>
|
|
|
|
<div class="container">
|
|
<!-- Slide 1: Title -->
|
|
<div class="slide" id="slide1">
|
|
<div style="flex: 1; display: flex; flex-direction: column; justify-content: center;">
|
|
<h1>Scheduler Bot Upgrade: CSV to SQLite</h1>
|
|
<p style="font-size: 1.3rem; color: #4a5568;">From CSV Files to Database Management</p>
|
|
<p style="margin-top: 30px; font-size: 1.1rem; color: #718096;">
|
|
Transform your CSV-based scheduler into a dynamic database system
|
|
</p>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn1">Previous</button>
|
|
<button class="nav-btn" id="nextBtn1">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 2: Before vs After Comparison -->
|
|
<div class="slide" id="slide2">
|
|
<h2>CSV vs SQLite: What's Changing</h2>
|
|
|
|
<div class="comparison">
|
|
<div class="old-code">
|
|
<h3>Current System (CSV)</h3>
|
|
<ul>
|
|
<li>Reads from <code>schedule_template RS.csv</code></li>
|
|
<li>Uses pandas library</li>
|
|
<li>Static file that you edit manually</li>
|
|
<li>Schedule loads at bot startup</li>
|
|
<li>No way to add classes via bot</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="new-code">
|
|
<h3>New System (SQLite)</h3>
|
|
<ul>
|
|
<li>Stores data in <code>schedule.db</code> database</li>
|
|
<li>Uses built-in sqlite3 module</li>
|
|
<li>Dynamic - you can add classes via bot</li>
|
|
<li>Real-time data access</li>
|
|
<li>Users can add their own schedule entries</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<p><strong>What we're replacing:</strong></p>
|
|
<ul>
|
|
<li><code>pandas</code> → <code>sqlite3</code> (built-in, no install needed!)</li>
|
|
<li><code>CSV file</code> → <code>SQLite database</code></li>
|
|
<li><code>Static loading</code> → <code>Dynamic database operations</code></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn2">Previous</button>
|
|
<button class="nav-btn" id="nextBtn3">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 3: Step-by-Step Guide - Part 1 -->
|
|
<div class="slide active" id="slide3">
|
|
<h2>Step-by-Step Upgrade - Part 1</h2>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">1</div>
|
|
<strong>Remove pandas import</strong>
|
|
<p>At the top of your file, FIND and DELETE these lines:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
try:
|
|
import pandas as pd
|
|
except ImportError:
|
|
print("❌ Error: pandas library not found!")
|
|
print("Please install required packages using:")
|
|
print("pip install -r requirements.txt")
|
|
exit(1)</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">2</div>
|
|
<strong>Add sqlite3 import</strong>
|
|
<p>At the VERY TOP (after other imports), ADD this line:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
import sqlite3</div>
|
|
<p>Your imports should now look like:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
import datetime
|
|
from telegram import Update
|
|
from telegram.ext import Application, CommandHandler, ContextTypes
|
|
import sqlite3 # ← ADDED THIS LINE</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">3</div>
|
|
<strong>Add MessageHandler import</strong>
|
|
<p>Change this import line:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
from telegram.ext import Application, CommandHandler, ContextTypes</div>
|
|
<p>To this:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters # ← ADDED MessageHandler and filters</div>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn3">Previous</button>
|
|
<button class="nav-btn" id="nextBtn4">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 4: Step-by-Step Guide - Part 2 -->
|
|
<div class="slide" id="slide4">
|
|
<h2>Step-by-Step Upgrade - Part 2</h2>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">4</div>
|
|
<strong>Add database configuration</strong>
|
|
<p>After your <code>BOT_TOKEN</code> line, ADD these lines:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
# Database setup
|
|
DATABASE_NAME = "schedule.db"
|
|
|
|
# User states for tracking conversations
|
|
user_states = {} # Stores user conversation state</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">5</div>
|
|
<strong>Remove old schedule loading</strong>
|
|
<p>FIND and DELETE the entire <code>load_schedule()</code> function:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.85rem; padding: 10px;">
|
|
def load_schedule():
|
|
"""
|
|
Load schedule from CSV file using pandas
|
|
Returns a dictionary with day-wise schedule
|
|
"""
|
|
try:
|
|
# Read CSV file - Updated to use the provided file name
|
|
df = pd.read_csv('schedule_template RS.csv')
|
|
schedule = {}
|
|
|
|
# Process each row (each day)
|
|
for _, row in df.iterrows():
|
|
day = row['Day']
|
|
schedule[day] = []
|
|
|
|
# Process each period column...
|
|
# ... (all the CSV processing code) ...
|
|
return schedule
|
|
|
|
except FileNotFoundError:
|
|
print("❌ Error: schedule_template RS.csv file not found!")
|
|
print("Please make sure schedule_template RS.csv is in the same folder")
|
|
return {}
|
|
except Exception as e:
|
|
print(f"❌ Error loading schedule: {e}")
|
|
return {}</div>
|
|
<p>Also DELETE this line that loads the schedule:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
# Load schedule at startup
|
|
SCHEDULE = load_schedule()</div>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn4">Previous</button>
|
|
<button class="nav-btn" id="nextBtn5">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 5: Step-by-Step Guide - Part 3 -->
|
|
<div class="slide" id="slide5">
|
|
<h2>Step-by-Step Upgrade - Part 3</h2>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">6</div>
|
|
<strong>Add new database functions</strong>
|
|
<p>Where the old <code>load_schedule()</code> function was, ADD these new functions:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px; margin-bottom: 10px;">
|
|
def init_db():
|
|
"""Initialize the SQLite database and create tables if they don't exist."""
|
|
conn = sqlite3.connect(DATABASE_NAME)
|
|
cursor = conn.cursor()
|
|
|
|
# Create table for schedule entries
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS schedule (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
day TEXT NOT NULL,
|
|
period INTEGER NOT NULL,
|
|
subject TEXT NOT NULL,
|
|
class_name TEXT NOT NULL,
|
|
room TEXT NOT NULL,
|
|
UNIQUE(day, period)
|
|
)
|
|
''')
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
|
|
def add_schedule_entry(day, period, subject, class_name, room):
|
|
"""Add a new schedule entry to the database."""
|
|
conn = sqlite3.connect(DATABASE_NAME)
|
|
cursor = conn.cursor()
|
|
|
|
try:
|
|
cursor.execute('''
|
|
INSERT OR REPLACE INTO schedule (day, period, subject, class_name, room)
|
|
VALUES (?, ?, ?, ?, ?)
|
|
''', (day, period, subject, class_name, room))
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
return True
|
|
except sqlite3.Error as e:
|
|
print(f"Database error: {e}")
|
|
conn.close()
|
|
return False
|
|
|
|
def load_schedule_from_db():
|
|
"""Load schedule from the SQLite database."""
|
|
conn = sqlite3.connect(DATABASE_NAME)
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute("SELECT day, period, subject, class_name, room FROM schedule ORDER BY day, period")
|
|
rows = cursor.fetchall()
|
|
|
|
conn.close()
|
|
|
|
# Group by day
|
|
schedule = {}
|
|
for day, period, subject, class_name, room in rows:
|
|
if day not in schedule:
|
|
schedule[day] = []
|
|
|
|
class_info = f"Subject: {subject} Class: {class_name} Room: {room}"
|
|
schedule[day].append((str(period), class_info))
|
|
|
|
return schedule</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">7</div>
|
|
<strong>Initialize the database</strong>
|
|
<p>After the new functions, ADD this line:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
# Initialize the database
|
|
init_db()</div>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn5">Previous</button>
|
|
<button class="nav-btn" id="nextBtn6">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 6: Step-by-Step Guide - Part 4 -->
|
|
<div class="slide" id="slide6">
|
|
<h2>Step-by-Step Upgrade - Part 4</h2>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">8</div>
|
|
<strong>Update all command functions</strong>
|
|
<p>In EACH of these functions: <code>where_am_i()</code>, <code>schedule()</code>, and <code>tomorrow()</code>:</p>
|
|
|
|
<p><strong>FIND this check at the beginning:</strong></p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px; margin-bottom: 10px;">
|
|
if not SCHEDULE:
|
|
await update.message.reply_text("❌ Schedule not loaded. Check schedule_template RS.csv file.")
|
|
return</div>
|
|
|
|
<p><strong>REPLACE it with:</strong></p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px; margin-bottom: 10px;">
|
|
# Reload schedule from DB to ensure latest data
|
|
schedule = load_schedule_from_db()
|
|
|
|
if not schedule:
|
|
await update.message.reply_text("❌ Schedule not loaded from database.")
|
|
return</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">9</div>
|
|
<strong>Change all SCHEDULE references</strong>
|
|
<p>In each function, CHANGE every <code>SCHEDULE</code> to just <code>schedule</code> (lowercase):</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
# OLD: if current_day not in SCHEDULE:
|
|
# NEW:
|
|
if current_day not in schedule:
|
|
|
|
# OLD: for period_num, class_info in SCHEDULE[current_day]:
|
|
# NEW:
|
|
for period_num, class_info in schedule[current_day]:
|
|
|
|
# OLD: schedule_text = f"*{day}'s Schedule:*\n"
|
|
# OLD: if day in SCHEDULE and SCHEDULE[day]:
|
|
# NEW:
|
|
schedule_text = f"*{day}'s Schedule:*\n"
|
|
if day in schedule and schedule[day]:</div>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn6">Previous</button>
|
|
<button class="nav-btn" id="nextBtn7">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 7: Step-by-Step Guide - Part 5 -->
|
|
<div class="slide" id="slide7">
|
|
<h2>Step-by-Step Upgrade - Part 5</h2>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">10</div>
|
|
<strong>Add the new /add command function</strong>
|
|
<p>After your <code>tomorrow()</code> function, ADD this new function:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px; margin-bottom: 10px;">
|
|
async def add(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Start the process of adding a new schedule entry."""
|
|
user_id = update.effective_user.id
|
|
user_states[user_id] = {"step": "waiting_day"}
|
|
|
|
await update.message.reply_text(
|
|
"📅 Adding a new class to the schedule.\n"
|
|
"Please enter the day of the week (e.g., Monday, Tuesday, etc.):"
|
|
)</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">11</div>
|
|
<strong>Add the message handler function</strong>
|
|
<p>After the <code>add()</code> function, ADD this function:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Handle user messages during the add process."""
|
|
user_id = update.effective_user.id
|
|
|
|
if user_id not in user_states:
|
|
# Not in a conversation, ignore
|
|
return
|
|
|
|
state_info = user_states[user_id]
|
|
message_text = update.message.text.strip()
|
|
|
|
if state_info["step"] == "waiting_day":
|
|
# Validate day input
|
|
valid_days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
|
|
if message_text.lower() not in valid_days:
|
|
await update.message.reply_text(
|
|
f"'{message_text}' is not a valid day of the week.\n"
|
|
"Please enter a valid day (e.g., Monday, Tuesday, etc.):"
|
|
)
|
|
return
|
|
|
|
state_info["day"] = message_text.capitalize()
|
|
state_info["step"] = "waiting_period"
|
|
|
|
await update.message.reply_text(
|
|
f"Got it! Day: {state_info['day']}\n"
|
|
"Now please enter the period number (1-13):"
|
|
)
|
|
|
|
elif state_info["step"] == "waiting_period":
|
|
try:
|
|
period = int(message_text)
|
|
if period < 1 or period > 13:
|
|
raise ValueError("Period must be between 1 and 13")
|
|
|
|
state_info["period"] = period
|
|
state_info["step"] = "waiting_subject"
|
|
|
|
await update.message.reply_text(
|
|
f"Got it! Period: {period}\n"
|
|
"Now please enter the subject name:"
|
|
)
|
|
except ValueError:
|
|
await update.message.reply_text(
|
|
f"'{message_text}' is not a valid period number.\n"
|
|
"Please enter a number between 1 and 13:"
|
|
)
|
|
|
|
# ... continue with subject, class, and room steps ...
|
|
|
|
elif state_info["step"] == "waiting_room":
|
|
state_info["room"] = message_text
|
|
|
|
# Add to database
|
|
success = add_schedule_entry(
|
|
state_info["day"],
|
|
state_info["period"],
|
|
state_info["subject"],
|
|
state_info["class_name"],
|
|
message_text
|
|
)
|
|
|
|
if success:
|
|
await update.message.reply_text(
|
|
f"✅ Successfully added to schedule!\n\n"
|
|
f"Day: {state_info['day']}\n"
|
|
f"Period: {state_info['period']}\n"
|
|
f"Subject: {state_info['subject']}\n"
|
|
f"Class: {state_info['class_name']}\n"
|
|
f"Room: {state_info['room']}"
|
|
)
|
|
else:
|
|
await update.message.reply_text(
|
|
f"❌ Failed to add to schedule. Please try again."
|
|
)
|
|
|
|
# Clean up user state
|
|
del user_states[user_id]</div>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn7">Previous</button>
|
|
<button class="nav-btn" id="nextBtn8">Next</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 8: Step-by-Step Guide - Part 6 -->
|
|
<div class="slide" id="slide8">
|
|
<h2>Step-by-Step Upgrade - Part 6</h2>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">12</div>
|
|
<strong>Update the main() function</strong>
|
|
<p>In your <code>main()</code> function:</p>
|
|
|
|
<p><strong>DELETE these lines:</strong></p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px; margin-bottom: 10px;">
|
|
if not SCHEDULE:
|
|
print("❌ Failed to load schedule. Please check schedule_template RS.csv file.")
|
|
print("Make sure schedule_template RS.csv exists in the same folder")
|
|
return</div>
|
|
|
|
<p><strong>In the handler section, ADD these two lines:</strong></p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
# Add command handlers
|
|
application.add_handler(CommandHandler("start", start))
|
|
application.add_handler(CommandHandler("whereami", where_am_i))
|
|
application.add_handler(CommandHandler("schedule", schedule))
|
|
application.add_handler(CommandHandler("tomorrow", tomorrow))
|
|
application.add_handler(CommandHandler("add", add)) # ← ADD THIS LINE
|
|
application.add_handler(CommandHandler("help", help_command))
|
|
|
|
# Add message handler for conversation flow
|
|
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message)) # ← ADD THIS LINE</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">13</div>
|
|
<strong>Update the start message</strong>
|
|
<p>In your <code>start()</code> function, update the message to include the /add command:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
await update.message.reply_text(
|
|
"🤖 Hello! I'm your enhanced class scheduler bot with database support!\n"
|
|
"Use /whereami to find your current class\n"
|
|
"Use /schedule to see today's full schedule\n"
|
|
"Use /tomorrow to see tomorrow's schedule\n"
|
|
"Use /add to add a new class to the schedule\n" # ← ADDED THIS LINE
|
|
"Use /help for all commands"
|
|
)</div>
|
|
</div>
|
|
|
|
<div class="instruction-block">
|
|
<div class="step-number">14</div>
|
|
<strong>Update the help command</strong>
|
|
<p>In your <code>help_command()</code> function, add /add to the list:</p>
|
|
<div class="code-block" style="background: #4a5568; font-size: 0.9rem; padding: 10px;">
|
|
await update.message.reply_text(
|
|
"Available commands:\n"
|
|
"/start - Start the bot\n"
|
|
"/whereami - Find your current class\n"
|
|
"/schedule - Show today's full schedule\n"
|
|
"/tomorrow - Show tomorrow's schedule\n"
|
|
"/add - Add a new class to the schedule\n" # ← ADDED THIS LINE
|
|
"/help - Show this help message"
|
|
)</div>
|
|
</div>
|
|
|
|
<div class="nav-container">
|
|
<button class="nav-btn" id="prevBtn8">Previous</button>
|
|
<button class="nav-btn" id="nextBtn9">Finish</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const totalSlides = 8;
|
|
let currentSlide = 1;
|
|
|
|
function updateSlideCounter() {
|
|
document.getElementById('slide-counter').textContent = `Slide ${currentSlide} of ${totalSlides}`;
|
|
}
|
|
|
|
function showSlide(slideNumber) {
|
|
for (let i = 1; i <= totalSlides; i++) {
|
|
const slide = document.getElementById(`slide${i}`);
|
|
if (slide) slide.classList.remove('active');
|
|
}
|
|
|
|
const slideElement = document.getElementById(`slide${slideNumber}`);
|
|
if (slideElement) {
|
|
slideElement.classList.add('active');
|
|
currentSlide = slideNumber;
|
|
updateSlideCounter();
|
|
updateButtons();
|
|
}
|
|
}
|
|
|
|
function updateButtons() {
|
|
for (let i = 1; i <= totalSlides; i++) {
|
|
const prevBtn = document.getElementById(`prevBtn${i}`);
|
|
const nextBtn = document.getElementById(`nextBtn${i}`);
|
|
if (prevBtn) prevBtn.disabled = currentSlide === 1;
|
|
if (nextBtn) {
|
|
nextBtn.textContent = currentSlide === totalSlides ? 'Finish' : 'Next';
|
|
}
|
|
}
|
|
}
|
|
|
|
for (let i = 1; i <= totalSlides; i++) {
|
|
const nextBtn = document.getElementById(`nextBtn${i}`);
|
|
const prevBtn = document.getElementById(`prevBtn${i}`);
|
|
|
|
if (nextBtn) {
|
|
nextBtn.addEventListener('click', () => {
|
|
if (currentSlide < totalSlides) {
|
|
showSlide(currentSlide + 1);
|
|
} else {
|
|
alert('Congratulations! You have upgraded your Scheduler Bot from CSV to SQLite database. Your bot now has dynamic schedule management!');
|
|
}
|
|
});
|
|
}
|
|
|
|
if (prevBtn) {
|
|
prevBtn.addEventListener('click', () => {
|
|
if (currentSlide > 1) {
|
|
showSlide(currentSlide - 1);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'ArrowRight' || e.key === ' ') {
|
|
if (currentSlide < totalSlides) showSlide(currentSlide + 1);
|
|
} else if (e.key === 'ArrowLeft') {
|
|
if (currentSlide > 1) showSlide(currentSlide - 1);
|
|
}
|
|
});
|
|
|
|
updateSlideCounter();
|
|
updateButtons();
|
|
</script>
|
|
|
|
</div>
|
|
<div class="document-separator" id="doc-5"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">5. Student Database Search System Beginner's Guide</h2>
|
|
<div class="document-source">Source file: Student Database Search System _ Beginner's Guide.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="presentation-container">
|
|
<!-- Slide 1: Title -->
|
|
<div class="slide active" id="slide1">
|
|
<div class="title-slide">
|
|
<div>
|
|
<h1 class="thesis-title">Student Database Search System</h1>
|
|
<p class="thesis-subtitle">From Excel to Database - A Beginner's Journey</p>
|
|
</div>
|
|
|
|
<div class="author-info" style="margin-top: 50px; padding-top: 30px; border-top: 2px solid #e0e6ed; width: 100%; max-width: 600px;">
|
|
<p><strong>Goal:</strong> Build a working search system in 1 hour</p>
|
|
<p><strong>Prerequisites:</strong> No database experience needed!</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 2: What is a Relational Database? -->
|
|
<div class="slide" id="slide2">
|
|
<h1>What Is a Relational Database?</h1>
|
|
<p class="lead">Beginner's Guide to Understanding Database Fundamentals</p>
|
|
|
|
<div class="feature-box">
|
|
<h3>You'll Learn:</h3>
|
|
<div class="feature-item">
|
|
<div class="feature-number">1</div>
|
|
<div>What tables, fields, records, and keys are</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">2</div>
|
|
<div>How relationships connect data across tables</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">3</div>
|
|
<div>Why primary keys and foreign keys are critical</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">4</div>
|
|
<div>The role of SQL (Structured Query Language)</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">5</div>
|
|
<div>Real-world examples in banks, hospitals, and apps</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="database-concept">
|
|
<span class="concept-title">Think of it like this:</span>
|
|
<p>A relational database is like a digital filing cabinet with labeled folders (tables) that are connected to each other.</p>
|
|
<p>Each folder contains specific information that can be linked to other folders.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 3: Watch Learning Video -->
|
|
<div class="slide" id="slide3">
|
|
<h2>Let's Watch and Learn</h2>
|
|
<p class="lead">Take 10 minutes to understand relational databases</p>
|
|
|
|
<div class="video-container">
|
|
<h3>What Is a Relational Database? | Beginner's Guide</h3>
|
|
<p>By Knewget (30.3K subscribers)</p>
|
|
|
|
<a href="https://www.youtube.com/watch?v=zDNAOM6Mx4E" target="_blank" class="video-link">
|
|
▶ Watch Video on YouTube
|
|
</a>
|
|
|
|
<p style="margin-top: 20px; color: #666;">
|
|
This video explains everything you need to know about databases in plain English.
|
|
Perfect for beginners!
|
|
</p>
|
|
</div>
|
|
|
|
<div class="feature-box">
|
|
<h3>Key Takeaways:</h3>
|
|
<div class="feature-item">
|
|
<div class="feature-number">✓</div>
|
|
<div><strong>Tables</strong> = Excel sheets with rows and columns</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">✓</div>
|
|
<div><strong>Rows</strong> = Individual records (like a student)</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">✓</div>
|
|
<div><strong>Columns</strong> = Fields of information (name, grade, etc.)</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">✓</div>
|
|
<div><strong>Primary Key</strong> = Unique ID for each row</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">✓</div>
|
|
<div><strong>Foreign Key</strong> = Link to another table</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 4: Our Project - What We're Building -->
|
|
<div class="slide" id="slide4">
|
|
<h2>Our 1-Hour MVP Project</h2>
|
|
<p class="lead">Simple Python program to search student schedules</p>
|
|
|
|
<div class="database-concept">
|
|
<span class="concept-title">Current Problem:</span>
|
|
<p>School data is in messy Excel sheets that are hard to search.</p>
|
|
<p>We need to find information quickly!</p>
|
|
</div>
|
|
|
|
<h3>Search Examples We'll Build:</h3>
|
|
<div class="feature-box">
|
|
<div class="feature-item">
|
|
<div class="feature-number">1</div>
|
|
<div>
|
|
<strong>Find homeroom teacher:</strong><br>
|
|
"Who is the homeroom teacher for student Alex?"
|
|
</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">2</div>
|
|
<div>
|
|
<strong>Find students in a subject:</strong><br>
|
|
"Show me all students in Math class 4A"
|
|
</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">3</div>
|
|
<div>
|
|
<strong>Simple database search:</strong><br>
|
|
"Search for any information across all sheets"
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 5: Step 1 - Setup -->
|
|
<div class="slide" id="slide5">
|
|
<h2>Step 1: Setup (5 minutes)</h2>
|
|
|
|
<div class="code-block"><span class="code-comment"># 1. Create a new file called "school_search.py"</span>
|
|
<span class="code-comment"># 2. Open it in any text editor</span>
|
|
<span class="code-comment"># 3. Start with this basic setup:</span>
|
|
|
|
<span class="code-keyword">import</span> pandas <span class="code-keyword">as</span> pd
|
|
|
|
<span class="code-keyword">def</span> <span class="code-function">main</span>():
|
|
<span class="code-comment"># Main function - everything starts here</span>
|
|
print(<span class="code-string">"=== School Search System ==="</span>)
|
|
|
|
<span class="code-comment"># Load our Excel file</span>
|
|
file_path = <span class="code-string">"school_data.xlsx"</span>
|
|
|
|
<span class="code-keyword">try</span>:
|
|
<span class="code-comment"># Read the Excel file</span>
|
|
excel_file = pd.ExcelFile(file_path)
|
|
print(<span class="code-string">f"Success! Found </span>{len(excel_file.sheet_names)}<span class="code-string"> sheets"</span>)
|
|
<span class="code-keyword">return</span> excel_file
|
|
<span class="code-keyword">except</span> Exception <span class="code-keyword">as</span> e:
|
|
print(<span class="code-string">f"Error: </span>{e}<span class="code-string">"</span>)
|
|
<span class="code-keyword">return</span> <span class="code-keyword">None</span>
|
|
|
|
<span class="code-keyword">if</span> __name__ == <span class="code-string">"__main__"</span>:
|
|
main()</div>
|
|
|
|
<div class="feature-box">
|
|
<h3>To Install Required Libraries:</h3>
|
|
<div class="code-block" style="margin: 10px 0; padding: 15px; background: #2c3e50;"><span class="code-comment"># Open Command Prompt or Terminal and type:</span>
|
|
pip install pandas</div>
|
|
<p>That's it! Pandas will help us read Excel files easily.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 6: Step 2 - Simple Search Function -->
|
|
<div class="slide" id="slide6">
|
|
<h2>Step 2: Create Search Function (15 minutes)</h2>
|
|
|
|
<div class="code-block"><span class="code-comment"># Add this function to your file (under the imports)</span>
|
|
|
|
<span class="code-keyword">def</span> <span class="code-function">simple_search</span>(excel_file, search_term):
|
|
<span class="code-comment">"""Search for any term across all sheets"""</span>
|
|
results = []
|
|
|
|
<span class="code-keyword">for</span> sheet_name <span class="code-keyword">in</span> excel_file.sheet_names:
|
|
<span class="code-comment"># Read each sheet</span>
|
|
df = pd.read_excel(excel_file, sheet_name=sheet_name)
|
|
|
|
<span class="code-comment"># Search in all cells</span>
|
|
<span class="code-keyword">for</span> row_idx, row <span class="code-keyword">in</span> df.iterrows():
|
|
<span class="code-keyword">for</span> col_name, cell_value <span class="code-keyword">in</span> row.items():
|
|
<span class="code-keyword">if</span> pd.notna(cell_value):
|
|
<span class="code-keyword">if</span> search_term.lower() <span class="code-keyword">in</span> str(cell_value).lower():
|
|
results.append({
|
|
<span class="code-string">'sheet'</span>: sheet_name,
|
|
<span class="code-string">'row'</span>: row_idx + 2, <span class="code-comment"># Excel row number</span>
|
|
<span class="code-string">'column'</span>: col_name,
|
|
<span class="code-string">'value'</span>: str(cell_value)
|
|
})
|
|
|
|
<span class="code-keyword">return</span> results</div>
|
|
|
|
<h3>Update Your Main Function:</h3>
|
|
<div class="code-block"><span class="code-keyword">def</span> <span class="code-function">main</span>():
|
|
print(<span class="code-string">"=== School Search System ==="</span>)
|
|
|
|
<span class="code-comment"># Load data</span>
|
|
data = pd.ExcelFile(<span class="code-string">"school_data.xlsx"</span>)
|
|
|
|
<span class="code-comment"># Test search</span>
|
|
print(<span class="code-string">"\nSearching for 'Math'..."</span>)
|
|
math_results = simple_search(data, <span class="code-string">"Math"</span>)
|
|
|
|
<span class="code-keyword">for</span> result <span class="code-keyword">in</span> math_results[:5]: <span class="code-comment"># Show first 5 results</span>
|
|
print(<span class="code-string">f"Found in </span>{result['sheet']}<span class="code-string">, row </span>{result['row']}<span class="code-string">: </span>{result['value']}<span class="code-string">"</span>)
|
|
|
|
print(<span class="code-string">f"\nTotal found: </span>{len(math_results)}<span class="code-string"> results"</span>)</div>
|
|
</div>
|
|
|
|
<!-- Slide 7: Step 3 - Specific Searches -->
|
|
<div class="slide" id="slide7">
|
|
<h2>Step 3: Add Specific Searches (15 minutes)</h2>
|
|
|
|
<div class="code-block"><span class="code-comment"># Function to find homeroom teacher</span>
|
|
<span class="code-keyword">def</span> <span class="code-function">find_teacher</span>(excel_file, student_name):
|
|
<span class="code-comment">"""Find homeroom teacher for a student"""</span>
|
|
|
|
<span class="code-keyword">for</span> sheet_name <span class="code-keyword">in</span> excel_file.sheet_names:
|
|
df = pd.read_excel(excel_file, sheet_name=sheet_name)
|
|
|
|
<span class="code-comment"># Look for student name</span>
|
|
<span class="code-keyword">for</span> idx, row <span class="code-keyword">in</span> df.iterrows():
|
|
<span class="code-keyword">for</span> cell_value <span class="code-keyword">in</span> row.values:
|
|
<span class="code-keyword">if</span> pd.notna(cell_value) <span class="code-keyword">and</span> student_name <span class="code-keyword">in</span> str(cell_value):
|
|
<span class="code-comment"># Check if teacher info is in same row</span>
|
|
<span class="code-keyword">for</span> col <span class="code-keyword">in</span> df.columns:
|
|
<span class="code-keyword">if</span> <span class="code-string">"teacher"</span> <span class="code-keyword">in</span> str(col).lower() <span class="code-keyword">or</span> <span class="code-string">"преподаватель"</span> <span class="code-keyword">in</span> str(col).lower():
|
|
<span class="code-keyword">if</span> pd.notna(row[col]):
|
|
<span class="code-keyword">return</span> row[col]
|
|
|
|
<span class="code-keyword">return</span> <span class="code-string">"Teacher not found"</span></div>
|
|
|
|
<div class="code-block"><span class="code-comment"># Function to find students by class</span>
|
|
<span class="code-keyword">def</span> <span class="code-function">find_students_in_class</span>(excel_file, class_name):
|
|
<span class="code-comment">"""Find all students in a specific class (like 4A)"""</span>
|
|
students = []
|
|
|
|
<span class="code-keyword">for</span> sheet_name <span class="code-keyword">in</span> excel_file.sheet_names:
|
|
df = pd.read_excel(excel_file, sheet_name=sheet_name)
|
|
|
|
<span class="code-keyword">for</span> idx, row <span class="code-keyword">in</span> df.iterrows():
|
|
<span class="code-keyword">for</span> cell_value <span class="code-keyword">in</span> row.values:
|
|
<span class="code-keyword">if</span> pd.notna(cell_value) <span class="code-keyword">and</span> class_name <span class="code-keyword">in</span> str(cell_value):
|
|
<span class="code-comment"># Look for student names in this row</span>
|
|
<span class="code-keyword">for</span> col <span class="code-keyword">in</span> df.columns:
|
|
<span class="code-keyword">if</span> <span class="code-string">"name"</span> <span class="code-keyword">in</span> str(col).lower() <span class="code-keyword">or</span> <span class="code-string">"фио"</span> <span class="code-keyword">in</span> str(col).lower():
|
|
<span class="code-keyword">if</span> pd.notna(row[col]):
|
|
students.append(row[col])
|
|
|
|
<span class="code-keyword">return</span> list(set(students)) <span class="code-comment"># Remove duplicates</span></div>
|
|
</div>
|
|
|
|
<!-- Slide 8: Step 4 - Complete Program -->
|
|
<div class="slide" id="slide8">
|
|
<h2>Step 4: Complete Program (10 minutes)</h2>
|
|
|
|
<div class="code-block"><span class="code-comment"># school_search.py - COMPLETE PROGRAM</span>
|
|
|
|
<span class="code-keyword">import</span> pandas <span class="code-keyword">as</span> pd
|
|
|
|
<span class="code-comment"># [PASTE ALL FUNCTIONS FROM PREVIOUS SLIDES HERE]</span>
|
|
<span class="code-comment"># 1. simple_search() function</span>
|
|
<span class="code-comment"># 2. find_teacher() function</span>
|
|
<span class="code-comment"># 3. find_students_in_class() function</span>
|
|
|
|
<span class="code-keyword">def</span> <span class="code-function">main</span>():
|
|
<span class="code-comment"># 1. Load the data</span>
|
|
print(<span class="code-string">"=== Student Database Search ==="</span>)
|
|
|
|
<span class="code-keyword">try</span>:
|
|
<span class="code-comment"># Change this to your actual file name</span>
|
|
data = pd.ExcelFile(<span class="code-string">"Распределение по группам Технолицей 2025_2026 - 4.xlsx"</span>)
|
|
print(<span class="code-string">f"✓ Loaded: </span>{len(data.sheet_names)}<span class="code-string"> sheets"</span>)
|
|
<span class="code-keyword">except</span>:
|
|
print(<span class="code-string">"✗ Error: Make sure the Excel file is in the same folder!"</span>)
|
|
<span class="code-keyword">return</span>
|
|
|
|
<span class="code-comment"># 2. Example searches</span>
|
|
print(<span class="code-string">"\n--- Example 1: Find Teacher ---"</span>)
|
|
teacher = find_teacher(data, <span class="code-string">"Арефьев"</span>)
|
|
print(<span class="code-string">f"Homeroom teacher: </span>{teacher}<span class="code-string">"</span>)
|
|
|
|
print(<span class="code-string">"\n--- Example 2: Find Students ---"</span>)
|
|
students = find_students_in_class(data, <span class="code-string">"4A"</span>)
|
|
print(<span class="code-string">f"Students in 4A: </span>{len(students)}<span class="code-string"> found"</span>)
|
|
<span class="code-keyword">for</span> student <span class="code-keyword">in</span> students[:3]: <span class="code-comment"># Show first 3</span>
|
|
print(<span class="code-string">f" • </span>{student}<span class="code-string">"</span>)
|
|
|
|
print(<span class="code-string">"\n--- Example 3: General Search ---"</span>)
|
|
results = simple_search(data, <span class="code-string">"Math"</span>)
|
|
print(<span class="code-string">f"Found 'Math' </span>{len(results)}<span class="code-string"> times"</span>)
|
|
|
|
print(<span class="code-string">"\n=== Search Complete ==="</span>)
|
|
|
|
<span class="code-keyword">if</span> __name__ == <span class="code-string">"__main__"</span>:
|
|
main()</div>
|
|
|
|
<div class="feature-box">
|
|
<h3>How to Run:</h3>
|
|
<div class="feature-item">
|
|
<div class="feature-number">1</div>
|
|
<div>Save all code in "school_search.py"</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">2</div>
|
|
<div>Put your Excel file in same folder</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">3</div>
|
|
<div>Open terminal in that folder</div>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-number">4</div>
|
|
<div>Type: <code>python school_search.py</code></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Slide 9: Next Steps & Database Connection -->
|
|
<div class="slide" id="slide9">
|
|
<h2>Next Step: Real Database</h2>
|
|
<p class="lead">Moving from Excel to SQLite database</p>
|
|
|
|
<div class="code-block"><span class="code-comment"># Simple SQLite database setup (future enhancement)</span>
|
|
<span class="code-keyword">import</span> sqlite3
|
|
|
|
<span class="code-keyword">def</span> <span class="code-function">create_database</span>():
|
|
<span class="code-comment"># Connect to database (creates if doesn't exist)</span>
|
|
conn = sqlite3.connect(<span class="code-string">'school.db'</span>)
|
|
cursor = conn.cursor()
|
|
|
|
<span class="code-comment"># Create tables (like in the video!)</span>
|
|
cursor.execute(<span class="code-string">'''CREATE TABLE IF NOT EXISTS students (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
grade TEXT,
|
|
class TEXT,
|
|
homeroom_teacher_id INTEGER
|
|
)'''</span>)
|
|
|
|
cursor.execute(<span class="code-string">'''CREATE TABLE IF NOT EXISTS teachers (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
subject TEXT
|
|
)'''</span>)
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
print(<span class="code-string">"Database created successfully!"</span>)</div>
|
|
|
|
<div class="database-concept">
|
|
<span class="concept-title">Database vs Excel:</span>
|
|
<p><strong>Excel:</strong> Good for viewing, bad for searching</p>
|
|
<p><strong>Database:</strong> Fast searching, relationships, scalable</p>
|
|
</div>
|
|
|
|
<div class="feature-box">
|
|
<h3>Your 1-Hour MVP is Complete!</h3>
|
|
<p>You've built a working search system that can:</p>
|
|
<p>• Search across all Excel sheets</p>
|
|
<p>• Find teachers for students</p>
|
|
<p>• List students in classes</p>
|
|
<p>• Be extended to a real database</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Navigation -->
|
|
<div class="navigation">
|
|
<button class="nav-btn" id="prev-btn" onclick="prevSlide()" disabled="">← Back</button>
|
|
|
|
<div class="slide-counter">
|
|
<span id="current-slide">1</span> of <span id="total-slides">9</span>
|
|
</div>
|
|
|
|
<button class="nav-btn" id="next-btn" onclick="nextSlide()">Next →</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let currentSlide = 1;
|
|
const totalSlides = 9;
|
|
|
|
function showSlide(slideNumber) {
|
|
document.querySelectorAll('.slide').forEach(slide => {
|
|
slide.classList.remove('active');
|
|
});
|
|
|
|
document.getElementById(`slide${slideNumber}`).classList.add('active');
|
|
document.getElementById(`slide${slideNumber}`).scrollTop = 0;
|
|
|
|
document.getElementById('current-slide').textContent = slideNumber;
|
|
|
|
document.getElementById('prev-btn').disabled = slideNumber === 1;
|
|
document.getElementById('next-btn').disabled = slideNumber === totalSlides;
|
|
|
|
if (slideNumber === totalSlides) {
|
|
document.getElementById('next-btn').textContent = 'Finish';
|
|
} else {
|
|
document.getElementById('next-btn').textContent = 'Next →';
|
|
}
|
|
}
|
|
|
|
function nextSlide() {
|
|
if (currentSlide < totalSlides) {
|
|
currentSlide++;
|
|
showSlide(currentSlide);
|
|
}
|
|
}
|
|
|
|
function prevSlide() {
|
|
if (currentSlide > 1) {
|
|
currentSlide--;
|
|
showSlide(currentSlide);
|
|
}
|
|
}
|
|
|
|
// Initialize
|
|
showSlide(1);
|
|
|
|
// Keyboard navigation
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'ArrowRight' || e.key === ' ' || e.key === 'Enter') {
|
|
nextSlide();
|
|
} else if (e.key === 'ArrowLeft') {
|
|
prevSlide();
|
|
}
|
|
});
|
|
|
|
// Touch swipe for mobile
|
|
let touchStartY = 0;
|
|
let touchEndY = 0;
|
|
|
|
document.addEventListener('touchstart', (e) => {
|
|
touchStartY = e.changedTouches[0].screenY;
|
|
});
|
|
|
|
document.addEventListener('touchend', (e) => {
|
|
touchEndY = e.changedTouches[0].screenY;
|
|
const swipeThreshold = 100;
|
|
|
|
if (touchEndY < touchStartY - swipeThreshold) {
|
|
nextSlide();
|
|
}
|
|
|
|
if (touchEndY > touchStartY + swipeThreshold) {
|
|
prevSlide();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</div>
|
|
<div class="document-separator" id="doc-6"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">6. Thesis Intelligent School Schedule Management System 23 Jan 2026</h2>
|
|
<div class="document-source">Source file: Thesis_ Intelligent School Schedule Management System_23_Jan_2026.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="container">
|
|
<header>
|
|
<h1>Thesis: Intelligent School Schedule Management System</h1>
|
|
<p class="subtitle">From Simple Chat Bot to Comprehensive Database-Powered Solution</p>
|
|
</header>
|
|
|
|
<section>
|
|
<p>This project evolved from a simple chat assistant into a comprehensive school schedule management system. It began as a Telegram bot that tells students what class they have and when, and has grown to handle complex school scheduling with multiple layers of data organization.</p>
|
|
|
|
<div class="highlight-box">
|
|
<h3>The Evolution</h3>
|
|
<p>What started as a friendly robot in your phone that knows your class schedule has transformed into a sophisticated database system capable of managing complex school timetables with multiple tracks, groups, and modules.</p>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>What It Does</h2>
|
|
<p>The system now serves as a complete personal assistant for complex school timetables. Here are all the things it can do:</p>
|
|
|
|
<div class="command-list">
|
|
<div class="command-item">
|
|
<div class="command-name">/start</div>
|
|
<div class="command-desc">Introduces the system and explains its capabilities</div>
|
|
</div>
|
|
|
|
<div class="command-item">
|
|
<div class="command-name">/whereami</div>
|
|
<div class="command-desc">Checks current time and tells which class or activity a student should be attending</div>
|
|
</div>
|
|
|
|
<div class="command-item">
|
|
<div class="command-name">/schedule</div>
|
|
<div class="command-desc">Displays all classes and activities for today in chronological order</div>
|
|
</div>
|
|
|
|
<div class="command-item">
|
|
<div class="command-name">/tomorrow</div>
|
|
<div class="command-desc">Shows tomorrow's complete schedule for advance preparation</div>
|
|
</div>
|
|
|
|
<div class="command-item">
|
|
<div class="command-name">/add</div>
|
|
<div class="command-desc">Allows administrators to add new schedule entries dynamically</div>
|
|
</div>
|
|
|
|
<div class="command-item">
|
|
<div class="command-name">Database Queries</div>
|
|
<div class="command-desc">Advanced queries for student groups, teacher schedules, and room allocations</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="data-analysis">
|
|
<h2>Data Analysis: Understanding Complex School Schedules</h2>
|
|
|
|
<p>After analyzing real school schedule spreadsheets, we discovered that school timetables are far more complex than simple period-by-period schedules. Here's what we found:</p>
|
|
|
|
<h3>Key Insights from School Schedule Data:</h3>
|
|
|
|
<div class="data-point">
|
|
<strong>Complex Groupings</strong>: Students belong to multiple overlapping group systems simultaneously:
|
|
</div>
|
|
<div style="padding-left: 40px; margin-bottom: 15px;">
|
|
• Whole class activities (entire 4A, 4B, 4C together)<br>
|
|
• Split groups (Group 1, Group 2 for specialized subjects)<br>
|
|
• English level groups (E1-E6 based on proficiency)<br>
|
|
• Special tracks (Design & Creativity, Culinary, Industrial, etc.)<br>
|
|
• Olympiad and competition groups<br>
|
|
• Speaking clubs and extracurricular activities
|
|
</div>
|
|
|
|
<div class="data-point">
|
|
<strong>Temporal Structure</strong>: Two modules (terms) with potentially different schedules and groupings
|
|
</div>
|
|
|
|
<div class="data-point">
|
|
<strong>Multiple Dimensions</strong>: Each student has multiple simultaneous affiliations:
|
|
</div>
|
|
<div style="padding-left: 40px; margin-bottom: 15px;">
|
|
• Primary class (4A, 4B, 4C)<br>
|
|
• English group (E1-E6)<br>
|
|
• Technology track group<br>
|
|
• Olympiad participation<br>
|
|
• Speaking club assignment
|
|
</div>
|
|
|
|
<div class="data-point">
|
|
<strong>Teacher Assignments</strong>: Different teachers for different subjects, with some handling multiple groups
|
|
</div>
|
|
|
|
<div class="data-point">
|
|
<strong>Room Management</strong>: Specific rooms for specific activities, some shared across groups
|
|
</div>
|
|
</section>
|
|
|
|
<section class="db-schema">
|
|
<h2>Recommended Database Schema</h2>
|
|
|
|
<p>To handle this complexity, we designed a comprehensive database structure with 11 interconnected tables:</p>
|
|
|
|
<div class="table-list">
|
|
<div class="table-item">
|
|
<div class="table-name">students</div>
|
|
<div class="table-desc">Student personal information and class assignments</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">teachers</div>
|
|
<div class="table-desc">Teacher information and department assignments</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">subjects</div>
|
|
<div class="table-desc">All subjects and tracks offered by the school</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">classes</div>
|
|
<div class="table-desc">Class information and homeroom teacher assignments</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">rooms</div>
|
|
<div class="table-desc">Room availability and capacity information</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">timeslots</div>
|
|
<div class="table-desc">Day and period time definitions</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">schedule_entries</div>
|
|
<div class="table-desc">Main scheduling table connecting all elements</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">student_subjects</div>
|
|
<div class="table-desc">Which students take which subjects</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">student_groups</div>
|
|
<div class="table-desc">Student assignments to specific activity groups</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">tech_tracks</div>
|
|
<div class="table-desc">Technological track specialization assignments</div>
|
|
</div>
|
|
|
|
<div class="table-item">
|
|
<div class="table-name">special_groups</div>
|
|
<div class="table-desc">Olympiad, programming, and special interest groups</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h3>Core Database Structure:</h3>
|
|
|
|
<div class="diagram-container">
|
|
<div class="diagram-title">Entity-Relationship Diagram</div>
|
|
<div class="diagram">
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ CORE SCHEDULING STRUCTURE │
|
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ <span class="entity">students</span> <span class="cardinality">(1)</span> ────────────────────────────────────────────────┐ │
|
|
│ <span class="entity">teachers</span> <span class="cardinality">(1)</span> ────────────────────────────────────────────────┤ │
|
|
│ <span class="entity">subjects</span> <span class="cardinality">(1)</span> ────────────────────────────────────────────────┼──────┐ │
|
|
│ <span class="entity">rooms</span> <span class="cardinality">(1)</span> ──────────────────────────────────────────────────┤ │ │
|
|
│ <span class="entity">classes</span> <span class="cardinality">(1)</span> ─────────────────────────────────────────────────┤ │ │
|
|
│ <span class="entity">timeslots</span> <span class="cardinality">(1)</span> ────────────────────────────────────────────────┘ │ │
|
|
│ │ │ │
|
|
│ ▼ ▼ ▼ │
|
|
│ <span class="entity">schedule_entries</span> <span class="cardinality">(many)</span> │
|
|
│ │
|
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
│ STUDENT SPECIALIZATION STRUCTURE │
|
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ <span class="entity">students</span> <span class="cardinality">(1)</span> ────── <span class="relationship">student_subjects</span> <span class="cardinality">(many)</span> ────── <span class="entity">subjects</span> <span class="cardinality">(1)</span> │
|
|
│ │
|
|
│ <span class="entity">students</span> <span class="cardinality">(1)</span> ────── <span class="relationship">student_groups</span> <span class="cardinality">(many)</span> ─────── <span class="entity">groups</span> <span class="cardinality">(1)</span> │
|
|
│ │
|
|
│ <span class="entity">students</span> <span class="cardinality">(1)</span> ────── <span class="relationship">tech_tracks</span> <span class="cardinality">(many)</span> ────────── <span class="entity">tracks</span> <span class="cardinality">(1)</span> │
|
|
│ │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
</div>
|
|
|
|
<div class="legend">
|
|
<div class="legend-item">
|
|
<div class="legend-color entity-color"></div>
|
|
<span>Entity (Database Table)</span>
|
|
</div>
|
|
<div class="legend-item">
|
|
<div class="legend-color relationship-color"></div>
|
|
<span>Relationship (Junction Table)</span>
|
|
</div>
|
|
<div class="legend-item">
|
|
<div class="legend-color cardinality-color"></div>
|
|
<span>Cardinality (1:1, 1:many, many:1)</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<p style="margin-top: 20px;">This normalized structure allows for efficient querying of complex relationships while maintaining data integrity and avoiding duplication. The core <span class="entity">schedule_entries</span> table connects all major entities, while specialized tables handle the complex group assignments that characterize modern school schedules.</p>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>How It Works (System Architecture)</h2>
|
|
|
|
<div class="how-it-works">
|
|
<p>The entire system is designed to be scalable and maintainable. Here's how it all comes together:</p>
|
|
|
|
<div class="step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h3>Data Import and Storage</h3>
|
|
<p>The system imports complex school schedules from multiple Excel sheets into a structured SQLite database. Each spreadsheet (representing different grades or modules) is parsed and stored in the appropriate tables with proper relationships.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h3>Intelligent Query Processing</h3>
|
|
<p>When a student asks "Where am I?", the system checks multiple dimensions: current time, day, the student's class, their English group, their technology track, and any special group assignments to determine their exact location.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h3>Multi-Dimensional Scheduling</h3>
|
|
<p>The system understands that students have multiple simultaneous schedules: core class schedule, English group schedule, track activities, and extracurricular activities. It combines these to give a complete picture.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="step">
|
|
<div class="step-number">4</div>
|
|
<div class="step-content">
|
|
<h3>Dynamic Updates and Management</h3>
|
|
<p>Administrators can update schedules in real-time. The system handles changes gracefully, updating all related records while maintaining data consistency across all tables.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>The Innovation</h2>
|
|
<p>This project demonstrates how a simple concept can evolve into a sophisticated system through careful analysis of real-world data. We discovered that school scheduling is not just about "period 1, period 2" but involves complex overlapping group systems, multiple modules, and specialized tracks.</p>
|
|
|
|
<p>The key innovation is in recognizing and modeling these complex relationships in a way that's both efficient for the database and intuitive for users. The system doesn't just tell students "you have math now" - it understands that Student A from 4A in English group E3 doing the Design & Creativity track should be in Room 204 with Teacher Smith for their specialized session.</p>
|
|
|
|
<div class="conclusion">
|
|
<h3>Future Directions</h3>
|
|
<p>This foundation opens up numerous possibilities:</p>
|
|
<ul style="margin: 15px 0 15px 20px;">
|
|
<li><strong>Advanced Analytics</strong>: Track room utilization, teacher workload, and student participation patterns</li>
|
|
<li><strong>Conflict Detection</strong>: Automatically identify scheduling conflicts before they occur</li>
|
|
<li><strong>Parent Portal</strong>: Allow parents to view their children's schedules and receive updates</li>
|
|
<li><strong>Mobile Integration</strong>: Push notifications for schedule changes and reminders</li>
|
|
<li><strong>AI Optimization</strong>: Use machine learning to optimize schedules based on historical data</li>
|
|
</ul>
|
|
<p style="margin-top: 15px;">This project shows that even the most complex real-world systems can be modeled effectively with careful database design and thoughtful user interfaces.</p>
|
|
</div>
|
|
</section>
|
|
|
|
<footer>
|
|
<p>Intelligent School Schedule Management System Thesis</p>
|
|
<p>Demonstrating the evolution from simple chat bot to comprehensive database solution</p>
|
|
<p>© 2024 - Analysis based on real school scheduling data</p>
|
|
</footer>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="document-separator" id="doc-7"></div>
|
|
<div class="document-header">
|
|
<h2 class="document-title">7. Thesis AI7 Building A Scheduler Bot A Student Project</h2>
|
|
<div class="document-source">Source file: Thesis_AI7_Building_A_ Scheduler_Bot_A Student Project.html</div>
|
|
</div>
|
|
<div class="document-content">
|
|
|
|
<div class="container">
|
|
<header>
|
|
<h1>Thesis: Advanced Telegram Scheduler Bot</h1>
|
|
</header>
|
|
|
|
<div class="project-team">
|
|
<div class="supervisor">Supervisor: Bob Santos</div>
|
|
<div class="developers">Developer: Березуцкий Григорий</div>
|
|
</div>
|
|
|
|
<section>
|
|
<h2>Introduction</h2>
|
|
<p>This project created an advanced version of a class schedule helper bot for Telegram. The bot helps students by providing detailed schedule information through a messaging app. Unlike simple bots, this version can handle weekly schedules, multiple commands, and loads schedule data from an external file that can be easily updated by teachers or administrators.</p>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Aim</h2>
|
|
<p>The goal was to create a more sophisticated scheduling tool that could:</p>
|
|
<ul>
|
|
<li>Load schedule data from a CSV file that's easy to edit without changing code</li>
|
|
<li>Handle full weekly schedules with different classes each day</li>
|
|
<li>Provide multiple helpful commands for students</li>
|
|
<li>Show both current class information and full daily schedules</li>
|
|
<li>Work with real class timings for a complete school day</li>
|
|
<li>Make schedule updates simple for teachers and administrators</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Method</h2>
|
|
|
|
<div class="how-it-works">
|
|
<p>The development followed these key steps:</p>
|
|
|
|
<div class="step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h3>Design Schedule Structure</h3>
|
|
<p>Created a CSV file format that teachers can easily edit using programs like Excel or Google Sheets. The file includes days of the week and multiple class periods.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h3>Build File Loading System</h3>
|
|
<p>Used the pandas library to read and process the CSV file, converting it into a schedule that the bot can understand and use.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h3>Create Multiple Commands</h3>
|
|
<p>Built different functions for each command: /start, /whereami, /schedule, /tomorrow, and /help to provide a complete scheduling assistant.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="step">
|
|
<div class="step-number">4</div>
|
|
<div class="step-content">
|
|
<h3>Implement Time Logic</h3>
|
|
<p>Created a system that understands both the current day of the week and the exact time, matching them with the appropriate class period.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Results</h2>
|
|
<p>The project successfully created a feature-rich scheduling bot:</p>
|
|
|
|
<div class="feature-list">
|
|
<div class="feature-item">
|
|
<div class="feature-title">📂 File-Based Schedule</div>
|
|
<p>Schedule stored in CSV file that can be edited without touching the code. Teachers can update using familiar spreadsheet software.</p>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-title">🗓️ Weekly Scheduling</div>
|
|
<p>Handles different schedules for each day of the week (Monday-Friday), with up to 7 class periods per day.</p>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-title">🔍 Multiple Commands</div>
|
|
<p>Five useful commands: /start, /whereami, /schedule, /tomorrow, and /help to meet different student needs.</p>
|
|
</div>
|
|
|
|
<div class="feature-item">
|
|
<div class="feature-title">⏰ Real Class Times</div>
|
|
<p>Accurate timing system with proper start and end times for each period throughout the school day.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="highlight-box">
|
|
<h3>Bot Commands in Action</h3>
|
|
<ul>
|
|
<li><strong>/start</strong>: Welcomes users and explains available commands</li>
|
|
<li><strong>/whereami</strong>: Tells students exactly which class they should be in right now, considering both day and time</li>
|
|
<li><strong>/schedule</strong>: Shows the complete schedule for today, with all class periods and times</li>
|
|
<li><strong>/tomorrow</strong>: Shows what classes are scheduled for tomorrow, helping students prepare</li>
|
|
<li><strong>/help</strong>: Lists all available commands with descriptions</li>
|
|
</ul>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Conclusion</h2>
|
|
<p>This advanced scheduler bot project demonstrates how programming can create practical tools that solve real-world problems. By moving from a simple hard-coded schedule to a file-based system, the bot became much more useful and maintainable. The student learned important programming concepts including file handling, data processing, time management, and creating user-friendly interfaces. The project shows that even school projects can evolve into sophisticated applications that could be used by real schools.</p>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Future Possibilities</h2>
|
|
<p>This bot could be extended in several interesting ways:</p>
|
|
<ul>
|
|
<li><strong>Multiple user support</strong>: Allow different students to have personalized schedules</li>
|
|
<li><strong>Teacher information</strong>: Include which teacher is teaching each class and their contact information</li>
|
|
<li><strong>Classroom maps</strong>: Add links to maps showing where classrooms are located</li>
|
|
<li><strong>Homework integration</strong>: Connect to homework assignment systems</li>
|
|
<li><strong>Mobile notifications</strong>: Send push notifications before class starts</li>
|
|
<li><strong>Special schedules</strong>: Handle exam weeks, holidays, and special event days</li>
|
|
<li><strong>Statistics tracking</strong>: Track which commands are used most often to improve the bot</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<div class="addendum">
|
|
<h2>Addendum: Complete Bot Code</h2>
|
|
<p>Here is the complete Python code for the Advanced Telegram Scheduler Bot:</p>
|
|
|
|
<div class="code-note">
|
|
<strong>Note:</strong> For security reasons, the actual bot token has been removed. When using this code, you should replace "YOUR_BOT_TOKEN_HERE" with your actual bot token from @BotFather.
|
|
</div>
|
|
|
|
<div class="code-block">import pandas as pd
|
|
import datetime
|
|
from telegram import Update
|
|
from telegram.ext import Application, CommandHandler, ContextTypes
|
|
|
|
# 🔑 REPLACE THIS with your bot token from @BotFather
|
|
BOT_TOKEN = "YOUR_BOT_TOKEN_HERE"
|
|
|
|
def load_schedule():
|
|
"""
|
|
Load schedule from CSV file using pandas
|
|
Returns a dictionary with day-wise schedule
|
|
"""
|
|
try:
|
|
# Read CSV file
|
|
df = pd.read_csv('schedule.csv')
|
|
schedule = {}
|
|
|
|
# Process each row (each day)
|
|
for _, row in df.iterrows():
|
|
day = row['Day']
|
|
schedule[day] = []
|
|
|
|
# Process each time slot column
|
|
time_slots = ['Period_1', 'Period_2', 'Period_3',
|
|
'Period_4', 'Period_5', 'Period_6', 'Period_7']
|
|
|
|
for slot in time_slots:
|
|
# Check if class exists for this time slot
|
|
if pd.notna(row[slot]) and str(row[slot]).strip():
|
|
class_info = str(row[slot])
|
|
schedule[day].append((slot, class_info))
|
|
|
|
return schedule
|
|
|
|
except FileNotFoundError:
|
|
print("❌ Error: schedule.csv file not found!")
|
|
print("Please create schedule.csv in the same folder")
|
|
return {}
|
|
except Exception as e:
|
|
print(f"❌ Error loading schedule: {e}")
|
|
return {}
|
|
|
|
# Load schedule at startup
|
|
SCHEDULE = load_schedule()
|
|
|
|
# Time mapping for periods
|
|
PERIOD_TIMES = {
|
|
'Period_1': ('09:00', '09:40'),
|
|
'Period_2': ('10:00', '10:40'),
|
|
'Period_3': ('11:00', '11:40'),
|
|
'Period_4': ('11:50', '12:30'),
|
|
'Period_5': ('12:40', '13:20'),
|
|
'Period_6': ('13:30', '14:10'),
|
|
'Period_7': ('10:00', '10:40'),
|
|
}
|
|
|
|
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Send welcome message when command /start is issued."""
|
|
await update.message.reply_text(
|
|
"🤖 Hello! I'm your enhanced class scheduler bot!\n"
|
|
"Use /whereami to find your current class\n"
|
|
"Use /schedule to see today's full schedule\n"
|
|
"Use /tomorrow to see tomorrow's schedule\n"
|
|
"Use /help for all commands"
|
|
)
|
|
|
|
async def where_am_i(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Tell user where they should be right now."""
|
|
if not SCHEDULE:
|
|
await update.message.reply_text("❌ Schedule not loaded. Check schedule.csv file.")
|
|
return
|
|
|
|
now = datetime.datetime.now()
|
|
current_time = now.strftime("%H:%M")
|
|
current_day = now.strftime("%A")
|
|
|
|
await update.message.reply_text(f"📅 Today is {current_day}")
|
|
await update.message.reply_text(f"⏰ Current time: {current_time}")
|
|
|
|
# Check if we have schedule for today
|
|
if current_day not in SCHEDULE:
|
|
await update.message.reply_text("😊 No classes scheduled for today!")
|
|
return
|
|
|
|
# Find current class
|
|
found_class = False
|
|
for period, class_info in SCHEDULE[current_day]:
|
|
start_time, end_time = PERIOD_TIMES[period]
|
|
|
|
if start_time <= current_time <= end_time:
|
|
await update.message.reply_text(f"🎯 You should be in: {class_info}")
|
|
found_class = True
|
|
break
|
|
|
|
if not found_class:
|
|
await update.message.reply_text("😊 No class right now! Free period.")
|
|
|
|
async def schedule(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Show today's full schedule."""
|
|
if not SCHEDULE:
|
|
await update.message.reply_text("❌ Schedule not loaded. Check schedule.csv file.")
|
|
return
|
|
|
|
current_day = datetime.datetime.now().strftime("%A")
|
|
|
|
if current_day not in SCHEDULE or not SCHEDULE[current_day]:
|
|
await update.message.reply_text("😊 No classes scheduled for today!")
|
|
return
|
|
|
|
schedule_text = f"📚 {current_day}'s Schedule:\n\n"
|
|
for period, class_info in SCHEDULE[current_day]:
|
|
start, end = PERIOD_TIMES[period]
|
|
schedule_text += f"⏰ {start}-{end}: {class_info}\n"
|
|
|
|
await update.message.reply_text(schedule_text)
|
|
|
|
async def tomorrow(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Show tomorrow's schedule."""
|
|
if not SCHEDULE:
|
|
await update.message.reply_text("❌ Schedule not loaded. Check schedule.csv file.")
|
|
return
|
|
|
|
tomorrow_date = datetime.datetime.now() + datetime.timedelta(days=1)
|
|
tomorrow_day = tomorrow_date.strftime("%A")
|
|
|
|
if tomorrow_day not in SCHEDULE or not SCHEDULE[tomorrow_day]:
|
|
await update.message.reply_text(f"😊 No classes scheduled for {tomorrow_day}!")
|
|
return
|
|
|
|
schedule_text = f"📚 {tomorrow_day}'s Schedule:\n\n"
|
|
for period, class_info in SCHEDULE[tomorrow_day]:
|
|
start, end = PERIOD_TIMES[period]
|
|
schedule_text += f"⏰ {start}-{end}: {class_info}\n"
|
|
|
|
await update.message.reply_text(schedule_text)
|
|
|
|
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
"""Send help message with all commands."""
|
|
await update.message.reply_text(
|
|
"Available commands:\n"
|
|
"/start - Start the bot\n"
|
|
"/whereami - Find your current class\n"
|
|
"/schedule - Show today's schedule\n"
|
|
"/tomorrow - Show tomorrow's schedule\n"
|
|
"/help - Show this help message"
|
|
)
|
|
|
|
def main():
|
|
"""Start the bot."""
|
|
if not SCHEDULE:
|
|
print("❌ Failed to load schedule. Please check schedule.csv file.")
|
|
print("Make sure schedule.csv exists in the same folder")
|
|
return
|
|
|
|
# Create the Application
|
|
application = Application.builder().token(BOT_TOKEN).build()
|
|
|
|
# Add command handlers
|
|
application.add_handler(CommandHandler("start", start))
|
|
application.add_handler(CommandHandler("whereami", where_am_i))
|
|
application.add_handler(CommandHandler("schedule", schedule))
|
|
application.add_handler(CommandHandler("tomorrow", tomorrow))
|
|
application.add_handler(CommandHandler("help", help_command))
|
|
|
|
# Start the Bot
|
|
print("🤖 Enhanced scheduler bot is running...")
|
|
print("📊 Schedule loaded successfully!")
|
|
print("📅 Available days:", list(SCHEDULE.keys()))
|
|
print("Press Ctrl+C to stop the bot")
|
|
|
|
application.run_polling()
|
|
|
|
if __name__ == "__main__":
|
|
main()</div>
|
|
|
|
<p>Key features of this advanced code:</p>
|
|
<ol>
|
|
<li><strong>CSV File Loading</strong>: Uses pandas library to read schedule data from an external file</li>
|
|
<li><strong>Flexible Schedule Structure</strong>: Supports different schedules for each day of the week</li>
|
|
<li><strong>Multiple Periods</strong>: Handles up to 7 class periods per day with accurate timing</li>
|
|
<li><strong>Error Handling</strong>: Includes error messages if the schedule file is missing or has problems</li>
|
|
<li><strong>User-Friendly Commands</strong>: Five different commands to help students in different ways</li>
|
|
<li><strong>Professional Structure</strong>: Well-organized code with clear functions and documentation</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="footer">
|
|
<p>Consolidated from multiple thesis documents | Generated automatically</p>
|
|
</div>
|
|
</body>
|
|
</html> |