# 2. Sync Management

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

---

## 2. Sync Management

### 2.1 Progress Sync Configuration
**What it does:** The Super Admin configures how learner progress recorded offline is synchronized back to the platform when the device is back online.

**Sub-features:**
- Sync trigger: the condition that triggers a sync (auto on connect, manual, scheduled)
- Sync scope: the progress types synced (video watch time, quiz results, worksheet completion)
- Sync frequency: the interval for scheduled syncs
- Sync conflict policy: the policy for conflicting progress records
- Sync priority: the priority order for syncing queued items
- Available on web
- Event logging (action performed)
- Audit logging of progress sync configuration

**Super Admin User Journey:**
1. As a Super Admin, open the progress sync configuration.
2. Set the sync trigger, scope, and frequency.
3. Define the sync conflict policy and priority order.
4. Save and verify offline progress is synced when the device reconnects.

**Rules & Edge Cases:**
- An auto-on-connect sync runs immediately when the device regains connectivity.
- A manual sync runs only when the learner initiates it.
- A scheduled sync runs at the configured interval while online.
- A sync scope excludes progress types not selected; excluded types are not synced.
- A conflict policy of last-write-wins keeps the most recent record; first-write-wins keeps the earliest.
- A sync priority order determines the sequence in which queued items are processed.
- A sync that fails is retried up to the configured retry count before being marked failed.
- Configuration changes are audit-logged with the actor and timestamp.

### 2.2 Sync Queue Management
**What it does:** The Super Admin manages the offline sync queue so pending sync items are tracked, ordered, and processed reliably.

**Sub-features:**
- Queue visibility: the pending sync items visible per learner
- Queue ordering: the order in which queued items are processed
- Queue retry: the retry behavior for failed sync items
- Queue purge: the purge of stale or obsolete sync items
- Queue status: the state per queued item (pending, syncing, synced, failed)
- Queue limit: the maximum number of items held in the queue
- Available on web
- Event logging (action performed)
- Audit logging of sync queue management

**Super Admin User Journey:**
1. As a Super Admin, open the sync queue management view.
2. Review the pending sync items per learner.
3. Check the queue ordering and status per item.
4. Configure the retry behavior and queue limit.
5. Verify failed items are retried and stale items are purged.

**Rules & Edge Cases:**
- A queue item beyond the retry count is marked failed and held for review.
- A queue item older than the staleness window is purged.
- A queue at the limit blocks new items from being queued; the oldest synced items are cleared first.
- A queue item in syncing state is not re-queued until it completes or fails.
- A purge removes only items that are synced or failed; pending items are not purged.
- The queue is per learner and per device.
- Queue management actions are audit-logged with the actor and timestamp.

### 2.3 Conflict Resolution Rules
**What it does:** The Super Admin defines the rules for resolving conflicts when offline and online progress records disagree.

**Sub-features:**
- Conflict detection: the detection of conflicting progress records
- Resolution strategy: the strategy applied (last-write-wins, first-write-wins, manual review)
- Conflict log: the log of detected conflicts and their resolution
- Conflict threshold: the threshold that triggers a conflict (time delta, value delta)
- Manual review queue: the queue of conflicts requiring manual resolution
- Available on web
- Event logging (action performed)
- Audit logging of conflict resolution rules

**Super Admin User Journey:**
1. As a Super Admin, open the conflict resolution rules.
2. Define the conflict detection thresholds.
3. Set the resolution strategy per progress type.
4. Save and verify a conflict is detected and resolved per the strategy.
5. Review the conflict log and the manual review queue.

**Rules & Edge Cases:**
- A conflict is detected when two records for the same progress point differ beyond the threshold.
- A last-write-wins resolution keeps the record with the latest timestamp.
- A first-write-wins resolution keeps the record with the earliest timestamp.
- A manual review strategy holds the conflict in the review queue until resolved.
- A resolved conflict is recorded in the conflict log with the outcome.
- A conflict with no resolvable strategy defaults to manual review.
- Rule changes apply to new conflicts; already-resolved conflicts are not re-evaluated.
- Rule changes are audit-logged with the actor and timestamp.

### 2.4 Sync Status Monitoring
**What it does:** The Super Admin monitors the sync health across learners so sync failures and delays are visible and actionable.

**Sub-features:**
- Sync health dashboard: the overall sync health across learners
- Sync failure list: the learners with failed syncs
- Sync delay metrics: the time from offline action to synced state
- Sync success rate: the share of syncs that succeed
- Sync alerting: alerts on sync failure spikes
- Sync detail: the sync state per learner and device
- Available on web
- Event logging (action performed)
- Audit logging of sync status monitoring

**Super Admin User Journey:**
1. As a Super Admin, open the sync status monitoring dashboard.
2. Review the overall sync health and success rate.
3. Check the sync failure list and delay metrics.
4. Configure sync alerting thresholds.
5. Open a learner's sync detail to investigate a failure.

**Rules & Edge Cases:**
- A sync success rate below the alert threshold raises an alert.
- A sync failure list entry links to the learner's sync detail.
- A sync delay metric is computed from the offline action timestamp to the synced timestamp.
- A sync alert is raised once per threshold breach, not repeatedly per item.
- A sync detail shows the per-item state for a learner and device.
- Monitoring data is retained for the configured retention window.
- Alerting configuration changes are audit-logged with the actor and timestamp.

### 2.5 Offline Quiz Sync
**What it does:** The Super Admin configures the synchronization of quizzes taken offline so answers and results are recorded when the device reconnects.

**Sub-features:**
- Offline quiz enablement: offline quiz taking toggled on or off per course
- Answer sync: the sync of quiz answers on reconnect
- Result computation: the computation of quiz results after sync
- Anti-cheat on sync: the validation of offline quiz integrity on sync
- Quiz sync status: the sync state per offline quiz attempt
- Available on web
- Event logging (action performed)
- Audit logging of offline quiz sync

**Super Admin User Journey:**
1. As a Super Admin, open the offline quiz sync configuration.
2. Enable offline quiz taking per course.
3. Configure the answer sync, result computation, and anti-cheat validation.
4. Save and verify an offline quiz is synced and scored on reconnect.
5. Check the quiz sync status per attempt.

**Rules & Edge Cases:**
- An offline quiz is enabled only for courses where it is toggled on.
- An offline quiz answer is synced only when the device reconnects.
- A quiz result is computed after the answers are synced, not before.
- An offline quiz that fails anti-cheat validation on sync is marked invalid.
- A quiz sync that fails is retried per the queue retry policy.
- An offline quiz attempt has a single sync; a re-sync does not double-count.
- Configuration changes are audit-logged with the actor and timestamp.
