Spaces:
Sleeping
Sleeping
| # π PROTECTION SYSTEM GUIDE | |
| ## Overview | |
| The protection system prevents accidental modification of critical tutorial tasks (Week 1 and Week 2) by implementing a locking mechanism that requires special authorization to modify protected content. | |
| ## π‘οΈ Current Protection Status | |
| - **Week 1**: 3 tutorial tasks + 6 weekly practice tasks LOCKED | |
| - **Week 2**: 12 tutorial tasks LOCKED | |
| - **Total Protected**: 21 tasks | |
| - **Unlock Key**: `UNLOCK_WEEK1_WEEK2_2024` | |
| ## π Protected Tasks | |
| ### Week 1 (9 tasks) | |
| **Tutorial Tasks (3):** | |
| 1. Tutorial Task 1 - Gulangyu Stone | |
| 2. Tutorial Task 2 - Gulangyu Geology | |
| 3. Tutorial Task 3 - Opium War History | |
| **Weekly Practice Tasks (6):** | |
| 1. Chinese Pun 1 | |
| 2. Chinese Pun 2 | |
| 3. Chinese Pun 3 | |
| 4. English Joke 1 | |
| 5. English Joke 2 | |
| 6. English Joke 3 | |
| ### Week 2 (12 tasks) | |
| 1. Tutorial ST 1 - Week 2 | |
| 2. Tutorial ST 2 - Week 2 | |
| 3. Tutorial ST 3 - Week 2 | |
| 4. Tutorial ST 4 - Week 2 | |
| 5. Tutorial ST 5 - Week 2 | |
| 6. Tutorial ST 6 - Week 2 | |
| 7. Tutorial ST 7 - Week 2 | |
| 8. Tutorial ST 8 - Week 2 | |
| 9. Tutorial ST 9 - Week 2 | |
| 10. Tutorial ST 10 - Week 2 | |
| 11. Tutorial ST 11 - Week 2 | |
| 12. Tutorial ST 12 - Week 2 | |
| ## π§ Available Scripts | |
| ### 1. Check Protection Status | |
| ```bash | |
| node show-protection-status.js | |
| ``` | |
| Shows current protection status of all tutorial tasks. | |
| ### 2. Test Protection System | |
| ```bash | |
| node enhanced-protection-system.js | |
| ``` | |
| Tests the protection system to ensure it's working correctly. | |
| ### 3. Lock Tasks | |
| ```bash | |
| node lock-week1-week2-tasks.js | |
| ``` | |
| Locks Week 1 and Week 2 tutorial tasks (already done). | |
| ## π« What's Protected | |
| Protected tasks **CANNOT** be: | |
| - β Updated (content, images, etc.) | |
| - β Deleted | |
| - β Modified in any way | |
| ## π How to Unlock a Protected Task | |
| ### Step 1: Get the Task ID | |
| ```bash | |
| node show-protection-status.js | |
| ``` | |
| Find the task ID from the output. | |
| ### Step 2: Use the Unlock Function | |
| ```javascript | |
| const { unlockProtectedTask } = require('./enhanced-protection-system.js'); | |
| // Unlock a specific task | |
| await unlockProtectedTask('TASK_ID_HERE', 'UNLOCK_WEEK1_WEEK2_2024'); | |
| ``` | |
| ### Step 3: Make Your Changes | |
| Once unlocked, you can modify the task normally. | |
| ### Step 4: Re-lock (Optional) | |
| After making changes, you can re-lock the task: | |
| ```bash | |
| node lock-week1-week2-tasks.js | |
| ``` | |
| ## β Safe Operations | |
| ### For Non-Protected Tasks | |
| Use these functions for safe operations: | |
| ```javascript | |
| const { safeUpdateTask, safeDeleteTask } = require('./enhanced-protection-system.js'); | |
| // Safe update | |
| await safeUpdateTask(taskId, { content: 'New content' }, 'Update reason'); | |
| // Safe delete | |
| await safeDeleteTask(taskId, 'Delete reason'); | |
| ``` | |
| ### For Protected Tasks | |
| 1. **Unlock first**: Use `unlockProtectedTask(taskId, key)` | |
| 2. **Make changes**: Update normally | |
| 3. **Re-lock**: Run the locking script again | |
| ## π¨ Important Notes | |
| ### Protection Features | |
| - β **Automatic Protection**: Week 1 and Week 2 tasks are automatically protected | |
| - β **Clear Messages**: System provides clear feedback when operations are blocked | |
| - β **Modification History**: All changes are tracked with timestamps and reasons | |
| - β **Special Key Required**: Unlock key prevents accidental unlocking | |
| ### Safety Measures | |
| - β **No Automatic Unlocking**: Tasks stay locked until manually unlocked | |
| - β **Key Verification**: Invalid keys are rejected | |
| - β **History Tracking**: All modifications are logged | |
| - β **Safe Functions**: Use `safeUpdateTask()` and `safeDeleteTask()` for protection | |
| ## π Troubleshooting | |
| ### Task Won't Update | |
| **Problem**: Getting "CANNOT UPDATE: Task is PROTECTED" error | |
| **Solution**: | |
| 1. Unlock the task: `unlockProtectedTask(taskId, 'UNLOCK_WEEK1_WEEK2_2024')` | |
| 2. Make your changes | |
| 3. Re-lock if needed | |
| ### Can't Find Task ID | |
| **Problem**: Don't know the task ID | |
| **Solution**: Run `node show-protection-status.js` to see all task IDs | |
| ### Invalid Unlock Key | |
| **Problem**: Getting "Invalid unlock key" error | |
| **Solution**: Use the correct key: `UNLOCK_WEEK1_WEEK2_2024` | |
| ## π Best Practices | |
| 1. **Always check protection status** before making changes | |
| 2. **Use safe functions** (`safeUpdateTask`, `safeDeleteTask`) when possible | |
| 3. **Document your changes** with clear reasons | |
| 4. **Re-lock tasks** after making necessary changes | |
| 5. **Keep the unlock key secure** and don't share it publicly | |
| ## π Security Notes | |
| - The unlock key is currently hardcoded for simplicity | |
| - In production, consider using environment variables or a more secure method | |
| - The protection system prevents accidental changes but doesn't replace proper backup procedures | |
| - Always backup your database before making significant changes | |
| ## π Support | |
| If you encounter issues with the protection system: | |
| 1. Check the protection status first | |
| 2. Verify you're using the correct task ID | |
| 3. Ensure you're using the correct unlock key | |
| 4. Check the modification history for recent changes |