Spaces:
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):
- Tutorial Task 1 - Gulangyu Stone
- Tutorial Task 2 - Gulangyu Geology
- Tutorial Task 3 - Opium War History
Weekly Practice Tasks (6):
- Chinese Pun 1
- Chinese Pun 2
- Chinese Pun 3
- English Joke 1
- English Joke 2
- English Joke 3
Week 2 (12 tasks)
- Tutorial ST 1 - Week 2
- Tutorial ST 2 - Week 2
- Tutorial ST 3 - Week 2
- Tutorial ST 4 - Week 2
- Tutorial ST 5 - Week 2
- Tutorial ST 6 - Week 2
- Tutorial ST 7 - Week 2
- Tutorial ST 8 - Week 2
- Tutorial ST 9 - Week 2
- Tutorial ST 10 - Week 2
- Tutorial ST 11 - Week 2
- Tutorial ST 12 - Week 2
π§ Available Scripts
1. Check Protection Status
node show-protection-status.js
Shows current protection status of all tutorial tasks.
2. Test Protection System
node enhanced-protection-system.js
Tests the protection system to ensure it's working correctly.
3. Lock Tasks
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
node show-protection-status.js
Find the task ID from the output.
Step 2: Use the Unlock Function
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:
node lock-week1-week2-tasks.js
β Safe Operations
For Non-Protected Tasks
Use these functions for safe operations:
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
- Unlock first: Use
unlockProtectedTask(taskId, key) - Make changes: Update normally
- 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()andsafeDeleteTask()for protection
π Troubleshooting
Task Won't Update
Problem: Getting "CANNOT UPDATE: Task is PROTECTED" error Solution:
- Unlock the task:
unlockProtectedTask(taskId, 'UNLOCK_WEEK1_WEEK2_2024') - Make your changes
- 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
- Always check protection status before making changes
- Use safe functions (
safeUpdateTask,safeDeleteTask) when possible - Document your changes with clear reasons
- Re-lock tasks after making necessary changes
- 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:
- Check the protection status first
- Verify you're using the correct task ID
- Ensure you're using the correct unlock key
- Check the modification history for recent changes