Back to Admin Dashboard

🏠 Assessment Landing Page Operations

Documentation of the deterministic logic governing the Assessment Hub. The landing page acts as the central router and state machine for the entire platform. It manages user onboarding, database initialization, sandbox exploration, and persistent UI states.

1. ZERO-BLOAT JSON SYSTEM

To ensure maximum performance and prevent PHP file bloat, no JSON strings are hardcoded into the landing page. All schemas are stored externally in a secure theme directory.

Pristine Payload

schema-empty.json is the master blueprint. It contains a completely flattened, pristine layout of every key required by the platform’s algorithms.

Sandbox Payloads

schema-demo-*.json files contain pre-populated data. When requested, they safely overwrite the user’s current session to allow platform exploration.

2. DATABASE ONBOARDING

When a user lands on the hub, the system ensures they have a valid starting state before any UI is rendered.

Step 1: PHP checks the assessment table for the current user’s ID.

Step 2: If no row exists (New User), PHP native function file_get_contents() retrieves the schema-empty.json.

Step 3: An INSERT is executed, saving the pristine schema to the assessmentscript column, immediately preparing their profile.

3. THE STATE MACHINE (MODES)

The entire platform’s data behavior is dictated by a single JSON key: "assessment_mode". The server evaluates this key to determine what demo buttons to highlight and what access level the user has.

Mode Value System Response & Data State Access Level
"self" Default State: The user’s schema is currently their own real data. The “Start Real Assessment” button is hidden. Demo buttons are available to click. Open
"demo_*" Sandbox State: The system has loaded pre-populated dummy data. The Green “Switch to Real Assessment” button appears to allow escape. Locked
"started" Active State: Triggered by the Green Button. The system resets the user to a blank slate, removes demo restrictions, and hides the demo panel permanently via local storage. Open
4. UI VISIBILITY & LOCAL STORAGE

The visibility of the Demo exploration panel is controlled independently of the database via browser localStorage to ensure a seamless, non-intrusive experience.

Brand New Users

Because no local storage key exists yet, the Demo panel is fully visible (display: block) by default, inviting them to explore.

Manual Hide

Clicking “Hide Demo Mode” saves assess_hub_panel_hidden = true in the browser. The box collapses into a small “Show Demo Mode” text link. This persists across all page reloads.

The Green Button Trigger

Clicking “Switch to My Real Assessment” does two things simultaneously: It updates the database state to "started", AND it programmatically triggers the Hide function. This ensures that once a user commits to their real assessment, the demo interface automatically gets out of their way permanently.

5. GLOBAL LOCKDOWN PROTOCOL

If a user is in a demo_* state, we must prevent them from accidentally submitting form data and mutating the pristine demo file in the database. This is handled by a globally injected security script.

The Trigger (WPCode)

A PHP snippet running in the site footer checks the DB. If assessment_mode contains the word “demo”, it injects the JavaScript security payload. If not, the script is completely bypassed to save resources.

The Execution (Javascript)

1. Match URL: Checks if the user is on an active assessment form.

2. Inject Banner: Spawns a floating red warning banner with an escape link.

3. Disable DOM: Loops through all inputs, selects, textareas, and buttons and sets their disabled attribute to TRUE.
🛠️

Admin Tools: Debug & Reset

Developer Only

The landing page contains two powerful administrative tools embedded at the top of the PHP script. Note: These tools are hidden from normal users via a PHP variable at the very top of the Dashboard template file ($dev_debug_display). To reveal the tools, simply change this variable from 'none' to 'block'.

The Debug Mode Extraction

A red dashed banner displays the exact, real-time value of the assessment_mode key directly from the database.

  • Purpose: Allows admins to verify that the AJAX requests are successfully rewriting the database state.
  • Error Handling: If the JSON is broken or the external file path is wrong, this banner will output the specific system error instead of the mode.
The Force Reset Trigger

A highly destructive URL parameter link (?force_reset_db=1) that bypasses all UI checks.

  • Action: Immediately overwrites the logged-in user’s entire database row with the contents of schema-empty.json.
  • Purpose: Used during development to instantly wipe corrupted test data and return the profile to absolute zero without requiring database access via phpMyAdmin.