Skip to main content

Open Sessions (To be removed)

Description

The Open Sessions screen displays all open (unclosed) zone check-in sessions found on the scanner device. This screen appears after login when a user with manager/auditor role attempts to log in and there are open sessions from other users or previous sessions that need to be closed. The screen allows managers to review, sync (close), or resume these open sessions. Each session displays verification status and sync readiness based on audit quotas and verification requirements.

When This Screen Appears

Login Flow Context

After a user logs in, the system checks for open sessions:

  1. PerformLogin executes and checks for open zone check-ins.
  2. Three Possible Outcomes:
    • Response.CurrentUser: The logged-in user has their own open session → Shows dialog to resume it.
    • Response.CanSyncSession: User has manager/auditor role AND there are other open sessions → Navigates to Open Sessions screen.
    • Response.Successful: No open sessions or regular user → Proceeds to home screen.

Who Sees This Screen

From the login documentation and code:

  • Managers/Auditors: Users with elevated roles who can sync sessions from other users.
  • Condition: user.hasRole() returns true AND there are open zone check-ins.
  • Purpose: Allows managers to clean up unfinished sessions before starting their own work.

What Are Open Sessions

Open sessions are zone check-ins where:

  • closedAt is null (session not yet closed).
  • Session may belong to:
    • Another user who didn't complete verification.
    • The same user from a previous interrupted session.
    • A different device if sessions are shared across devices.

Screen Functionality

GetZoneCheckIns - Fetching Open Sessions

When the screen loads:

  1. Query All Zone Check-Ins: Loads all zone check-in records for the current project.
  2. Filter Open Sessions: Keeps only records where closedAt == null.
  3. Convert to Session Objects: For each open zone check-in:
    • Gets number of scans (GetNumberOfScans).
    • Gets customer/client name (GetCustomer).
    • Calculates sync readiness (GetVerifyStatus).
  4. Auto-Navigate: If no open sessions exist, automatically navigates to Home screen.
  5. Display List: Shows all open sessions with their details.

Session Information Displayed

Each session in the list shows:

  • Zone Code: The zone identifier for this session.
  • Project Name: Which project the session belongs to.
  • User Name: Who started this session.
  • Mode: Scan, PositionCountVerify, or ZoneCountVerify.
  • Number of Scans: Total scans in the session.
  • Customer: Client/customer name.
  • Device Code: Which scanner device created the session.
  • Sync Ready Status: Whether the session can be synced (closed).
  • Select Next: Move to the next session in the list (wraps to first).
  • Select Previous: Move to the previous session in the list (wraps to last).
  • Select by Touch: Tap any session to select it.
  • First Session Default: The first session is automatically selected on load.

Available Actions

View Session

  • Opens the session in its respective mode:
    • Scan Mode: Navigates to Add Scans screen with the session ID.
    • Verify Modes: Navigates to Verify screen with the session ID and mode.
  • Allows user to complete or continue the work.
  • Useful when the session needs additional scanning or verification.

Sync Session

  • Closes the session by setting closedAt to current timestamp.
  • Enqueues for upload to sync the session data to the server.
  • Removes from list: After successful sync, session disappears from open sessions.
  • Auto-select next: Automatically selects the next session in the list.
  • Only if Ready: Sync button is enabled only when isSyncReady = true.

Sync Readiness - Why a Session Can Be Synced or Not

GetVerifyStatus - Calculating Sync Readiness

For each session, the system determines if it's ready to be synced:

Scan Mode Sessions:

  • Always Ready: Scan mode sessions can always be synced.
  • No verification requirements.
  • Simply closes the session and uploads scans.

Verify Mode Sessions (PositionCountVerify, ZoneCountVerify):

  • Conditional: Must meet audit requirements.
  • Calculates AuditingStats for the session.
  • Checks if auditStatus == AuditStatus.Complete.

Auditing Stats Calculation

