Spaces:
Sleeping
Sleeping
File size: 4,849 Bytes
da819ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# π 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 |