# 3. Progress Sync & Conflict Handling

User Type: **Student**
Source: *Mi Digital Academy - Education CRM Features Document*

---

## 3. Progress Sync & Conflict Handling

### 3.1 Sync Progress When Back Online
**What it does:** Syncs the Student's offline activity (watch progress, quiz results, flashcard study, notes) when the device is back online. The sync is automatic and the Student sees a sync status. All offline activity is reconciled with the Student's account so their progress is complete and accurate.

**Sub-features:**
- Automatic sync when back online
- Sync of watch progress
- Sync of quiz results and grading
- Sync of flashcard study and mastery
- Sync of notes and follow-ups
- Sync status indicator
- Sync queue (pending items)
- Sync event logging (started, completed)
- Audit logging of the sync progress when back online

**Student User Journey:**
1. Student is offline and completes a video, a quiz, and a flashcard session.
2. The device goes back online.
3. The sync starts automatically; a sync status indicator is shown.
4. The watch progress, quiz result, and flashcard mastery sync.
5. The Student's dashboard reflects the synced activity.
6. The sync queue is empty after the sync.
7. Student opens Profile → "Activity" and confirms the sync events are recorded.

**Rules & Edge Cases:**
- The sync is automatic when the device is back online.
- All offline activity is reconciled with the account.
- A sync status indicator is shown while syncing.
- The sync queue holds pending items until synced.
- Sync events (started, completed) are logged with the account and the timestamp.
- The sync progress when back online is audit-logged with the account and the timestamp.

### 3.2 Sync Queue Management
**What it does:** Manages the queue of offline items waiting to sync. The Student can see the pending items, their status, and retry a failed sync. The queue is processed in order when online, and the Student is informed of any items that could not sync.

**Sub-features:**
- Sync queue of pending offline items
- View pending items and their status
- Retry a failed sync
- Queue processed in order when online
- Notification for items that could not sync
- Clear the queue after a successful sync
- Queue event logging (item added, retried, cleared)
- Audit logging of the sync queue management

**Student User Journey:**
1. Student goes offline and generates several sync items.
2. Student opens the sync queue and sees the pending items.
3. When online, the queue is processed in order.
4. A failed item is retried.
5. An item that could not sync is notified.
6. The queue is cleared after a successful sync.
7. Student opens Profile → "Activity" and confirms the queue events are recorded.

**Rules & Edge Cases:**
- The sync queue holds pending offline items.
- The queue is processed in order when online.
- A failed sync can be retried.
- Items that could not sync are notified.
- Queue events (item added, retried, cleared) are logged with the account and the timestamp.
- The sync queue management is audit-logged with the account and the timestamp.

### 3.3 Conflict Resolution
**What it does:** Resolves conflicts when offline and online changes to the same item occur (e.g., a note edited offline and online). The platform applies a documented resolution (latest change wins, with a merge where possible) and the Student is informed of any resolved conflicts. This keeps the Student's data consistent.

**Sub-features:**
- Detect a conflict (offline and online change to the same item)
- Resolution rule (latest change wins, merge where possible)
- Inform the Student of a resolved conflict
- Conflict log (item, resolution, timestamp)
- View the Student's conflict history
- Manual review for a conflict (where needed)
- Conflict event logging (detected, resolved)
- Audit logging of the conflict resolution

**Student User Journey:**
1. Student edits a note offline; the same note is edited online on another device.
2. On sync, a conflict is detected.
3. The platform applies the resolution (latest change wins).
4. The Student is informed of the resolved conflict.
5. The conflict appears in the conflict log.
6. For a conflict needing review, the Student reviews it manually.
7. Student opens Profile → "Activity" and confirms the conflict events are recorded.

**Rules & Edge Cases:**
- A conflict is detected when offline and online changes touch the same item.
- The resolution rule is latest change wins, with a merge where possible.
- The Student is informed of a resolved conflict.
- A conflict can require manual review.
- Conflict events (detected, resolved) are logged with the item and the timestamp.
- The conflict resolution is audit-logged with the account, the item, and the timestamp.