The system evaluates verification completeness:

  1. Get Scan Groups: Groups all scans in the session using the same logic as Verify screen.

  2. Filter Non-Added Scans: Excludes scans from AddScans session (only verify sessions count).

  3. Calculate Metrics:

    • verifyDone: Number of scans marked as verified.
    • verifyTotal: Total scans that need verification.
    • totalDone: All verified scans (regardless of need).
    • totalScans: Total number of scans (non-added).
    • auditQuota: Required percentage from configuration.
    • shouldVerifyMandatory: Whether mandatory items must be verified.
    • verifiedMandatory: Whether all mandatory items are verified.
  4. Determine Audit Status:

    • Complete: Zone is empty OR (quota met AND mandatory verified).
    • QuotaNotAchieved: Percentage of verified scans < audit quota.
    • NotAllMandatoryVerified: Quota met but mandatory items not verified.

Why a Session CANNOT Be Synced

Quota Not Met

  • Condition: (totalDone / totalScans * 100) < auditQuota
  • Example: Audit quota is 80%, but only 60% of scans are verified.
  • Reason: Insufficient verification coverage.
  • Solution: User must "View" the session and verify more scan groups until quota is met.

Mandatory Items Not Verified

  • Condition: shouldVerifyMandatory == true AND some scans with needsVerification = true are not verified.
  • Example: Items marked as mandatory haven't been checked yet.
  • Reason: Critical items must be verified before closing.
  • Solution: User must "View" the session and verify all mandatory items.

Empty Zone

  • Condition: Zone has no scans (after filtering AddScans).
  • Status: Actually allows sync (considered Complete).
  • Reason: Nothing to verify means verification is complete.

Why a Session CAN Be Synced

Scan Mode

  • Reason: Scan sessions don't require verification.
  • Status: isSyncReady = true always.
  • Action: Closes session and uploads scan data.

Verify Mode - Complete Audit

  • Conditions Met:
    • Percentage of verified scans >= audit quota.
    • All mandatory items are verified (if required).
    • OR zone is empty.
  • Status: auditStatus == AuditStatus.CompleteisSyncReady = true.
  • Action: Closes session and uploads verification results.

Visual Indicators

Based on isSyncReady:

  • True: Sync button is enabled (ready to close).
  • False: Sync button is disabled (must complete verification first).
  • User can see which sessions are ready and which need more work.

Complete Flow Examples

Example 1: Manager Syncing Complete Verify Session

Scenario:

  • Manager logs in.
  • Employee left an open PositionCountVerify session.
  • Audit quota: 75%, employee verified 80% of items.
  • All mandatory items verified.

Flow:

  1. Login succeeds → PerformLogin.Response.CanSyncSession.
  2. Navigate to Open Sessions screen.
  3. Screen loads: Shows 1 open session.
  4. Session details: Employee name, zone code, 80% verified, isSyncReady = true.
  5. Manager reviews: Sees "Sync" button is enabled.
  6. Manager taps "Sync".
  7. System calls ZoneCheckOut:
    • Sets closedAt to current time.
    • Enqueues session for server upload.
  8. Session removed from list.
  9. No more open sessions → Auto-navigate to Home screen.

Example 2: Manager Views Incomplete Session

Scenario:

  • Manager logs in.
  • Employee left open session with only 50% verified.
  • Audit quota: 75%.

Flow:

  1. Navigate to Open Sessions screen.
  2. Session shows: 50% verified, isSyncReady = false.
  3. "Sync" button is disabled.
  4. Manager taps "View" button.
  5. Opens session in Verify screen.
  6. Manager verifies additional groups until 75%+ reached.
  7. Returns to Open Sessions (or syncs from verify screen).
  8. Session now shows isSyncReady = true.
  9. Manager can now sync the session.

Example 3: Multiple Open Sessions

Scenario:

  • Three employees left open sessions.
  • Session 1: Scan mode (always ready).
  • Session 2: Verify mode, 90% verified (ready).
  • Session 3: Verify mode, 40% verified (not ready).

Flow:

  1. Open Sessions shows 3 sessions.
  2. First session (Scan) is selected by default.
  3. Manager syncs Session 1 → Removed, Session 2 auto-selected.
  4. Manager syncs Session 2 → Removed, Session 3 auto-selected.
  5. Session 3: "Sync" disabled.
  6. Manager taps "View" → Opens in Verify screen.
  7. Manager completes verification or decides to keep for employee.
  8. Returns and syncs or leaves for employee to finish.

Fields

No input fields - this is a selection and action screen.

Error Messages

No specific error messages documented for this screen. Errors from ZoneCheckOut or GetVerifyStatus would be displayed if sync fails.